Changeset 724564 for src/Patterns/Factory_impl.hpp
- Timestamp:
- Jan 4, 2011, 5:15:14 PM (15 years ago)
- Children:
- 1afcbe
- Parents:
- 746ff1
- git-author:
- Frederik Heber <heber@…> (01/04/11 15:57:33)
- git-committer:
- Frederik Heber <heber@…> (01/04/11 17:15:14)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/Factory_impl.hpp
r746ff1 r724564 16 16 #include <boost/preprocessor/punctuation/comma.hpp> 17 17 #include <boost/preprocessor/punctuation/comma_if.hpp> 18 #include <boost/preprocessor/punctuation/paren.hpp> 18 19 #include <boost/preprocessor/seq/elem.hpp> 19 20 #include <boost/preprocessor/seq/size.hpp> … … 52 53 #endif 53 54 54 /** Functions that allows to print a given seq of elements in the way of55 * std::map from strings to enums.56 *57 * e.g. let "seq" be defined as58 * #define seq (one)(two)(three)(four)59 *60 * then we use61 * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_string_enum_map(seqsize, n, seq, EnumMap, name_space)62 * #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_SEQ_SIZE(seq)-1 )63 * #include BOOST_PP_LOCAL_ITERATE()64 *65 * which expands by the preprocessor to:66 * EnumMap["one"] = test:: one;67 * EnumMap["two"] = test:: two;68 * EnumMap["three"] = test:: three;69 * EnumMap["four"] = test:: four;70 71 */72 #define seqitems_as_string_enum_map(z,n,seq_with_elements, map, name_space) \73 map [BOOST_PP_STRINGIZE( \74 BOOST_PP_SEQ_ELEM(n, seq_with_elements) \75 )] = name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements) \76 ;77 55 78 56 /** Functions that allows to print a given seq of elements in the way of … … 92 70 * EnumMap[three] = test::three; 93 71 * EnumMap[four] = test::four; 94 72 * 95 73 */ 96 74 #define seqitems_as_enum_key_map(z,n,seq_with_elements, map, keytype, name_space, suffix) \ … … 99 77 ] = keytype< name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements) suffix > (); 100 78 79 /** Functions that allows to print a given seq of elements in the way of 80 * std::map from strings to enums. 81 * 82 * e.g. let "seq" be defined as 83 * #define seq (one)(two)(three)(four) 84 * 85 * then we use 86 * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_value_map(seqsize, n, seq, EnumMap, typid BOOST_PP_LPAREN() super:: , BOOST_PP_RPAREN().name() , test::) 87 * #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_SEQ_SIZE(seq)-1 ) 88 * #include BOOST_PP_LOCAL_ITERATE() 89 * 90 * which expands by the preprocessor to: 91 * EnumMap[ typeid ( super:: one ) .name() ] = test::one; 92 * EnumMap[ typeid ( super:: two ) .name() ] = test::two; 93 * EnumMap[ typeid ( super:: three ) .name() ] = test::three; 94 * EnumMap[ typeid ( super:: four ) .name() ] = test::four; 95 * 96 * or we use 97 * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_value_map(seqsize, n, seq, EnumMap, BOOST_PP_STRINGIZE BOOST_PP_LPAREN() , BOOST_PP_RPAREN() , test::) 98 * #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_SEQ_SIZE(seq)-1 ) 99 * #include BOOST_PP_LOCAL_ITERATE() 100 * 101 * which expands by the preprocessor to: 102 * EnumMap[ "one" ] = test:: one; 103 * EnumMap[ "two" ] = test:: two; 104 * EnumMap[ "three" ] = test:: three; 105 * EnumMap[ "four" ] = test:: four; 106 */ 107 #define seqitems_as_enum_value_map(z,n,seq_with_elements, map, type_specifier, type_suffix, enum_name_space) \ 108 map [ type_specifier \ 109 BOOST_PP_SEQ_ELEM(n, seq_with_elements) \ 110 type_suffix \ 111 ] = enum_name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements); 112 101 113 102 114 template <> … … 104 116 { 105 117 // insert all known (enum, string) keys 106 #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_string_enum_map(~, n, type_seq, enums, FactoryTypeList<Abstract_Interface_Class>::) 118 #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_value_map(~, n, type_seq, enums, BOOST_PP_STRINGIZE BOOST_PP_LPAREN() , BOOST_PP_RPAREN() , FactoryTypeList<Abstract_Interface_Class>::) 119 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_SEQ_SIZE(type_seq)-1 ) 120 #include BOOST_PP_LOCAL_ITERATE() 121 122 // insert all known (type, enum) keys 123 #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_value_map(~, n, type_seq, types, typeid BOOST_PP_LPAREN() type_name_space , type_name_space_suffix BOOST_PP_RPAREN() .name(), FactoryTypeList<Abstract_Interface_Class>::) 107 124 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_SEQ_SIZE(type_seq)-1 ) 108 125 #include BOOST_PP_LOCAL_ITERATE()
Note:
See TracChangeset
for help on using the changeset viewer.