Register.h

00001 
00002 // The Loki Library
00003 // Copyright (c) 2006 Peter Kümmel
00004 // Permission to use, copy, modify, distribute and sell this software for any 
00005 //     purpose is hereby granted without fee, provided that the above copyright 
00006 //     notice appear in all copies and that both that copyright notice and this 
00007 //     permission notice appear in supporting documentation.
00008 // The author makes no representations about the 
00009 //     suitability of this software for any purpose. It is provided "as is" 
00010 //     without express or implied warranty.
00012 #ifndef LOKI_REGISTER_INC_
00013 #define LOKI_REGISTER_INC_
00014 
00015 // $Id: Register.h 776 2006-11-09 13:12:57Z syntheticpp $
00016 
00017 
00018 #include "TypeManip.h"
00019 #include "HierarchyGenerators.h"
00020 
00022 
00023 namespace Loki
00024 {
00025 
00027     //
00028     //  Helper classes/functions for RegisterByCreateSet
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 } // namespace Loki
00131 
00132 
00133 #endif // end file guardian
00134 

Generated on Sun Feb 25 16:52:26 2007 for Loki by  doxygen 1.5.1-p1