andorid sp
来源:互联网 发布:人工智能之父西蒙 编辑:程序博客网 时间:2024/04/28 22:42
template <typename TYPE>
class ANDROID_API Singleton 模板单例类
{
public:
static TYPE& getInstance() {//static 构成单例类很重要
Mutex::Autolock _l(sLock);
TYPE* instance = sInstance;
if (instance == 0) {
instance = new TYPE();
sInstance = instance;
}
return *instance;
}
class ComposerService : public Singleton<ComposerService>
getService(name, &mComposerService)
template<typename INTERFACE>
status_t getService(const String16& name, sp<INTERFACE>* outService)
{
const sp<IServiceManager> sm = defaultServiceManager();
if (sm != NULL) {
*outService = interface_cast<INTERFACE>(sm->getService(name));
if ((*outService) != NULL) return NO_ERROR;
}
return NAME_NOT_FOUND;
}
template<typename INTERFACE>
inline sp<INTERFACE> interface_cast(const sp<IBinder>& obj)
{
return INTERFACE::asInterface(obj);
}
template <typename T>
class sp
{
public:
inline sp() : m_ptr(0) { }
sp(T* other);
template<typename U> sp(U* other);
}
template<typename T>
sp<T>::sp(T* other)
: m_ptr(other)
{
if (other) other->incStrong(this);
}
template<typename T> template<typename U>
sp<T>::sp(U* other) : m_ptr(other)
{
if (other) ((T*)other)->incStrong(this);
}
- andorid sp
- SP
- SP
- sp
- sp
- SP
- sp
- Android sp & sp
- Android sp & sp
- SP namespace (sp.js)
- Andorid ireader
- andorid gridview
- Andorid Activity
- 学习andorid
- andorid webview
- Andorid控件
- Andorid更新
- Andorid框架
- 思维导图之我的电影之旅
- xp 下安装virtualbox 安装ubuntu12.04 lts
- 自己写的一个企业管理程序,很简陋,随便看看吧
- Ubuntu 13.04里longene QQ无法调用fcitx输入法问题解决
- Ubuntu下Eclipse中文乱码解决
- andorid sp
- 人临死前最后悔的五件事
- C++函数与java函数菜鸟级的对比理解
- 文件字符读入算法分析
- switch-case
- 企业管理程序数据删除代码
- 《JavaScript语言精粹》--第5章:继承
- lua 冒号由来
- Linux驱动开发-----内存存取