00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012 #ifndef LOKI_REGISTER_INC_
00013 #define LOKI_REGISTER_INC_
00014
00015
00016
00017
00018 #include "TypeManip.h"
00019 #include "HierarchyGenerators.h"
00020
00022
00023 namespace Loki
00024 {
00025
00027
00028
00029
00031
00036 template<class t> bool RegisterFunction();
00037
00042 template<class t> bool UnRegisterFunction();
00043
00044 namespace Private
00045 {
00046 template<class T>
00047 struct RegisterOnCreate
00048 {
00049 RegisterOnCreate() { RegisterFunction<T>(); }
00050 };
00051
00052 template<class T>
00053 struct UnRegisterOnDelete
00054 {
00055 ~UnRegisterOnDelete() { UnRegisterFunction<T>(); }
00056 };
00057
00058 template<class T>
00059 struct RegisterOnCreateElement
00060 {
00061 RegisterOnCreate<T> registerObj;
00062 };
00063
00064 template<class T>
00065 struct UnRegisterOnDeleteElement
00066 {
00067 UnRegisterOnDelete<T> unregisterObj;
00068 };
00069 }
00070
00080
00081 template<typename ElementList>
00082 struct RegisterOnCreateSet
00083 : GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement>
00084 {};
00085
00095 template<typename ElementList>
00096 struct UnRegisterOnDeleteSet
00097 : GenScatterHierarchy<ElementList, Private::UnRegisterOnDeleteElement>
00098 {};
00099
00100
00110
00111
00112 #define LOKI_CONCATE(a,b,c,d) a ## b ## c ## d
00113 #define LOKI_CONCAT(a,b,c,d) LOKI_CONCATE(a,b,c,d)
00114
00115 #define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST ) \
00116 \
00117 struct LOKI_CONCAT(check_,CLASS,_isInList_,LIST) \
00118 { \
00119 typedef int LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST); \
00120 }; \
00121 typedef Loki::Select<Loki::TL::IndexOf<LIST, CLASS>::value == -1, \
00122 CLASS, \
00123 LOKI_CONCAT(check_,CLASS,_isInList_,LIST)> \
00124 ::Result LOKI_CONCAT(CLASS,isInList,LIST,result); \
00125 typedef LOKI_CONCAT(CLASS,isInList,LIST,result):: \
00126 LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST) \
00127 LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList__,LIST);
00128
00129
00130 }
00131
00132
00133 #endif // end file guardian
00134