Mirror reflection library 0.5.13

mirror/meta_namespace.hpp

Go to the documentation of this file.
00001 
00011 #ifndef MIRROR_META_NAMESPACE_1011291729_HPP
00012 #define MIRROR_META_NAMESPACE_1011291729_HPP
00013 
00014 #include <mirror/mirror_fwd.hpp>
00015 #include <mirror/meta_object_tags.hpp>
00016 #include <mirror/auxiliary/scoped_named.hpp>
00017 #include <mirror/auxiliary/global_list.hpp>
00018 #include <mirror/ct_string/basic_string.hpp>
00019 #include <mirror/meta_prog/only_if.hpp>
00020 #include <string>
00021 #include <type_traits>
00022 
00023 MIRROR_NAMESPACE_BEGIN
00024 
00025 template <class Namespace>
00026 struct meta_namespace
00027  : public aux::scoped_named_impl<Namespace>
00028 {
00029     typedef meta_namespace<typename Namespace::scope> scope;
00030     typedef typename Namespace::ct_name static_name;
00031 };
00032 
00033 // Implementation of the members meta-function for namespaces
00034 template <class Namespace>
00035 struct members<meta_namespace<Namespace> >
00036 {
00037     typedef MIRROR_GET_GLOBAL_LIST_BASE(
00038         Namespace,
00039         MIRROR_COUNTER_LUID,
00040         typename
00041     ) type;
00042 };
00043 
00044 // The implementation of namespaces for instantiation of meta_namespace
00045 template <class X>
00046 struct namespaces<meta_namespace<X> >
00047 {
00048     typedef typename mp::only_if<
00049         typename members<meta_namespace<X> >::type,
00050         mp::is_a<mp::arg<1>, meta_namespace_tag>
00051     >::type type;
00052 };
00053 
00054 namespace _namespace {
00055 
00056 // This structure provides basic meta-data about the global scope namespace
00057 /*  Do not use this structure directly, use the appropriate specialization
00058  *  of meta_namespace instead.
00059  *  .see meta_namespace
00060  */
00061 struct _
00062 {
00063     typedef mirror::meta_namespace_tag category;
00064 
00065     // The scope of this namespace is again the global scope
00066     typedef _ scope;
00067 
00068     // Implement the individual overloads of the name function
00069     MIRROR_IMPLEMENT_META_OBJECT_NAME_FUNCTIONS("")
00070     typedef typename cts::string<>::type ct_name;
00071 };
00072 
00073 // This typedef is used by the nested namespaces
00074 typedef _ _parent_namespace;
00075 
00076 } // namespace _namespace
00077 
00078 // Initialize the global list of members of this namespace
00079 MIRROR_REGISTER_GLOBAL_LIST( mirror::_namespace::_ )
00080 
00081 namespace _namespace {
00082 
00083 // This structure provides basic meta-data about unspecified local scopes
00084 /*  Do not use this structure directly, use the appropriate specialization
00085  *  of meta_namespace instead.
00086  *  .see meta_namespace
00087  */
00088 struct _unspec_scope
00089 {
00090     typedef mirror::meta_unspecified_scope_tag category;
00091 
00092     // The scope of this namespace is again the global scope
00093     typedef _ scope;
00094 
00095     // Implement the individual overloads of the name function
00096     MIRROR_IMPLEMENT_META_OBJECT_NAME_FUNCTIONS("<unspecified>")
00097     typedef typename cts::string<
00098         '<','u','n','s','p','e','c','i','f','i','e','d','>'
00099     >::type ct_name;
00100 };
00101 
00102 } // namespace _namespace
00103 
00104 // This macro implements the _ structure containing the basic metadata
00105 #define MIRROR_REGISTER_BASE_NAMESPACE_META_DATA(NAME, SPELLED) \
00106 struct _ \
00107 {  \
00108     typedef meta_namespace_tag category; \
00109     typedef _parent_namespace scope; \
00110     MIRROR_IMPLEMENT_META_OBJECT_NAME_FUNCTIONS(#NAME) \
00111     typedef typename cts::string< \
00112         MIRROR_PP_EXPAND_ARGS SPELLED \
00113     >::type ct_name; \
00114 }; \
00115 typedef _ _parent_namespace;
00116 
00117 #ifdef MIRROR_DOCUMENTATION_ONLY
00118 
00119 
00124 #define MIRROR_REG_NAMESPACE_BEGIN
00125 #else
00126 #define MIRROR_REG_NAMESPACE_BEGIN namespace _namespace {
00127 #endif
00128 
00129 #define MIRROR_REG_NAMESPACE_CTS(NAMESPACE_NAME, SPELLED) \
00130 namespace NAMESPACE_NAME { \
00131 MIRROR_REGISTER_BASE_NAMESPACE_META_DATA(NAMESPACE_NAME, SPELLED) \
00132 }
00133 
00134 #ifdef MIRROR_DOCUMENTATION_ONLY
00135 
00136 
00142 #define MIRROR_REG_NAMESPACE(NAMESPACE_NAME)
00143 #else
00144 #define MIRROR_REG_NAMESPACE(NAMESPACE_NAME) \
00145     MIRROR_REG_NAMESPACE_CTS(NAMESPACE_NAME, ())
00146 #endif
00147 
00148 #ifdef MIRROR_DOCUMENTATION_ONLY
00149 
00150 
00156 #define MIRROR_REG_NAMESPACE_END
00157 #else
00158 #define MIRROR_REG_NAMESPACE_END }
00159 #endif
00160 
00161 #ifdef MIRROR_DOCUMENTATION_ONLY
00162 
00163 
00175 #define MIRROR_INIT_NAMESPACE_MEMBER_LIST(FULL_NAMESPACE_NAME)
00176 #else
00177 #define MIRROR_INIT_NAMESPACE_MEMBER_LIST(FULL_NAMESPACE_NAME) \
00178 MIRROR_REGISTER_GLOBAL_LIST( \
00179     mirror::_namespace:: FULL_NAMESPACE_NAME ::_ \
00180 ) \
00181 MIRROR_ADD_TO_GLOBAL_LIST( \
00182     mirror::_namespace:: FULL_NAMESPACE_NAME ::_::scope, \
00183     mirror::meta_namespace< \
00184         mirror::_namespace:: FULL_NAMESPACE_NAME ::_ \
00185      > \
00186 )
00187 #endif
00188 
00189 #define MIRROR_QREG_GLOBAL_SCOPE_NAMESPACE_CTS(NAMESPACE, SPELLED) \
00190 MIRROR_REG_NAMESPACE_BEGIN \
00191 MIRROR_REG_NAMESPACE_CTS(NAMESPACE, SPELLED) \
00192 MIRROR_REG_NAMESPACE_END \
00193 MIRROR_INIT_NAMESPACE_MEMBER_LIST(NAMESPACE)
00194 
00195 #ifdef MIRROR_DOCUMENTATION_ONLY
00196 
00197 
00210 #define MIRROR_QREG_GLOBAL_SCOPE_NAMESPACE(NAMESPACE)
00211 #else
00212 #define MIRROR_QREG_GLOBAL_SCOPE_NAMESPACE(NAMESPACE) \
00213     MIRROR_QREG_GLOBAL_SCOPE_NAMESPACE_CTS(NAMESPACE, ())
00214 #endif
00215 
00216 #define MIRROR_QREG_NESTED_NAMESPACE_CTS( \
00217     PARENT_NAMESPACE, \
00218     NESTED_NAMESPACE, \
00219     SPELLED \
00220 ) \
00221 MIRROR_REG_NAMESPACE_BEGIN \
00222 namespace PARENT_NAMESPACE { \
00223 MIRROR_REG_NAMESPACE_CTS(NESTED_NAMESPACE, SPELLED) \
00224 } \
00225 MIRROR_REG_NAMESPACE_END \
00226 MIRROR_INIT_NAMESPACE_MEMBER_LIST(PARENT_NAMESPACE::NESTED_NAMESPACE)
00227 
00228 #ifdef MIRROR_DOCUMENTATION_ONLY
00229 
00230 
00246 #define MIRROR_QREG_NESTED_NAMESPACE(PARENT_NAMESPACE, NESTED_NAMESPACE)
00247 #else
00248 #define MIRROR_QREG_NESTED_NAMESPACE(PARENT_NAMESPACE, NESTED_NAMESPACE)\
00249     MIRROR_QREG_NESTED_NAMESPACE_CTS(PARENT_NAMESPACE, NESTED_NAMESPACE, ())
00250 #endif
00251 
00252 #define MIRROR_QREG_NESTED_NESTED_NAMESPACE_CTS( \
00253     GRANDPARENT_NAMESPACE, \
00254     PARENT_NAMESPACE, \
00255     NESTED_NAMESPACE, \
00256     SPELLED \
00257 )\
00258 MIRROR_REG_NAMESPACE_BEGIN \
00259 namespace GRANDPARENT_NAMESPACE { \
00260 namespace PARENT_NAMESPACE { \
00261 MIRROR_REG_NAMESPACE_CTS(NESTED_NAMESPACE, SPELLED) \
00262 } } \
00263 MIRROR_REG_NAMESPACE_END \
00264 MIRROR_INIT_NAMESPACE_MEMBER_LIST( \
00265     GRANDPARENT_NAMESPACE::PARENT_NAMESPACE::NESTED_NAMESPACE \
00266 )
00267 
00268 #ifdef MIRROR_DOCUMENTATION_ONLY
00269 
00270 
00288 #define MIRROR_QREG_NESTED_NESTED_NAMESPACE( \
00289     GRANDPARENT_NAMESPACE, \
00290     PARENT_NAMESPACE, \
00291     NESTED_NAMESPACE \
00292 )
00293 #else
00294 #define MIRROR_QREG_NESTED_NESTED_NAMESPACE( \
00295     GRANDPARENT_NAMESPACE, \
00296     PARENT_NAMESPACE, \
00297     NESTED_NAMESPACE \
00298 )    MIRROR_QREG_NESTED_NESTED_NAMESPACE_CTS( \
00299     GRANDPARENT_NAMESPACE, \
00300     PARENT_NAMESPACE, \
00301     NESTED_NAMESPACE, \
00302     () \
00303 )
00304 #endif
00305 
00306 #ifdef MIRROR_DOCUMENTATION_ONLY
00307 
00308 
00320 #define MIRRORED_NAMESPACE(FULL_NAMESPACE_NAME) mirror::MetaNamespace
00321 #else
00322 #define MIRRORED_NAMESPACE(FULL_NAMESPACE_NAME) \
00323     mirror::meta_namespace< \
00324     mirror::_namespace :: FULL_NAMESPACE_NAME :: _ \
00325     >
00326 #endif
00327 
00328 #ifdef MIRROR_DOCUMENTATION_ONLY
00329 
00330 
00340 #define MIRRORED_GLOBAL_SCOPE() mirror::MetaNamespace
00341 #else
00342 #define MIRRORED_GLOBAL_SCOPE() \
00343 mirror::meta_namespace< \
00344     mirror::_namespace:: _ \
00345 >
00346 #endif
00347 
00348 #ifdef MIRROR_DOCUMENTATION_ONLY
00349 
00350 
00361 #define MIRRORED_UNSPECIFIED_SCOPE() mirror::MetaNamespace
00362 #else
00363 #define MIRRORED_UNSPECIFIED_SCOPE() \
00364 mirror::meta_namespace< \
00365     mirror::_namespace:: _unspec_scope \
00366 >
00367 #endif
00368 
00369 
00370 MIRROR_NAMESPACE_END
00371 
00372 #endif //include guard
00373 

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.