- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/Action_impl_header.hpp
r3139b2 r6ba9ba 14 14 #include <boost/preprocessor/comparison/equal.hpp> 15 15 #include <boost/preprocessor/comparison/not_equal.hpp> 16 #include <boost/preprocessor/control/expr_if.hpp> 16 17 #include <boost/preprocessor/control/if.hpp> 17 18 #include <boost/preprocessor/debug/assert.hpp> 18 19 #include <boost/preprocessor/iteration/local.hpp> 20 #include <boost/preprocessor/list/adt.hpp> 19 21 #include <boost/preprocessor/punctuation/comma_if.hpp> 22 #include <boost/preprocessor/punctuation/paren.hpp> 20 23 #include <boost/preprocessor/repetition/repeat.hpp> 21 24 #include <boost/preprocessor/seq/elem.hpp> … … 31 34 #include "Actions/ValueStorage.hpp" 32 35 36 #include "Parameters/Parameter.hpp" 37 33 38 // some derived names: if CATEGORY is not given, we don't prefix with it 34 39 #ifdef CATEGORY … … 47 52 #define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes) 48 53 #endif 54 #ifndef paramdefaults 55 #define MAXPARAMDEFAULTS 0 56 // this is required for valid_print "else part" 57 #define sequencer(z,n,data) \ 58 BOOST_PP_SEQ_PUSH_BACK( data, NOPARAM_DEFAULT) 59 #define paramdefaults BOOST_PP_REPEAT( MAXPARAMTYPES, sequencer, BOOST_PP_SEQ_NIL ) 60 #else 61 #define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults) 62 #endif 63 #define PARAM_DEFAULT(x) \ 64 (x, BOOST_PP_NIL) 49 65 50 66 // check user has given name and category … … 77 93 #endif 78 94 79 // check if paramdefaults is given, otherwise fill list with NO DEFAULT95 // check if paramdefaults is given, otherwise fill list with NOPARAM_DEFAULT 80 96 // this does not work: paramdefaults has to be completely defined before 81 97 // being used within option_print (used as an array there and not as 82 98 // some function call still to be expanded) 83 //#define paramdefaults (NO DEFAULT)99 //#define paramdefaults (NOPARAM_DEFAULT) 84 100 //#define tempvalue(z,n,value) 85 // BOOST_PP_CAT(value,(NO DEFAULT))101 // BOOST_PP_CAT(value,(NOPARAM_DEFAULT)) 86 102 //BOOST_PP_REPEAT(tempvalue, MAXPARAMTYPES, paramdefaults) 87 103 //#undef tempvalue … … 95 111 #endif 96 112 97 // print a list of type ref followed by a separator, i.e. " inti;"113 // print a list of type ref followed by a separator, i.e. "Parameter<int> i;" 98 114 #define type_print(z,n,TYPELIST, VARLIST, separator) \ 115 Parameter < \ 99 116 BOOST_PP_SEQ_ELEM(n, TYPELIST) \ 100 BOOST_PP_SEQ_ELEM(n, VARLIST)\ 117 > \ 118 BOOST_PP_SEQ_ELEM(n, VARLIST) \ 101 119 separator 102 120 … … 108 126 109 127 // prints Options.insert 110 #ifdef paramdefaults111 128 #define option_print(z,n,unused, unused2) \ 112 129 tester = Options. insert (\ … … 116 133 BOOST_PP_SEQ_ELEM(n, paramtokens), \ 117 134 &typeid( BOOST_PP_SEQ_ELEM(n, paramtypes) ), \ 118 BOOST_PP_SEQ_ELEM(n, paramdescriptions), \ 119 std::string( BOOST_PP_SEQ_ELEM(n, paramdefaults) ) )\ 135 BOOST_PP_SEQ_ELEM(n, paramdescriptions) \ 136 BOOST_PP_COMMA_IF( BOOST_PP_NOT( BOOST_PP_LIST_IS_NIL( BOOST_PP_SEQ_ELEM(n, paramdefaults) ) ) ) \ 137 BOOST_PP_EXPR_IF( \ 138 BOOST_PP_NOT( BOOST_PP_LIST_IS_NIL( BOOST_PP_SEQ_ELEM(n, paramdefaults) ) ), \ 139 toString BOOST_PP_LPAREN() \ 140 BOOST_PP_LIST_FIRST( BOOST_PP_SEQ_ELEM(n, paramdefaults) )) \ 141 BOOST_PP_RPAREN() \ 142 )\ 120 143 )\ 121 144 ); \ 122 145 ASSERT(tester.second, "ActionTrait<ACTION>::ActionTrait<ACTION>() option token present twice!"); 123 #else124 #define option_print(z,n,unused, unused2) \125 tester = Options. insert (\126 std::pair< std::string, OptionTrait *> ( \127 BOOST_PP_SEQ_ELEM(n, paramtokens), \128 new OptionTrait(\129 BOOST_PP_SEQ_ELEM(n, paramtokens), \130 &typeid( BOOST_PP_SEQ_ELEM(n, paramtypes) ), \131 BOOST_PP_SEQ_ELEM(n, paramdescriptions), \132 NODEFAULT )\133 )\134 ); \135 ASSERT(tester.second, "ActionTrait<ACTION>::ActionTrait<ACTION>() option token present twice!");136 #endif137 146 138 147 namespace MoleCuilder { … … 205 214 206 215 struct PARAMS : ActionParameters { 216 //!> constructor for class PARAMS, setting valid ranges 217 PARAMS(); 218 //!> copy constructor for class PARAMS, setting valid ranges 219 PARAMS(const PARAMS &p); 207 220 #if defined paramtypes && defined paramreferences 208 221 #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, paramtypes, paramreferences, ;) … … 219 232 220 233 private: 221 virtual void getParametersfromValueStorage();234 //virtual void getParametersfromValueStorage(); 222 235 virtual Action::state_ptr performCall(); 223 236 virtual Action::state_ptr performUndo(Action::state_ptr); … … 227 240 } 228 241 242 #undef paramvalids 229 243 #undef paramtypes 230 244 #undef paramtokens … … 233 247 #undef paramdefaults 234 248 #undef MAXPARAMTYPES 249 #undef MAXPARAMDEFAULTS 235 250 #undef statetypes 236 251 #undef statereferences 237 252 #undef MAXSTATETYPES 253 #undef PARAM_DEFAULT 238 254 239 255 #undef option_print 256 #undef sequencer 240 257 #undef type_print 241 258 #undef type_list
Note:
See TracChangeset
for help on using the changeset viewer.