Mirror reflection library 0.5.13

mirror/meta_meta_object.hpp

Go to the documentation of this file.
00001 
00011 #ifndef MIRROR_META_META_OBJECT_1011291729_HPP
00012 #define MIRROR_META_META_OBJECT_1011291729_HPP
00013 
00014 #include <mirror/mirror_fwd.hpp>
00015 #include <mirror/meta_object_tags.hpp>
00016 #include <mirror/preprocessor.hpp>
00017 #include <mirror/auxiliary/scoped_named.hpp>
00018 #include <mirror/meta_prog/range.hpp>
00019 #include <mirror/ct_string/basic_string.hpp>
00020 
00021 MIRROR_NAMESPACE_BEGIN
00022 namespace aux {
00023 
00024 template <typename Tag>
00025 struct meta_meta_object_base;
00026 
00027 #define MIRROR_HLPR_MAKE_META_OBJECT_NICE_NAME(OBJECT, PREFIX) \
00028     PREFIX #OBJECT
00029 
00030 #define MIRROR_HLPR_META_OBJECT_TAG(OBJECT, X) \
00031     meta_ ## OBJECT ## _tag
00032 
00033 #define MIRROR_HLPR_IMPLEMENT_MMO_NAMES(OBJECT, I, X) \
00034 template <> \
00035 struct meta_meta_object_base<meta_## OBJECT ##_tag> \
00036 { \
00037 protected: \
00038     struct ctrt \
00039     { \
00040         MIRROR_IMPLEMENT_META_OBJECT_NAME_FUNCTIONS(#OBJECT) \
00041     }; \
00042     struct base \
00043     { \
00044         MIRROR_IMPLEMENT_META_OBJECT_NAME_FUNCTIONS( \
00045             MIRROR_META_OBJECT_NICE_NAME( \
00046                 OBJECT, \
00047                 MIRROR_HLPR_MAKE_META_OBJECT_NICE_NAME, \
00048                 "Meta" \
00049             ) \
00050         ) \
00051     };\
00052 public: \
00053     typedef mirror::mp::range< \
00054         MIRROR_FOR_EACH_META_OBJECT_BASE( \
00055             OBJECT, \
00056             MIRROR_HLPR_META_OBJECT_TAG, \
00057             _, \
00058             MIRROR_PP_COMMA \
00059         ) \
00060     > gens; \
00061 };
00062 
00063 MIRROR_FOR_EACH_META_OBJECT(MIRROR_HLPR_IMPLEMENT_MMO_NAMES, _)
00064 #undef MIRROR_HLPR_MAKE_META_OBJECT_NICE_NAME
00065 #undef MIRROR_HLPR_IMPLEMENT_MMO_NAMES
00066 
00067 template <typename Range>
00068 struct wrap_mmo_gens;
00069 
00070 template <typename ... T>
00071 struct wrap_mmo_gens<mirror::mp::range<T...> >
00072 {
00073     typedef mirror::mp::range<
00074         mirror::meta_meta_object<T>...
00075     > type;
00076 };
00077 
00078 } // namespace aux
00079 
00080 template <typename MetaObjectCategory>
00081 struct meta_meta_object : aux::meta_meta_object_base<
00082     MetaObjectCategory
00083 >
00084 {
00085 public:
00086     // The category of the reflected meta-object
00087     typedef MetaObjectCategory category;
00088 private:
00089     typedef aux::meta_meta_object_base< category > base_class;
00090 
00091     static std::string make_ctrt_name(std::string res)
00092     {
00093         std::string::iterator i = res.begin(), e = res.end();
00094         while(i != e)
00095         {
00096             if(*i == '_') *i = ' ';
00097             ++i;
00098         }
00099         return res;
00100     }
00101 public:
00102     typedef typename mirror::cts::string<>::type static_name;
00103 
00104     // Returns the base name of the meta-object
00105     static std::string base_name(void)
00106     {
00107         return std::string(
00108             base_class::base::name(),
00109             base_class::base::name_length()
00110         );
00111     }
00112 
00113     // Returns the name of the construct reflected by the meta-object
00114     static std::string construct_name(void)
00115     {
00116         static std::string res = make_ctrt_name(
00117             std::string(
00118                 base_class::ctrt::name(),
00119                 base_class::ctrt::name_length()
00120             )
00121         );
00122         return res;
00123     }
00124 };
00125 
00126 template <typename MetaObjectCategory>
00127 struct generalizations<meta_meta_object<MetaObjectCategory> >
00128 {
00129     typedef typename mirror::aux::wrap_mmo_gens<
00130         typename mirror::aux::meta_meta_object_base<
00131             MetaObjectCategory
00132         >::gens
00133     >::type type;
00134 };
00135 
00136 #ifdef MIRROR_DOCUMENTATION_ONLY
00137 
00138 
00151 #define MIRRORED_META_OBJECT(META_OBJECT) mirror::MetaMetaObject
00152 #else
00153 #define MIRRORED_META_OBJECT(META_OBJECT) \
00154     mirror::meta_meta_object< \
00155         typename mirror::meta_object_category< META_OBJECT >::type \
00156     >
00157 #endif
00158 
00159 
00160 MIRROR_NAMESPACE_END
00161 
00162 #endif //include guard
00163 

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.