Mirror reflection library - Rubber type-erasure utility 0.5.13

rubber/meta_object.hpp

Go to the documentation of this file.
00001 
00010 #ifndef RUBBER_META_OBJECT_1103151301_HPP
00011 #define RUBBER_META_OBJECT_1103151301_HPP
00012 
00013 #include <rubber/config.hpp>
00014 #include <rubber/meta_meta_object.hpp>
00015 #include <mirror/meta_object_tags.hpp>
00016 
00017 RUBBER_NAMESPACE_BEGIN
00018 
00020 
00025 class meta_object
00026 {
00027 private:
00028     int _uid;
00029     aux::return_value<meta_meta_object>::type (*_get_self)(void);
00030 public:
00031     template <typename MetaObject>
00032     meta_object(MetaObject mo)
00033      : _uid(aux::meta_object_uid(mo))
00034      , _get_self(
00035         &wrap_shaped<
00036             MIRRORED_META_OBJECT(MetaObject),
00037             meta_meta_object
00038         >
00039     )
00040     { }
00041 
00042 #if RUBBER_POLYMORPHIC_META_OBJECT
00043     virtual ~meta_object(void)
00044     { }
00045 #endif
00046 
00048     inline int uid(void) const
00049     {
00050         return _uid;
00051     }
00052 
00054     friend bool operator == (const meta_object& a, const meta_object& b)
00055     {
00056         return a.uid() == b.uid();
00057     }
00058 
00060     friend bool operator != (const meta_object& a, const meta_object& b)
00061     {
00062         return a.uid() != b.uid();
00063     }
00064 
00066     friend bool operator <= (const meta_object& a, const meta_object& b)
00067     {
00068         return a.uid() <= b.uid();
00069     }
00070 
00072     friend bool operator >= (const meta_object& a, const meta_object& b)
00073     {
00074         return a.uid() >= b.uid();
00075     }
00076 
00078     friend bool operator <  (const meta_object& a, const meta_object& b)
00079     {
00080         return a.uid() <  b.uid();
00081     }
00082 
00084     friend bool operator >  (const meta_object& a, const meta_object& b)
00085     {
00086         return a.uid() >  b.uid();
00087     }
00088 
00090     aux::return_value<meta_meta_object>::type self(void) const
00091     {
00092         assert(_get_self != nullptr);
00093         return _get_self();
00094     }
00095 
00097     puddle::meta_object_category category(void) const
00098     {
00099         return self().category();
00100     }
00101 
00102     #ifdef MIRROR_DOCUMENTATION_ONLY
00103 
00104 
00112     bool is_X(void) const;
00113     #endif
00114 #define RUBBER_HELPER_MAKE_MO_IS_X(OBJECT, I, X) \
00115     inline bool is_## OBJECT(void) const \
00116     { \
00117         return self().is_meta_## OBJECT(); \
00118     }
00119 MIRROR_FOR_EACH_META_OBJECT(RUBBER_HELPER_MAKE_MO_IS_X, _)
00120 #undef RUBBER_HELPER_MAKE_MO_IS_X
00121 
00122 #ifdef MIRROR_DOCUMENTATION_ONLY
00123 
00124 
00133     template <typename TypeErased>
00134     const TypeErased& as(void) const
00135 #endif
00136 #if RUBBER_POLYMORPHIC_META_OBJECT
00137     template <typename TypeErased>
00138     const TypeErased& as(void) const
00139     {
00140         return dynamic_cast<const TypeErased&>(*this);
00141     }
00142 #endif
00143 };
00144 
00145 RUBBER_NAMESPACE_END
00146 
00147 #endif //include guard
00148 

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.