Mirror reflection library - Lagoon run-time layer 0.5.13
|
00001 00010 #ifndef LAGOON_SPECIFIERS_1011291729_HPP 00011 #define LAGOON_SPECIFIERS_1011291729_HPP 00012 00013 #include <lagoon/lagoon_fwd.hpp> 00014 #include <lagoon/auxiliary/fwd.hpp> 00015 #include <lagoon/utils.hpp> 00016 #include <puddle/specifiers.hpp> 00017 #include <mirror/specifier_tags.hpp> 00018 #include <mirror/preprocessor.hpp> 00019 00020 LAGOON_NAMESPACE_BEGIN 00021 00029 00030 00037 #ifdef MIRROR_DOCUMENTATION_ONLY 00038 enum specifier_category; 00039 #else 00040 using puddle::specifier_category; 00041 #endif 00042 00044 00049 struct specifier 00050 { 00051 private: 00052 const std::string _keyword; 00053 specifier_category _category; 00054 00055 static inline bool category_matches(unsigned a, unsigned b) 00056 { 00057 return (a & b) == b; 00058 } 00059 protected: 00060 template <class Specifier> 00061 specifier(Specifier) 00062 : _keyword(Specifier::keyword()) 00063 , _category(puddle::get_category(Specifier())) 00064 { } 00065 public: 00067 std::string keyword(void) 00068 { 00069 return _keyword; 00070 } 00071 00073 specifier_category category(void) 00074 { 00075 return _category; 00076 } 00077 00079 inline bool is_a(specifier_category cat) 00080 { 00081 return category_matches( 00082 unsigned(category()), 00083 unsigned(cat) 00084 ); 00085 } 00086 00088 bool is_none(void) 00089 { 00090 return is_a(specifier_category::spec__tag); 00091 } 00092 00093 #define LAGOON_HELPER_MAKE_IS_SPEC_GROUP_FN_false(KIND) 00094 #define LAGOON_HELPER_MAKE_IS_SPEC_GROUP_FN_true(KIND) \ 00095 bool is_ ## KIND ## _spec(void) \ 00096 { \ 00097 return is_a(specifier_category::spec_##KIND##_tag); \ 00098 } 00099 #define LAGOON_HELPER_MAKE_IS_SPEC_GROUP_FN(SPEC, KW, GRP, I, X) \ 00100 LAGOON_HELPER_MAKE_IS_SPEC_GROUP_FN_##GRP(SPEC) 00101 00102 MIRROR_FOR_EACH_SPECIFIER( 00103 LAGOON_HELPER_MAKE_IS_SPEC_GROUP_FN, 00104 0 00105 ) 00106 00107 #undef LAGOON_HELPER_MAKE_IS_SPEC_GROUP_FN_false 00108 #undef LAGOON_HELPER_MAKE_IS_SPEC_GROUP_FN_true 00109 #undef LAGOON_HELPER_MAKE_IS_SPEC_GROUP_FN 00110 }; 00111 00112 00113 #define LAGOON_HELPER_MAKE_SPEC_KIND_IS_X_FN(SPEC, X) \ 00114 bool is_ ## SPEC(void) \ 00115 { \ 00116 return is_a(specifier_category::spec_## SPEC ##_tag);\ 00117 } 00118 00119 00120 #define LAGOON_HELPER_MAKE_SPEC_KIND_INTF_false(KIND) 00121 #define LAGOON_HELPER_MAKE_SPEC_KIND_INTF_true(KIND) \ 00122 struct KIND ## _specifier : public specifier \ 00123 { \ 00124 private: \ 00125 template <typename Specifier, typename Interface> \ 00126 friend shared<Interface> aux::get_##KIND##_spec(void);\ 00127 \ 00128 template <class Specifier> \ 00129 KIND ## _specifier(Specifier spec) \ 00130 : specifier(spec) \ 00131 { } \ 00132 public: \ 00133 MIRROR_FOR_EACH_SPECIFIER_TYPE( \ 00134 KIND, \ 00135 LAGOON_HELPER_MAKE_SPEC_KIND_IS_X_FN, \ 00136 0, \ 00137 MIRROR_PP_EMPTY \ 00138 ) \ 00139 }; 00140 00141 #define LAGOON_HELPER_MAKE_SPEC_KIND_INTF(SPEC, KW, GRP, I, X)\ 00142 LAGOON_HELPER_MAKE_SPEC_KIND_INTF_##GRP(SPEC) 00143 00144 MIRROR_FOR_EACH_SPECIFIER( 00145 LAGOON_HELPER_MAKE_SPEC_KIND_INTF, 00146 0 00147 ) 00148 00149 #undef LAGOON_HELPER_MAKE_SPEC_KIND_INTF 00150 #undef LAGOON_HELPER_MAKE_SPEC_KIND_INTF_false 00151 #undef LAGOON_HELPER_MAKE_SPEC_KIND_INTF_true 00152 #undef LAGOON_HELPER_MAKE_SPEC_KIND_IS_X_FN 00153 00154 LAGOON_NAMESPACE_END 00155 00156 00157 #endif //include guard 00158