Mirror reflection library 0.5.13

mirror/meta_object_tags.hpp

Go to the documentation of this file.
00001 
00011 #ifndef MIRROR_META_OBJECT_TAGS_1011291729_HPP
00012 #define MIRROR_META_OBJECT_TAGS_1011291729_HPP
00013 
00014 #include <mirror/config.hpp>
00015 #include <type_traits>
00016 
00017 MIRROR_NAMESPACE_BEGIN
00018 
00030 
00031 
00039 struct non_meta_object_tag
00040 { };
00041 
00043 
00049 struct meta_object_tag
00050 { };
00051 
00052 #define MIRROR_META_OBJECT_NAME_object(MACRO, DATA) \
00053     MACRO(Object, DATA)
00054 #define MIRROR_FOR_EACH_MO_BASE_object(MACRO, DATA, SEP_MACRO)
00055 
00056 
00058 
00064 struct meta_named_object_tag
00065  : virtual public meta_object_tag
00066 { };
00067 
00068 #define MIRROR_META_OBJECT_NAME_named_object(MACRO, DATA) \
00069     MACRO(NamedObject, DATA)
00070 #define MIRROR_FOR_EACH_MO_BASE_named_object(MACRO, DATA, SEP_MACRO) \
00071     MACRO(object, DATA)
00072 
00073 
00075 
00081 struct meta_meta_object_tag
00082  : virtual public meta_named_object_tag
00083 { };
00084 
00085 #define MIRROR_META_OBJECT_NAME_meta_object(MACRO, DATA) \
00086     MACRO(MetaObject, DATA)
00087 #define MIRROR_FOR_EACH_MO_BASE_meta_object(MACRO, DATA, SEP_MACRO) \
00088     MACRO(named_object, DATA)
00089 
00090 
00092 
00098 struct meta_scoped_object_tag
00099  : virtual public meta_object_tag
00100 { };
00101 
00102 #define MIRROR_META_OBJECT_NAME_scoped_object(MACRO, DATA) \
00103     MACRO(ScopedObject, DATA)
00104 #define MIRROR_FOR_EACH_MO_BASE_scoped_object(MACRO, DATA, SEP_MACRO) \
00105     MACRO(object, DATA)
00106 
00107 
00109 
00115 struct meta_named_scoped_object_tag
00116  : virtual public meta_named_object_tag
00117  , virtual public meta_scoped_object_tag
00118 { };
00119 
00120 #define MIRROR_META_OBJECT_NAME_named_scoped_object(MACRO, DATA) \
00121     MACRO(NamedScopedObject, DATA)
00122 #define MIRROR_FOR_EACH_MO_BASE_named_scoped_object(MACRO, DATA, SEP_MACRO) \
00123     MACRO(named_object, DATA) \
00124     SEP_MACRO() \
00125     MACRO(scoped_object, DATA)
00126 
00127 
00129 
00135 struct meta_scope_tag
00136  : virtual public meta_named_scoped_object_tag
00137 { };
00138 
00139 #define MIRROR_META_OBJECT_NAME_scope(MACRO, DATA) \
00140     MACRO(Scope, DATA)
00141 #define MIRROR_FOR_EACH_MO_BASE_scope(MACRO, DATA, SEP_MACRO) \
00142     MACRO(named_scoped_object, DATA)
00143 
00144 
00146 
00152 struct meta_unspecified_scope_tag
00153  : virtual public meta_scope_tag
00154 { };
00155 
00156 #define MIRROR_META_OBJECT_NAME_unspecified_scope(MACRO, DATA) \
00157     MACRO(Scope, DATA)
00158 #define MIRROR_FOR_EACH_MO_BASE_unspecified_scope(MACRO, DATA, SEP_MACRO) \
00159     MACRO(scope, DATA)
00160 
00161 
00163 
00169 struct meta_namespace_tag
00170  : virtual public meta_scope_tag
00171 { };
00172 
00173 #define MIRROR_META_OBJECT_NAME_namespace(MACRO, DATA) \
00174     MACRO(Namespace, DATA)
00175 #define MIRROR_FOR_EACH_MO_BASE_namespace(MACRO, DATA, SEP_MACRO) \
00176     MACRO(scope, DATA)
00177 
00178 
00180 
00186 struct meta_global_scope_tag
00187  : virtual public meta_namespace_tag
00188 { };
00189 
00190 #define MIRROR_META_OBJECT_NAME_global_scope(MACRO, DATA) \
00191     MACRO(GlobalScope, DATA)
00192 #define MIRROR_FOR_EACH_MO_BASE_global_scope(MACRO, DATA, SEP_MACRO) \
00193     MACRO(namespace, DATA)
00194 
00195 
00197 
00203 struct meta_type_tag
00204  : virtual public meta_named_scoped_object_tag
00205 { };
00206 
00207 #define MIRROR_META_OBJECT_NAME_type(MACRO, DATA) \
00208     MACRO(Type, DATA)
00209 #define MIRROR_FOR_EACH_MO_BASE_type(MACRO, DATA, SEP_MACRO) \
00210     MACRO(named_scoped_object, DATA)
00211 
00212 
00214 
00220 struct meta_templated_type_tag
00221  : virtual public meta_type_tag
00222 { };
00223 
00224 #define MIRROR_META_OBJECT_NAME_templated_type(MACRO, DATA) \
00225     MACRO(TemplatedType, DATA)
00226 #define MIRROR_FOR_EACH_MO_BASE_templated_type(MACRO, DATA, SEP_MACRO) \
00227     MACRO(type, DATA)
00228 
00229 
00231 
00237 struct meta_type_template_tag
00238  : virtual public meta_named_scoped_object_tag
00239 { };
00240 
00241 #define MIRROR_META_OBJECT_NAME_type_template(MACRO, DATA) \
00242     MACRO(TypeTemplate, DATA)
00243 #define MIRROR_FOR_EACH_MO_BASE_type_template(MACRO, DATA, SEP_MACRO) \
00244     MACRO(named_scoped_object, DATA)
00245 
00246 
00248 
00254 struct meta_typedef_tag
00255  : virtual public meta_type_tag
00256 { };
00257 
00258 #define MIRROR_META_OBJECT_NAME_typedef(MACRO, DATA) \
00259     MACRO(Typedef, DATA)
00260 #define MIRROR_FOR_EACH_MO_BASE_typedef(MACRO, DATA, SEP_MACRO) \
00261     MACRO(type, DATA)
00262 
00263 
00265 
00271 struct meta_class_tag
00272  : virtual public meta_type_tag
00273  , virtual public meta_scope_tag
00274 { };
00275 
00276 #define MIRROR_META_OBJECT_NAME_class(MACRO, DATA) \
00277     MACRO(Class, DATA)
00278 #define MIRROR_FOR_EACH_MO_BASE_class(MACRO, DATA, SEP_MACRO) \
00279     MACRO(type, DATA) \
00280     SEP_MACRO() \
00281     MACRO(scope, DATA)
00282 
00283 
00285 
00291 struct meta_class_member_tag
00292  : virtual public meta_named_scoped_object_tag
00293 { };
00294 
00295 #define MIRROR_META_OBJECT_NAME_class_member(MACRO, DATA) \
00296     MACRO(ClassMember, DATA)
00297 #define MIRROR_FOR_EACH_MO_BASE_class_member(MACRO, DATA, SEP_MACRO) \
00298     MACRO(named_scoped_object, DATA)
00299 
00300 
00302 
00308 struct meta_templated_class_tag
00309  : virtual public meta_templated_type_tag
00310  , virtual public meta_class_tag
00311 { };
00312 
00313 #define MIRROR_META_OBJECT_NAME_templated_class(MACRO, DATA) \
00314     MACRO(TemplatedClass, DATA)
00315 #define MIRROR_FOR_EACH_MO_BASE_templated_class(MACRO, DATA, SEP_MACRO) \
00316     MACRO(templated_type, DATA) \
00317     SEP_MACRO() \
00318     MACRO(class, DATA)
00319 
00320 
00322 
00328 struct meta_enum_tag
00329  : virtual public meta_type_tag
00330  , virtual public meta_scope_tag
00331 { };
00332 
00333 #define MIRROR_META_OBJECT_NAME_enum(MACRO, DATA) \
00334     MACRO(Enum, DATA)
00335 #define MIRROR_FOR_EACH_MO_BASE_enum(MACRO, DATA, SEP_MACRO) \
00336     MACRO(type, DATA) \
00337     SEP_MACRO() \
00338     MACRO(scope, DATA)
00339 
00340 
00342 
00348 struct meta_enum_value_tag
00349  : virtual public meta_named_scoped_object_tag
00350 { };
00351 
00352 #define MIRROR_META_OBJECT_NAME_enum_value(MACRO, DATA) \
00353     MACRO(EnumValue, DATA)
00354 #define MIRROR_FOR_EACH_MO_BASE_enum_value(MACRO, DATA, SEP_MACRO) \
00355     MACRO(named_scoped_object, DATA)
00356 
00357 
00359 
00365 struct meta_inheritance_tag
00366  : virtual public meta_object_tag
00367 { };
00368 
00369 #define MIRROR_META_OBJECT_NAME_inheritance(MACRO, DATA) \
00370     MACRO(Inheritance, DATA)
00371 #define MIRROR_FOR_EACH_MO_BASE_inheritance(MACRO, DATA, SEP_MACRO) \
00372     MACRO(object, DATA)
00373 
00374 
00376 
00382 struct meta_variable_tag
00383  : virtual public meta_named_scoped_object_tag
00384 { };
00385 
00386 #define MIRROR_META_OBJECT_NAME_variable(MACRO, DATA) \
00387     MACRO(Variable, DATA)
00388 #define MIRROR_FOR_EACH_MO_BASE_variable(MACRO, DATA, SEP_MACRO) \
00389     MACRO(named_scoped_object, DATA)
00390 
00392 
00398 struct meta_plain_variable_tag
00399  : virtual public meta_variable_tag
00400 { };
00401 
00402 #define MIRROR_META_OBJECT_NAME_plain_variable(MACRO, DATA) \
00403     MACRO(PlainVariable, DATA)
00404 #define MIRROR_FOR_EACH_MO_BASE_plain_variable(MACRO, DATA, SEP_MACRO) \
00405     MACRO(variable, DATA)
00406 
00408 
00414 struct meta_free_variable_tag
00415  : virtual public meta_variable_tag
00416 { };
00417 
00418 #define MIRROR_META_OBJECT_NAME_free_variable(MACRO, DATA) \
00419     MACRO(FreeVariable, DATA)
00420 #define MIRROR_FOR_EACH_MO_BASE_free_variable(MACRO, DATA, SEP_MACRO) \
00421     MACRO(variable, DATA)
00422 
00423 
00425 
00431 struct meta_plain_free_variable_tag
00432  : virtual public meta_free_variable_tag
00433  , virtual public meta_plain_variable_tag
00434 { };
00435 
00436 #define MIRROR_META_OBJECT_NAME_plain_free_variable(MACRO, DATA) \
00437     MACRO(PlainFreeVariable, DATA)
00438 #define MIRROR_FOR_EACH_MO_BASE_plain_free_variable(MACRO, DATA, SEP_MACRO) \
00439     MACRO(free_variable, DATA) \
00440     SEP_MACRO() \
00441     MACRO(plain_variable, DATA)
00442 
00443 
00445 
00451 struct meta_member_variable_tag
00452  : virtual public meta_variable_tag
00453  , virtual public meta_class_member_tag
00454 { };
00455 
00456 #define MIRROR_META_OBJECT_NAME_member_variable(MACRO, DATA) \
00457     MACRO(MemberVariable, DATA)
00458 #define MIRROR_FOR_EACH_MO_BASE_member_variable(MACRO, DATA, SEP_MACRO) \
00459     MACRO(variable, DATA) \
00460     SEP_MACRO() \
00461     MACRO(class_member, DATA)
00462 
00463 
00465 
00471 struct meta_plain_member_variable_tag
00472  : virtual public meta_member_variable_tag
00473  , virtual public meta_plain_variable_tag
00474 { };
00475 
00476 #define MIRROR_META_OBJECT_NAME_plain_member_variable(MACRO, DATA) \
00477     MACRO(PlainMemberVariable, DATA)
00478 #define MIRROR_FOR_EACH_MO_BASE_plain_member_variable(MACRO, DATA, SEP_MACRO) \
00479     MACRO(member_variable, DATA) \
00480     SEP_MACRO() \
00481     MACRO(plain_variable, DATA)
00482 
00483 
00485 
00491 struct meta_parameter_tag
00492  : virtual public meta_variable_tag
00493 { };
00494 
00495 #define MIRROR_META_OBJECT_NAME_parameter(MACRO, DATA) \
00496     MACRO(Parameter, DATA)
00497 #define MIRROR_FOR_EACH_MO_BASE_parameter(MACRO, DATA, SEP_MACRO) \
00498     MACRO(variable, DATA)
00499 
00500 
00502 
00508 struct meta_function_tag
00509  : virtual public meta_scope_tag
00510 { };
00511 
00512 #define MIRROR_META_OBJECT_NAME_function(MACRO, DATA) \
00513     MACRO(Function, DATA)
00514 #define MIRROR_FOR_EACH_MO_BASE_function(MACRO, DATA, SEP_MACRO) \
00515     MACRO(scope, DATA)
00516 
00517 
00519 
00525 struct meta_member_function_tag
00526  : virtual public meta_function_tag
00527  , virtual public meta_class_member_tag
00528 { };
00529 
00530 #define MIRROR_META_OBJECT_NAME_member_function(MACRO, DATA) \
00531     MACRO(MemberFunction, DATA)
00532 #define MIRROR_FOR_EACH_MO_BASE_member_function(MACRO, DATA, SEP_MACRO) \
00533     MACRO(function, DATA) \
00534     SEP_MACRO() \
00535     MACRO(class_member, DATA)
00536 
00537 
00539 
00545 struct meta_constructor_tag
00546  : virtual public meta_function_tag
00547  , virtual public meta_class_member_tag
00548 { };
00549 
00550 #define MIRROR_META_OBJECT_NAME_constructor(MACRO, DATA) \
00551     MACRO(Constructor, DATA)
00552 #define MIRROR_FOR_EACH_MO_BASE_constructor(MACRO, DATA, SEP_MACRO) \
00553     MACRO(function, DATA) \
00554     SEP_MACRO() \
00555     MACRO(class_member, DATA)
00556 
00557 
00559 
00565 struct meta_conversion_operator_tag
00566  : virtual public meta_member_function_tag
00567 { };
00568 
00569 #define MIRROR_META_OBJECT_NAME_conversion_operator(MACRO, DATA) \
00570     MACRO(ConversionOperator, DATA)
00571 #define MIRROR_FOR_EACH_MO_BASE_conversion_operator(MACRO, DATA, SEP_MACRO) \
00572     MACRO(member_function, DATA)
00573 
00574 
00576 
00582 struct meta_overloaded_functions_tag
00583  : virtual public meta_named_scoped_object_tag
00584 { };
00585 
00586 
00587 #define MIRROR_META_OBJECT_NAME_overloaded_functions(MACRO, DATA) \
00588     MACRO(OverloadedFunctions, DATA)
00589 #define MIRROR_FOR_EACH_MO_BASE_overloaded_functions(MACRO, DATA, SEP_MACRO) \
00590     MACRO(named_scoped_object, DATA)
00591 
00593 
00599 struct meta_locator_tag
00600  : virtual public meta_named_object_tag
00601 { };
00602 
00603 #define MIRROR_META_OBJECT_NAME_locator(MACRO, DATA) \
00604     MACRO(Locator, DATA)
00605 #define MIRROR_FOR_EACH_MO_BASE_locator(MACRO, DATA, SEP_MACRO) \
00606     MACRO(named_object, DATA)
00607 
00608 
00610 
00616 struct meta_traversal_tag
00617  : virtual public meta_named_object_tag
00618 { };
00619 
00620 #define MIRROR_META_OBJECT_NAME_traversal(MACRO, DATA) \
00621     MACRO(Traversal, DATA)
00622 #define MIRROR_FOR_EACH_MO_BASE_traversal(MACRO, DATA, SEP_MACRO) \
00623     MACRO(named_object, DATA)
00624 
00625 
00627 
00633 struct meta_inserter_tag
00634  : virtual public meta_named_object_tag
00635 { };
00636 
00637 #define MIRROR_META_OBJECT_NAME_inserter(MACRO, DATA) \
00638     MACRO(Inserter, DATA)
00639 #define MIRROR_FOR_EACH_MO_BASE_inserter(MACRO, DATA, SEP_MACRO) \
00640     MACRO(named_object, DATA)
00641 
00642 
00644 
00650 struct meta_eraser_tag
00651  : virtual public meta_named_object_tag
00652 { };
00653 
00654 #define MIRROR_META_OBJECT_NAME_eraser(MACRO, DATA) \
00655     MACRO(Eraser, DATA)
00656 #define MIRROR_FOR_EACH_MO_BASE_eraser(MACRO, DATA, SEP_MACRO) \
00657     MACRO(named_object, DATA)
00658 
00659 
00661 
00667 struct meta_container_tag
00668  : virtual public meta_scoped_object_tag
00669 { };
00670 
00671 #define MIRROR_META_OBJECT_NAME_container(MACRO, DATA) \
00672     MACRO(Container, DATA)
00673 #define MIRROR_FOR_EACH_MO_BASE_container(MACRO, DATA, SEP_MACRO) \
00674     MACRO(scoped_object, DATA)
00675 
00676 
00677 
00678 namespace aux {
00679 
00680 template <class T, class Bool>
00681 struct meta_obj_cat;
00682 
00683 template <class T>
00684 struct meta_obj_cat<T, std::true_type>
00685 {
00686     typedef typename T::category type;
00687 };
00688 
00689 template <class T>
00690 struct meta_obj_cat<T, std::false_type>
00691 {
00692     typedef mirror::non_meta_object_tag type;
00693 };
00694 
00695 template <typename T>
00696 std::true_type meta_obj_has_cat(T*, typename T::category* = nullptr);
00697 
00698 std::false_type meta_obj_has_cat(...);
00699 
00700 } // namespace aux
00701 
00703 
00721 template <class T>
00722 struct meta_object_category
00723 {
00724 #ifdef MIRROR_DOCUMENTATION_ONLY
00725 
00726     typedef CategoryTag type;
00727 #else
00728     typedef typename aux::meta_obj_cat<
00729         T,
00730         decltype(aux::meta_obj_has_cat((T*)nullptr))
00731     >::type type;
00732 #endif
00733 };
00734 
00735 namespace aux {
00736 
00737 template <typename TestedCat, typename TargetCat>
00738 struct meta_obj_kind_same
00739  : std::integral_constant<
00740     bool,
00741     std::is_same<TargetCat, TestedCat>::value ||
00742     std::is_base_of<TargetCat, TestedCat>::value
00743 > { };
00744 
00745 template <typename TestedCat, typename ... Categories>
00746 struct meta_obj_kind_hlpr;
00747 
00748 template <typename TestedCat>
00749 struct meta_obj_kind_hlpr<TestedCat>
00750 {
00751     typedef TestedCat type;
00752 
00753 };
00754 
00755 template <
00756     typename Bool,
00757     typename TestedCat,
00758     typename MismatchCat,
00759     typename ... Categories
00760 > struct meta_obj_kind_hlpr2
00761  : meta_obj_kind_hlpr<TestedCat, Categories...>
00762 { };
00763 
00764 template <typename TestedCat, typename MatchCat, typename ... Categories>
00765 struct meta_obj_kind_hlpr2<std::true_type, TestedCat, MatchCat, Categories...>
00766 {
00767     typedef MatchCat type;
00768 };
00769 
00770 template <typename TestedCat, typename Category, typename ... Categories>
00771 struct meta_obj_kind_hlpr<TestedCat, Category, Categories...>
00772  : meta_obj_kind_hlpr2<
00773     typename meta_obj_kind_same<TestedCat, Category>::type,
00774     TestedCat,
00775     Category,
00776     Categories...
00777 > { };
00778 
00779 } // namespace aux
00780 
00782 
00801 template <class T, class ... CategoryTags>
00802 struct meta_object_kind
00803 #ifndef MIRROR_DOCUMENTATION_ONLY
00804  : aux::meta_obj_kind_hlpr<
00805     typename mirror::meta_object_category<T>::type,
00806     CategoryTags...
00807 >
00808 #endif
00809 {
00810 #ifdef MIRROR_DOCUMENTATION_ONLY
00811     typedef CategoryTag type;
00812 #endif
00813 };
00814 
00816 
00822 template <class T>
00823 typename meta_object_category<T>::type
00824 categorize_meta_object(const T& inst)
00825 {
00826     return typename meta_object_category<T>::type();
00827 }
00828 
00829 #define MIRROR_FOR_EACH_META_OBJECT(MACRO, DATA) \
00830     MACRO(object, 0, DATA) \
00831     MACRO(named_object, 1, DATA) \
00832     MACRO(scoped_object, 2, DATA) \
00833     MACRO(named_scoped_object, 3, DATA) \
00834     MACRO(scope, 4, DATA) \
00835     MACRO(unspecified_scope, 5, DATA) \
00836     MACRO(namespace, 6, DATA) \
00837     MACRO(global_scope, 7, DATA) \
00838     MACRO(type, 8, DATA) \
00839     MACRO(templated_type, 9, DATA) \
00840     MACRO(type_template, 10, DATA) \
00841     MACRO(typedef, 11, DATA) \
00842     MACRO(class, 12, DATA) \
00843     MACRO(templated_class, 13, DATA) \
00844     MACRO(class_member, 14, DATA) \
00845     MACRO(enum, 15, DATA) \
00846     MACRO(enum_value, 16, DATA) \
00847     MACRO(inheritance, 17, DATA) \
00848     MACRO(variable, 18, DATA) \
00849     MACRO(plain_variable, 19, DATA) \
00850     MACRO(free_variable, 20, DATA) \
00851     MACRO(plain_free_variable, 21, DATA) \
00852     MACRO(member_variable, 22, DATA) \
00853     MACRO(plain_member_variable, 23, DATA) \
00854     MACRO(parameter, 24, DATA) \
00855     MACRO(function, 25, DATA) \
00856     MACRO(member_function, 26, DATA) \
00857     MACRO(constructor, 27, DATA) \
00858     MACRO(conversion_operator, 28, DATA) \
00859     MACRO(overloaded_functions, 29, DATA) \
00860     MACRO(traversal, 30, DATA) \
00861     MACRO(locator, 31, DATA) \
00862     MACRO(inserter, 32, DATA) \
00863     MACRO(eraser, 33, DATA) \
00864     MACRO(container, 34, DATA)
00865 
00866 #define MIRROR_META_OBJECT_NICE_NAME(OBJECT, MACRO, DATA) \
00867     MIRROR_META_OBJECT_NAME_##OBJECT(MACRO, DATA)
00868 
00869 #define MIRROR_HLPR_MO_NICE_NAME_STR(OBJECT, X) \
00870     #OBJECT
00871 
00872 #define MIRROR_META_OBJECT_NICE_NAME_STR(OBJECT) \
00873     MIRROR_META_OBJECT_NICE_NAME(OBJECT, MIRROR_HLPR_MO_NICE_NAME_STR, _)
00874 
00875 #define MIRROR_FOR_EACH_META_OBJECT_BASE(OBJECT, MACRO, DATA, SEP_MACRO) \
00876     MIRROR_FOR_EACH_MO_BASE_##OBJECT(MACRO, DATA, SEP_MACRO)
00877 
00878 template <typename Expr>
00879 struct eval_meta_object_tag
00880 {
00881     typedef typename eval_meta_object_tag<
00882         typename Expr::type
00883     >::type type;
00884 };
00885 
00886 #define MIRROR_HLPR_IMPLEMENT_EVAL_MO_TAG(OBJECT, I, X) \
00887 template <> \
00888 struct eval_meta_object_tag< mirror::meta_ ## OBJECT ## _tag > \
00889 { \
00890     typedef mirror::meta_ ## OBJECT ## _tag type; \
00891 };
00892 
00893 MIRROR_FOR_EACH_META_OBJECT(MIRROR_HLPR_IMPLEMENT_EVAL_MO_TAG, _)
00894 
00895 #undef MIRROR_HLPR_IMPLEMENT_EVAL_MO_TAG
00896 
00897 MIRROR_NAMESPACE_END
00898 
00899 #endif //include guard
00900 

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.