Ignore:
Timestamp:
Jan 4, 2011, 5:15:14 PM (15 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Factory know has an additional type table and stubs have been refactored.

  • CommonStub.?pp contains basic classes with a int counter inside.
  • Library version is now 2:1:0, API is 1.0.3.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/Factory_impl.hpp

    r746ff1 r724564  
    1616#include <boost/preprocessor/punctuation/comma.hpp>
    1717#include <boost/preprocessor/punctuation/comma_if.hpp>
     18#include <boost/preprocessor/punctuation/paren.hpp>
    1819#include <boost/preprocessor/seq/elem.hpp>
    1920#include <boost/preprocessor/seq/size.hpp>
     
    5253#endif
    5354
    54 /** Functions that allows to print a given seq of elements in the way of
    55  *  std::map from strings to enums.
    56  *
    57  * e.g. let "seq" be defined as
    58  * #define seq (one)(two)(three)(four)
    59  *
    60  * then we use
    61  * #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   ;
    7755
    7856/** Functions that allows to print a given seq of elements in the way of
     
    9270 * EnumMap[three] = test::three;
    9371 * EnumMap[four] = test::four;
    94 
     72 *
    9573 */
    9674#define seqitems_as_enum_key_map(z,n,seq_with_elements, map, keytype, name_space, suffix) \
     
    9977  ] = keytype< name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements) suffix > ();
    10078
     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
    101113
    102114template <>
     
    104116{
    105117  // 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>::)
    107124#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(type_seq)-1 )
    108125#include BOOST_PP_LOCAL_ITERATE()
Note: See TracChangeset for help on using the changeset viewer.