1 ////////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2006 Peter Kümmel
4 // Permission to use, copy, modify, distribute and sell this software for any
5 // purpose is hereby granted without fee, provided that the above copyright
6 // notice appear in all copies and that both that copyright notice and this
7 // permission notice appear in supporting documentation.
8 // The author makes no representations about the
9 // suitability of this software for any purpose. It is provided "as is"
10 // without express or implied warranty.
11 ////////////////////////////////////////////////////////////////////////////////
12 #ifndef LOKI_REGISTER_INC_
13 #define LOKI_REGISTER_INC_
15 // $Id: Register.h 776 2006-11-09 13:12:57Z syntheticpp $
18 #include "TypeManip.h"
19 #include "HierarchyGenerators.h"
21 /// \defgroup RegisterGroup Register
26 ////////////////////////////////////////////////////////////////////////////////
28 // Helper classes/functions for RegisterByCreateSet
30 ////////////////////////////////////////////////////////////////////////////////
32 ////////////////////////////////////////////////////////////////////////////////
33 /// \ingroup RegisterGroup
34 /// Must be specialized be the user
35 ////////////////////////////////////////////////////////////////////////////////
36 template<class t> bool RegisterFunction();
38 ////////////////////////////////////////////////////////////////////////////////
39 /// \ingroup RegisterGroup
40 /// Must be specialized be the user
41 ////////////////////////////////////////////////////////////////////////////////
42 template<class t> bool UnRegisterFunction();
47 struct RegisterOnCreate
51 RegisterFunction<T>();
56 struct UnRegisterOnDelete
60 UnRegisterFunction<T>();
65 struct RegisterOnCreateElement
67 RegisterOnCreate<T> registerObj;
71 struct UnRegisterOnDeleteElement
73 UnRegisterOnDelete<T> unregisterObj;
77 ////////////////////////////////////////////////////////////////////////////////
78 /// \class RegisterOnCreateSet
80 /// \ingroup RegisterGroup
81 /// Implements a generic register class which registers classes of a typelist
85 ////////////////////////////////////////////////////////////////////////////////
87 template<typename ElementList>
88 struct RegisterOnCreateSet
89 : GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement>
92 ////////////////////////////////////////////////////////////////////////////////
93 /// \class UnRegisterOnDeleteSet
95 /// \ingroup RegisterGroup
96 /// Implements a generic register class which unregisters classes of a typelist
100 ////////////////////////////////////////////////////////////////////////////////
101 template<typename ElementList>
102 struct UnRegisterOnDeleteSet
103 : GenScatterHierarchy<ElementList, Private::UnRegisterOnDeleteElement>
107 ////////////////////////////////////////////////////////////////////////////////
108 /// \def LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST )
110 /// \ingroup RegisterGroup
111 /// Check if CLASS is in the typelist LIST.
114 /// see test/Register
115 ////////////////////////////////////////////////////////////////////////////////
118 #define LOKI_CONCATE(a,b,c,d) a ## b ## c ## d
119 #define LOKI_CONCAT(a,b,c,d) LOKI_CONCATE(a,b,c,d)
121 #define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST ) \
123 struct LOKI_CONCAT(check_,CLASS,_isInList_,LIST) \
125 typedef int LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST); \
127 typedef Loki::Select<Loki::TL::IndexOf<LIST, CLASS>::value == -1, \
129 LOKI_CONCAT(check_,CLASS,_isInList_,LIST)> \
130 ::Result LOKI_CONCAT(CLASS,isInList,LIST,result); \
131 typedef LOKI_CONCAT(CLASS,isInList,LIST,result):: \
132 LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST) \
133 LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList__,LIST);
139 #endif // end file guardian