Bayeux  3.4.1
Core Foundation library for SuperNEMO
reflection_export.h
Go to the documentation of this file.
1 // This code is derived by from Boost/Serialization export code.
3 
4 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5 // Use, modification and distribution is subject to the Boost Software
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 
10 #ifndef DATATOOLS_DETAIL_REFLECTION_EXPORT_H
11 #define DATATOOLS_DETAIL_REFLECTION_EXPORT_H
12 
13 // Third party:
14 // - Boost:
15 #include <boost/mpl/bool.hpp>
16 #include <boost/serialization/singleton.hpp>
17 
18 namespace datatools {
19  namespace detail {
20  namespace reflection {
21 
23  template<class T>
25  {
26  void export_guid(int tag) const
27  {
28  ::datatools::detail::reflection::implement_reflection<T> (tag);
29  return;
30  }
31  guid_initializer const & export_guid() const
32  {
33  //BOOST_STATIC_WARNING(boost::is_polymorphic< T >::value);
34  // note: exporting an abstract base class will have no effect
35  // and cannot be used to instantitiate serialization code
36  // (one might be using this in a DLL to instantiate code)
37  //BOOST_STATIC_WARNING(! boost::serialization::is_abstract< T >::value);
38  //export_guid(boost::serialization::is_abstract< T >());
39  export_guid (0);
40  return *this;
41  }
42  };
43 
44  template<typename T>
45  struct init_guid;
46 
47  } // namespace reflection
48  } // namespace detail
49 } // namespace datatools
50 
51 
52 namespace datatools {
53  namespace detail {
54  namespace reflection {
56  template<class T>
57  struct guid_defined : boost::mpl::false_ {};
58  template<class T>
59  inline const char * guid()
60  {
61  return NULL;
62  }
63 
64  } // namespace reflection
65  } // namespace detail
66 } // namespace datatools
67 
72 
83 #define DR_CLASS_EXPORT_IMPLEMENT(T) \
84  namespace datatools { \
85  namespace detail { \
86  namespace reflection { \
87  template<> \
88  struct init_guid< T > { \
89  static guid_initializer< T > const & g; \
90  }; \
91  guid_initializer< T > const & init_guid< T >::g = \
92  ::boost::serialization::singleton< guid_initializer< T > > \
93  ::get_mutable_instance().export_guid(); \
94  }}} \
95 
96 
97 
102 
107 #define DR_CLASS_EXPORT_KEY(T, K) \
108  namespace datatools { \
109  namespace detail { \
110  namespace reflection { \
111  template<> \
112  struct guid_defined< T > : boost::mpl::true_ {}; \
113  template<> \
114  inline const char * guid< T >(){ \
115  return K; \
116  } \
117  }}} \
118 
119 
124 
129 #define DR_CLASS_EXPORT(T, K) \
130  DR_CLASS_EXPORT_KEY (T, K) \
131  DR_CLASS_EXPORT_IMPLEMENT (T) \
132 
133 
136 #define DR_TYPE_EXPORT(T, K) \
137  DR_CLASS_EXPORT (T, K) \
138 
139 
140 #endif // DATATOOLS_DETAIL_REFLECTION_EXPORT_H
141 
142 // Local Variables: --
143 // mode: c++ --
144 // c-file-style: "gnu" --
145 // tab-width: 2 --
146 // End: --
void export_guid(int tag) const
Definition: reflection_export.h:26
Struct used internally by the reflection mechanism.
Definition: reflection_export.h:57
Definition: reflection_export.h:45
guid_initializer const & export_guid() const
Definition: reflection_export.h:31
Struct used internally by the reflection mechanism.
Definition: reflection_export.h:24
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
const char * guid()
Definition: reflection_export.h:59