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
49
RegisterOnCreate() { RegisterFunction<T>(); }
53
struct UnRegisterOnDelete
55
~UnRegisterOnDelete() { UnRegisterFunction<T>(); }
59
struct RegisterOnCreateElement
61
RegisterOnCreate<T> registerObj;
65
struct UnRegisterOnDeleteElement
67
UnRegisterOnDelete<T> unregisterObj;
71
////////////////////////////////////////////////////////////////////////////////
72
/// \class RegisterOnCreateSet
74
/// \ingroup RegisterGroup
75
/// Implements a generic register class which registers classes of a typelist
79
////////////////////////////////////////////////////////////////////////////////
81
template<typename ElementList>
82
struct RegisterOnCreateSet
83
: GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement>
86
////////////////////////////////////////////////////////////////////////////////
87
/// \class UnRegisterOnDeleteSet
89
/// \ingroup RegisterGroup
90
/// Implements a generic register class which unregisters classes of a typelist
94
////////////////////////////////////////////////////////////////////////////////
95
template<typename ElementList>
96
struct UnRegisterOnDeleteSet
97
: GenScatterHierarchy<ElementList, Private::UnRegisterOnDeleteElement>
101
////////////////////////////////////////////////////////////////////////////////
102
/// \def LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST )
104
/// \ingroup RegisterGroup
105
/// Check if CLASS is in the typelist LIST.
108
/// see test/Register
109
////////////////////////////////////////////////////////////////////////////////
112
#define LOKI_CONCATE(a,b,c,d) a ## b ## c ## d
113
#define LOKI_CONCAT(a,b,c,d) LOKI_CONCATE(a,b,c,d)
115
#define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST ) \
117
struct LOKI_CONCAT(check_,CLASS,_isInList_,LIST) \
119
typedef int LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST); \
121
typedef Loki::Select<Loki::TL::IndexOf<LIST, CLASS>::value == -1, \
123
LOKI_CONCAT(check_,CLASS,_isInList_,LIST)> \
124
::Result LOKI_CONCAT(CLASS,isInList,LIST,result); \
125
typedef LOKI_CONCAT(CLASS,isInList,LIST,result):: \
126
LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST) \
127
LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList__,LIST);
133
#endif // end file guardian