Mirror reflection library - Rubber type-erasure utility 0.5.13
|
00001 00010 #ifndef RUBBER_META_META_OBJECT_1103151301_HPP 00011 #define RUBBER_META_META_OBJECT_1103151301_HPP 00012 00013 #include <rubber/config.hpp> 00014 #include <mirror/meta_object_tags.hpp> 00015 #include <puddle/meta_object_tags.hpp> 00016 00017 #include <string> 00018 00019 RUBBER_NAMESPACE_BEGIN 00020 00033 00034 00039 class meta_meta_object 00040 { 00041 private: 00042 std::string _base_name; 00043 std::string _construct_name; 00044 00045 static inline bool category_matches(unsigned a, unsigned b) 00046 { 00047 return (a & b) == b; 00048 } 00049 00050 puddle::meta_object_category _cat; 00051 public: 00053 template <typename MetaMetaObject> 00054 meta_meta_object(MetaMetaObject mo) 00055 : _base_name(MetaMetaObject::base_name()) 00056 , _construct_name(MetaMetaObject::construct_name()) 00057 , _cat(puddle::get_category(typename MetaMetaObject::category())) 00058 { } 00059 00061 inline std::string base_name(void) const 00062 { 00063 return _base_name; 00064 } 00065 00067 inline std::string construct_name(void) const 00068 { 00069 return _construct_name; 00070 } 00071 00073 puddle::meta_object_category category(void) const 00074 { 00075 return _cat; 00076 } 00077 00079 inline bool is_a(puddle::meta_object_category cat) const 00080 { 00081 return category_matches( 00082 unsigned(category()), 00083 unsigned(cat) 00084 ); 00085 } 00086 00087 #ifdef MIRROR_DOCUMENTATION_ONLY 00088 00089 00097 inline bool is_meta_X(void) const; 00098 #endif 00099 #define RUBBER_HELPER_MAKE_MO_IS_X(OBJECT, I, X) \ 00100 inline bool is_meta_## OBJECT(void) const \ 00101 { \ 00102 return is_a( \ 00103 puddle::meta_object_category::meta_ ## OBJECT ## _tag \ 00104 ); \ 00105 } 00106 MIRROR_FOR_EACH_META_OBJECT(RUBBER_HELPER_MAKE_MO_IS_X, _) 00107 #undef RUBBER_HELPER_MAKE_MO_IS_X 00108 }; 00109 00110 RUBBER_NAMESPACE_END 00111 00112 #endif //include guard 00113