From d8c95cc027409a21735a7e910a26116cbc6849ea Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 17 Apr 2009 14:15:18 -0700 Subject: [PATCH] Squashed commit of the following: commit e5c24638f98162c3b75b4c67a16b510d38e31341 Author: Mathias Agopian Date: Fri Apr 17 14:09:03 2009 -0700 oops forgot this file. commit 282642632d0cb12882eecf42e0fdfb2343275de1 Author: Mathias Agopian Date: Fri Apr 17 14:07:32 2009 -0700 use a helper macro for creating Singleton<>'s static attributes instances. --- include/utils/Singleton.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/utils/Singleton.h b/include/utils/Singleton.h index ee07df11f..2f7c7c2db 100644 --- a/include/utils/Singleton.h +++ b/include/utils/Singleton.h @@ -49,6 +49,18 @@ private: static TYPE* sInstance; }; +/* + * use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file + * (eg: .cpp) to create the static instance of Singleton<>'s attributes, + * and avoid to have a copy of them in each compilation units Singleton + * is used. + */ + +#define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \ + template< class TYPE > Mutex Singleton< TYPE >::sLock; \ + template<> TYPE* Singleton< TYPE >::sInstance(0); + + // --------------------------------------------------------------------------- }; // namespace android