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