~ubuntu-branches/ubuntu/wily/tora/wily-proposed

« back to all changes in this revision

Viewing changes to ext/loki/loki-0.1.6/include/loki/Register.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes
  • Date: 2009-04-07 13:16:05 UTC
  • mfrom: (1.2.7 upstream) (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090407131605-u422yigfv7jgg0l0
Tags: 2.0.0-3
* Cleaned up packaging a little bit.
* Added homepage information to control file.
* Bumped Standards-Version to 3.8.1.
* Released to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
////////////////////////////////////////////////////////////////////////////////
2
 
// The Loki Library
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_
14
 
 
15
 
// $Id: Register.h 776 2006-11-09 13:12:57Z syntheticpp $
16
 
 
17
 
 
18
 
#include "TypeManip.h"
19
 
#include "HierarchyGenerators.h"
20
 
 
21
 
///  \defgroup RegisterGroup Register 
22
 
 
23
 
namespace Loki
24
 
{
25
 
 
26
 
    ////////////////////////////////////////////////////////////////////////////////
27
 
    //
28
 
    //  Helper classes/functions for RegisterByCreateSet
29
 
    //
30
 
    ////////////////////////////////////////////////////////////////////////////////
31
 
 
32
 
    ////////////////////////////////////////////////////////////////////////////////
33
 
    ///  \ingroup RegisterGroup
34
 
    ///  Must be specialized be the user
35
 
    ////////////////////////////////////////////////////////////////////////////////
36
 
    template<class t> bool RegisterFunction();
37
 
 
38
 
    ////////////////////////////////////////////////////////////////////////////////
39
 
    ///  \ingroup RegisterGroup
40
 
    ///  Must be specialized be the user
41
 
    ////////////////////////////////////////////////////////////////////////////////
42
 
    template<class t> bool UnRegisterFunction();
43
 
 
44
 
    namespace Private
45
 
    {
46
 
        template<class T> 
47
 
        struct RegisterOnCreate
48
 
        {
49
 
            RegisterOnCreate()  { RegisterFunction<T>(); }
50
 
        };
51
 
 
52
 
        template<class T> 
53
 
        struct UnRegisterOnDelete
54
 
        {
55
 
            ~UnRegisterOnDelete() { UnRegisterFunction<T>(); }
56
 
        };    
57
 
 
58
 
        template<class T>
59
 
        struct RegisterOnCreateElement
60
 
        {
61
 
            RegisterOnCreate<T> registerObj;
62
 
        };
63
 
 
64
 
        template<class T>
65
 
        struct UnRegisterOnDeleteElement
66
 
        {
67
 
            UnRegisterOnDelete<T> unregisterObj;
68
 
        };
69
 
    }
70
 
 
71
 
    ////////////////////////////////////////////////////////////////////////////////
72
 
    ///  \class RegisterOnCreateSet
73
 
    ///
74
 
    ///  \ingroup RegisterGroup
75
 
    ///  Implements a generic register class which registers classes of a typelist
76
 
    ///
77
 
    ///  \par Usage
78
 
    ///  see test/Register
79
 
    ////////////////////////////////////////////////////////////////////////////////
80
 
 
81
 
    template<typename ElementList>
82
 
    struct RegisterOnCreateSet 
83
 
        : GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement>
84
 
    {};
85
 
 
86
 
    ////////////////////////////////////////////////////////////////////////////////
87
 
    ///  \class UnRegisterOnDeleteSet
88
 
    ///
89
 
    ///  \ingroup RegisterGroup
90
 
    ///  Implements a generic register class which unregisters classes of a typelist
91
 
    ///
92
 
    ///  \par Usage
93
 
    ///  see test/Register
94
 
    ////////////////////////////////////////////////////////////////////////////////
95
 
    template<typename ElementList>
96
 
    struct UnRegisterOnDeleteSet 
97
 
        : GenScatterHierarchy<ElementList, Private::UnRegisterOnDeleteElement>
98
 
    {};
99
 
 
100
 
 
101
 
    ////////////////////////////////////////////////////////////////////////////////
102
 
    ///  \def  LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST )
103
 
    ///
104
 
    ///  \ingroup RegisterGroup
105
 
    ///  Check if CLASS is in the typelist LIST.
106
 
    ///
107
 
    ///  \par Usage
108
 
    ///  see test/Register
109
 
    ////////////////////////////////////////////////////////////////////////////////
110
 
 
111
 
    
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)
114
 
 
115
 
#define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST )                                \
116
 
                                                                                \
117
 
    struct LOKI_CONCAT(check_,CLASS,_isInList_,LIST)                            \
118
 
    {                                                                           \
119
 
        typedef int LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST);         \
120
 
    };                                                                          \
121
 
    typedef Loki::Select<Loki::TL::IndexOf<LIST, CLASS>::value == -1,           \
122
 
                        CLASS,                                                  \
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);
128
 
 
129
 
 
130
 
} // namespace Loki
131
 
 
132
 
 
133
 
#endif // end file guardian
134