| 1 | /* | 
|---|
| 2 | * Action_impl.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Aug 25, 2010 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | /** These macros define the following functions, necessary but repetitive for | 
|---|
| 9 | * every Action: | 
|---|
| 10 | *  -# Dialog* fillDialog() | 
|---|
| 11 | *  -# action command (e.g. AnalysisMolecularVolume() ) | 
|---|
| 12 | *  -# void getParametersfromValuStorage() | 
|---|
| 13 | *  -# struct Action...Parameters | 
|---|
| 14 | * | 
|---|
| 15 | *  For this, the user has the define the following values, each with | 
|---|
| 16 | *  parenthesis, for the values/parameters the action needs | 
|---|
| 17 | *  -# paramtypes, e.g. (int)(double) | 
|---|
| 18 | *  -# paramtokens, e.g. ("Z")("length") | 
|---|
| 19 | *  -# paramreferences, e.g. (Z)(length) | 
|---|
| 20 | *  and for additional values/parameters to save in the state | 
|---|
| 21 | *  -# statetypes, e.g. (int)(double) | 
|---|
| 22 | *  -# statereferences, e.g. (Z)(length) | 
|---|
| 23 | *  and the name and category of the action | 
|---|
| 24 | *  -# CATEGORY, e.g. Analysis | 
|---|
| 25 | *  -# ACTIONNAME, e.g. MolecularVolume | 
|---|
| 26 | */ | 
|---|
| 27 |  | 
|---|
| 28 | // include config.h | 
|---|
| 29 | #ifdef HAVE_CONFIG_H | 
|---|
| 30 | #include <config.h> | 
|---|
| 31 | #endif | 
|---|
| 32 |  | 
|---|
| 33 | #include "CodePatterns/Chronos.hpp" | 
|---|
| 34 |  | 
|---|
| 35 | #include <boost/preprocessor/cat.hpp> | 
|---|
| 36 | #include <boost/preprocessor/expand.hpp> | 
|---|
| 37 | #include <boost/preprocessor/comparison/equal.hpp> | 
|---|
| 38 | #include <boost/preprocessor/comparison/not_equal.hpp> | 
|---|
| 39 | #include <boost/preprocessor/control/expr_if.hpp> | 
|---|
| 40 | #include <boost/preprocessor/control/if.hpp> | 
|---|
| 41 | #include <boost/preprocessor/debug/assert.hpp> | 
|---|
| 42 | #include <boost/preprocessor/iteration/local.hpp> | 
|---|
| 43 | #include <boost/preprocessor/list/adt.hpp> | 
|---|
| 44 | #include <boost/preprocessor/punctuation/comma_if.hpp> | 
|---|
| 45 | #include <boost/preprocessor/repetition/repeat.hpp> | 
|---|
| 46 | #include <boost/preprocessor/seq/elem.hpp> | 
|---|
| 47 | #include <boost/preprocessor/seq/push_back.hpp> | 
|---|
| 48 | #include <boost/preprocessor/seq/seq.hpp> | 
|---|
| 49 | #include <boost/preprocessor/seq/size.hpp> | 
|---|
| 50 | #include <boost/preprocessor/seq/transform.hpp> | 
|---|
| 51 |  | 
|---|
| 52 | #include "Actions/ActionQueue.hpp" | 
|---|
| 53 | #include "Actions/toCLIString.hpp" | 
|---|
| 54 | #include "Actions/toPythonString.hpp" | 
|---|
| 55 | #include "Parameters/Parameter.hpp" | 
|---|
| 56 |  | 
|---|
| 57 |  | 
|---|
| 58 | // some derived names: if CATEGORY is not given, we don't prefix with it | 
|---|
| 59 | #ifdef CATEGORY | 
|---|
| 60 | #define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action)) | 
|---|
| 61 | #define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME) | 
|---|
| 62 | #define STATE BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, State)) | 
|---|
| 63 | #define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters)) | 
|---|
| 64 | #else | 
|---|
| 65 | #define ACTION BOOST_PP_CAT(ACTIONNAME, Action) | 
|---|
| 66 | #define COMMAND ACTIONNAME | 
|---|
| 67 | #define STATE BOOST_PP_CAT(ACTIONNAME, State) | 
|---|
| 68 | #define PARAMS BOOST_PP_CAT(ACTIONNAME, Parameters) | 
|---|
| 69 | #endif | 
|---|
| 70 | #define INSTANCE BOOST_PP_CAT(this_, BOOST_PP_CAT(ACTIONNAME, _instance)) | 
|---|
| 71 |  | 
|---|
| 72 | // check if no lists given | 
|---|
| 73 | #ifndef paramtypes | 
|---|
| 74 | #define MAXPARAMTYPES 0 | 
|---|
| 75 | #else | 
|---|
| 76 | #define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes) | 
|---|
| 77 | #endif | 
|---|
| 78 | #ifndef statetypes | 
|---|
| 79 | #define MAXSTATETYPES 0 | 
|---|
| 80 | #else | 
|---|
| 81 | #define MAXSTATETYPES BOOST_PP_SEQ_SIZE(statetypes) | 
|---|
| 82 | #endif | 
|---|
| 83 | #ifndef paramdefaults | 
|---|
| 84 | #define MAXPARAMDEFAULTS 0 | 
|---|
| 85 | // this is required for valid_print "else part" | 
|---|
| 86 | #define sequencer(z,n,data) \ | 
|---|
| 87 | BOOST_PP_SEQ_PUSH_BACK( data, NOPARAM_DEFAULT) | 
|---|
| 88 | #define paramdefaults BOOST_PP_REPEAT( MAXPARAMTYPES, sequencer, BOOST_PP_SEQ_NIL ) | 
|---|
| 89 | #else | 
|---|
| 90 | #define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults) | 
|---|
| 91 | #endif | 
|---|
| 92 | #define PARAM_DEFAULT(x) \ | 
|---|
| 93 | (x, BOOST_PP_NIL) | 
|---|
| 94 |  | 
|---|
| 95 | // check user has given name and category | 
|---|
| 96 | #ifndef ACTIONNAME | 
|---|
| 97 | ERROR: No "ACTIONNAME" defined in: __FILE__ | 
|---|
| 98 | #endif | 
|---|
| 99 |  | 
|---|
| 100 | // calculate numbers and check whether all have same size | 
|---|
| 101 | #ifdef paramtokens | 
|---|
| 102 | BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXPARAMTYPES, BOOST_PP_SEQ_SIZE(paramtokens)),\ | 
|---|
| 103 | ERROR: There are not the same number of "paramtokens" and "paramtypes" in: __FILE__ \ | 
|---|
| 104 | ) | 
|---|
| 105 | #endif | 
|---|
| 106 | #ifdef paramreferences | 
|---|
| 107 | BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXPARAMTYPES, BOOST_PP_SEQ_SIZE(paramreferences)),\ | 
|---|
| 108 | ERROR: There are not the same number of "paramtokens" and "paramreferences" in: __FILE__ \ | 
|---|
| 109 | ) | 
|---|
| 110 | #endif | 
|---|
| 111 |  | 
|---|
| 112 | #ifdef statetypes | 
|---|
| 113 | BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXSTATETYPES, BOOST_PP_SEQ_SIZE(statereferences)),\ | 
|---|
| 114 | ERROR: There are not the same number of "statetypes" and "statereferences" in: __FILE__ \ | 
|---|
| 115 | ) | 
|---|
| 116 | #endif | 
|---|
| 117 |  | 
|---|
| 118 | // print a list of type ref followed by a separator, i.e. "int i;" | 
|---|
| 119 | #define initialiser_print(z,n,initialiserlist) \ | 
|---|
| 120 | BOOST_PP_SEQ_ELEM(n, initialiserlist) \ | 
|---|
| 121 | (BOOST_PP_CAT(_, BOOST_PP_SEQ_ELEM(n, initialiserlist))), | 
|---|
| 122 |  | 
|---|
| 123 | // print a list of ref(_ref) followed by a separator, i.e. "id(_id)," | 
|---|
| 124 | #define type_print(z,n,TYPELIST, VARLIST, separator) \ | 
|---|
| 125 | BOOST_PP_SEQ_ELEM(n, TYPELIST) \ | 
|---|
| 126 | BOOST_PP_SEQ_ELEM(n, VARLIST)\ | 
|---|
| 127 | separator | 
|---|
| 128 |  | 
|---|
| 129 | // print a list of type ref followed, i.e. "int i, double position" | 
|---|
| 130 | #define type_list(z,n,TYPELIST,VARLIST) \ | 
|---|
| 131 | BOOST_PP_COMMA_IF(n)\ | 
|---|
| 132 | BOOST_PP_SEQ_ELEM(n, TYPELIST) \ | 
|---|
| 133 | BOOST_PP_SEQ_ELEM(n, VARLIST) | 
|---|
| 134 |  | 
|---|
| 135 | // prints dialog->query calls for paramtypes with tokens | 
|---|
| 136 | #define dialog_print(z,n,unused) \ | 
|---|
| 137 | dialog->query<\ | 
|---|
| 138 | BOOST_PP_SEQ_ELEM(n, paramtypes)\ | 
|---|
| 139 | >( params. \ | 
|---|
| 140 | BOOST_PP_SEQ_ELEM(n, paramreferences)\ | 
|---|
| 141 | ,\ | 
|---|
| 142 | BOOST_PP_SEQ_ELEM(n, paramtokens)\ | 
|---|
| 143 | , Traits.getDescription()\ | 
|---|
| 144 | ); | 
|---|
| 145 |  | 
|---|
| 146 | // prints command line call for this Action for paramtypes with tokens | 
|---|
| 147 | #define outputAsCLI_print(z,n,output) \ | 
|---|
| 148 | output << \ | 
|---|
| 149 | BOOST_PP_IF(n, " --", "--") \ | 
|---|
| 150 | << \ | 
|---|
| 151 | BOOST_PP_SEQ_ELEM(n, paramtokens) \ | 
|---|
| 152 | << " " << toCLIString(params. \ | 
|---|
| 153 | BOOST_PP_SEQ_ELEM(n, paramreferences) \ | 
|---|
| 154 | .get()); | 
|---|
| 155 |  | 
|---|
| 156 | // prints if statement to check two strings (paramtokens[n] vs. TOKEN) | 
|---|
| 157 | #define checkpresenttoken_print(z, n, TOKEN, booltoken) \ | 
|---|
| 158 | if ( std::string(\ | 
|---|
| 159 | BOOST_PP_SEQ_ELEM(n, paramtokens) )\ | 
|---|
| 160 | == getName()) \ | 
|---|
| 161 | booltoken = false; | 
|---|
| 162 |  | 
|---|
| 163 | // prints command line call for this Action for paramtypes with tokens | 
|---|
| 164 | #define outputAsPython_print(z,n,output) \ | 
|---|
| 165 | output << \ | 
|---|
| 166 | BOOST_PP_IF(n, ", ", "") \ | 
|---|
| 167 | << "\"" << toPythonString(params. \ | 
|---|
| 168 | BOOST_PP_SEQ_ELEM(n, paramreferences) \ | 
|---|
| 169 | .get()) \ | 
|---|
| 170 | << "\""; | 
|---|
| 171 |  | 
|---|
| 172 | // print an initialiser list, i.e. "var( token, valid (,default) )(,)" | 
|---|
| 173 | #define valid_print(z,n,TOKENLIST, VARLIST, VALIDLIST, DEFAULTLIST) \ | 
|---|
| 174 | BOOST_PP_COMMA_IF(n) \ | 
|---|
| 175 | BOOST_PP_SEQ_ELEM(n, VARLIST) \ | 
|---|
| 176 | ( \ | 
|---|
| 177 | BOOST_PP_SEQ_ELEM(n, TOKENLIST) \ | 
|---|
| 178 | , \ | 
|---|
| 179 | BOOST_PP_SEQ_ELEM(n, VALIDLIST) \ | 
|---|
| 180 | BOOST_PP_COMMA_IF( BOOST_PP_NOT( BOOST_PP_LIST_IS_NIL( BOOST_PP_SEQ_ELEM(n, DEFAULTLIST) ) ) ) \ | 
|---|
| 181 | BOOST_PP_EXPR_IF( \ | 
|---|
| 182 | BOOST_PP_NOT( BOOST_PP_LIST_IS_NIL( BOOST_PP_SEQ_ELEM(n, DEFAULTLIST) ) ), \ | 
|---|
| 183 | BOOST_PP_LIST_FIRST( BOOST_PP_SEQ_ELEM(n, DEFAULTLIST) )) \ | 
|---|
| 184 | ) | 
|---|
| 185 |  | 
|---|
| 186 | // print an initialiser list, i.e. "var( valid . var )(,)" | 
|---|
| 187 | #define validcopy_print(z,n,TOKENLIST, VARLIST, VALID) \ | 
|---|
| 188 | BOOST_PP_COMMA_IF(n) \ | 
|---|
| 189 | BOOST_PP_SEQ_ELEM(n, VARLIST) \ | 
|---|
| 190 | ( \ | 
|---|
| 191 | VALID . \ | 
|---|
| 192 | BOOST_PP_SEQ_ELEM(n, VARLIST) \ | 
|---|
| 193 | ) | 
|---|
| 194 |  | 
|---|
| 195 | // prints set/queryCurrentValue (command) for paramreferences and paramtokens | 
|---|
| 196 | #define value_print(z, n, container, prefix) \ | 
|---|
| 197 | prefix \ | 
|---|
| 198 | BOOST_PP_SEQ_ELEM(n, container)\ | 
|---|
| 199 | .set(\ | 
|---|
| 200 | BOOST_PP_SEQ_ELEM(n, container)\ | 
|---|
| 201 | ); | 
|---|
| 202 |  | 
|---|
| 203 | // prints set/queryCurrentValue (command) for paramreferences and paramtokens | 
|---|
| 204 | #define valuetype_print(z,n,container, types, prefix) \ | 
|---|
| 205 | prefix \ | 
|---|
| 206 | BOOST_PP_SEQ_ELEM(n, container) \ | 
|---|
| 207 | .setAsString( \ | 
|---|
| 208 | BOOST_PP_SEQ_ELEM(n, container) \ | 
|---|
| 209 | ); | 
|---|
| 210 |  | 
|---|
| 211 | #define stringtype std::string | 
|---|
| 212 |  | 
|---|
| 213 | #define type2string(s, data, elem) \ | 
|---|
| 214 | stringtype | 
|---|
| 215 |  | 
|---|
| 216 |  | 
|---|
| 217 | #include "Actions/ActionRegistry.hpp" | 
|---|
| 218 | //#include "Actions/ActionTraits.hpp" | 
|---|
| 219 | #include "UIElements/Dialog.hpp" | 
|---|
| 220 |  | 
|---|
| 221 | #ifdef paramtokens | 
|---|
| 222 | #define statenecessary 1 | 
|---|
| 223 | #endif | 
|---|
| 224 | #ifndef statetokens | 
|---|
| 225 | #define statenecessary 1 | 
|---|
| 226 | #endif | 
|---|
| 227 |  | 
|---|
| 228 | namespace MoleCuilder { | 
|---|
| 229 |  | 
|---|
| 230 | // =========== memento to remember the state when undoing =========== | 
|---|
| 231 | #ifdef statenecessary | 
|---|
| 232 | class STATE : public ActionState { | 
|---|
| 233 | public: | 
|---|
| 234 | STATE( | 
|---|
| 235 | #if defined statetypes && defined statereferences // if we have states, we have to add "_" before each reference and add the params as the last one | 
|---|
| 236 | #define OP(s,data,elem) BOOST_PP_CAT(data, elem)  // OP to add "_" | 
|---|
| 237 | #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, BOOST_PP_SEQ_PUSH_BACK(statetypes, const ACTION::PARAMS &), BOOST_PP_SEQ_TRANSFORM(OP, _, BOOST_PP_SEQ_PUSH_BACK(statereferences, params))) | 
|---|
| 238 | #else /// if not, params is only list | 
|---|
| 239 | #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, (const ACTION::PARAMS &), (_params)) | 
|---|
| 240 | #endif | 
|---|
| 241 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXSTATETYPES) | 
|---|
| 242 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 243 | ) : | 
|---|
| 244 | #if defined statetypes && defined statereferences // do we have states at all? | 
|---|
| 245 | BOOST_PP_REPEAT(MAXSTATETYPES, initialiser_print, statereferences) | 
|---|
| 246 | #endif | 
|---|
| 247 | params(_params) | 
|---|
| 248 | {} | 
|---|
| 249 |  | 
|---|
| 250 | #if defined statetypes && defined statereferences // do we have parameters at all? | 
|---|
| 251 | #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, statetypes, statereferences, ;) | 
|---|
| 252 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXSTATETYPES-1) | 
|---|
| 253 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 254 | #endif | 
|---|
| 255 | ACTION::PARAMS params; | 
|---|
| 256 | }; | 
|---|
| 257 | #endif /* statenecessary */ | 
|---|
| 258 |  | 
|---|
| 259 | // (const) prototype to be placed into the ActionRegistry (must be deleted by registry itself) | 
|---|
| 260 | //const ACTION INSTANCE; | 
|---|
| 261 | //boost::shared_ptr< ACTION > INSTANCE( new ACTION() ); | 
|---|
| 262 |  | 
|---|
| 263 | // =========== constructor =========== | 
|---|
| 264 | ACTION::ACTION () : | 
|---|
| 265 | MakroAction(ActionTraits< ACTION >(), actions), | 
|---|
| 266 | actions(prototype_actions) | 
|---|
| 267 | {} | 
|---|
| 268 |  | 
|---|
| 269 | // =========== destructor =========== | 
|---|
| 270 | ACTION::~ACTION () | 
|---|
| 271 | { | 
|---|
| 272 | //std::cout << "Action ACTION is being destroyed." << std::endl; | 
|---|
| 273 | } | 
|---|
| 274 |  | 
|---|
| 275 | // =========== parameter constructor =========== | 
|---|
| 276 | ACTION::PARAMS::PARAMS() | 
|---|
| 277 | #if defined paramtokens && defined paramreferences && defined paramvalids | 
|---|
| 278 | : | 
|---|
| 279 | #define BOOST_PP_LOCAL_MACRO(n) valid_print(~, n, paramtokens, paramreferences, paramvalids, paramdefaults) | 
|---|
| 280 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 281 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 282 | #endif | 
|---|
| 283 | {} | 
|---|
| 284 |  | 
|---|
| 285 | ACTION::PARAMS::PARAMS(const PARAMS &p) | 
|---|
| 286 | #if defined paramtokens && defined paramreferences | 
|---|
| 287 | : | 
|---|
| 288 | #define BOOST_PP_LOCAL_MACRO(n) validcopy_print(~, n, paramtokens, paramreferences, p) | 
|---|
| 289 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 290 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 291 | #endif | 
|---|
| 292 | {} | 
|---|
| 293 |  | 
|---|
| 294 | // =========== clone Action =========== | 
|---|
| 295 | Action* ACTION::clone(enum QueryOptions flag) const | 
|---|
| 296 | { | 
|---|
| 297 | return new ACTION(); | 
|---|
| 298 | } | 
|---|
| 299 |  | 
|---|
| 300 | // =========== fill a dialog =========== | 
|---|
| 301 | Dialog* ACTION::fillOwnDialog(Dialog *dialog) { | 
|---|
| 302 | ASSERT(dialog,"No Dialog given when filling actionname's dialog"); | 
|---|
| 303 | #if BOOST_PP_EQUAL(MAXPARAMTYPES,0) | 
|---|
| 304 | dialog->queryEmpty(TOKEN, Traits.getDescription()); | 
|---|
| 305 | #else | 
|---|
| 306 | #define BOOST_PP_LOCAL_MACRO(n) dialog_print(~, n, ~) | 
|---|
| 307 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 308 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 309 | #endif | 
|---|
| 310 | return dialog; | 
|---|
| 311 | }; | 
|---|
| 312 |  | 
|---|
| 313 | // =========== output as CLI =========== | 
|---|
| 314 | void ACTION::outputAsCLI(std::ostream &ost) const { | 
|---|
| 315 | // check whether TOKEN is also an option | 
|---|
| 316 | // is a bit ugly as preprocessor cannot compare strings | 
|---|
| 317 | bool status = true; | 
|---|
| 318 | #if defined paramtokens && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) | 
|---|
| 319 | #define BOOST_PP_LOCAL_MACRO(n) checkpresenttoken_print(~, n, TOKEN, status) | 
|---|
| 320 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 321 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 322 | #endif | 
|---|
| 323 | if (status) { | 
|---|
| 324 | ost << "--" << TOKEN; | 
|---|
| 325 | #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) | 
|---|
| 326 | ost << " "; | 
|---|
| 327 | #endif | 
|---|
| 328 | } | 
|---|
| 329 | // then print option along with each argument if set | 
|---|
| 330 | #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) | 
|---|
| 331 | #define BOOST_PP_LOCAL_MACRO(n) outputAsCLI_print(~, n, ost) | 
|---|
| 332 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 333 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 334 | #endif | 
|---|
| 335 | } | 
|---|
| 336 |  | 
|---|
| 337 | // =========== output as PYTHTON =========== | 
|---|
| 338 | void ACTION::outputAsPython(std::ostream &ost, const std::string &prefix) const { | 
|---|
| 339 | // print prefix and action command | 
|---|
| 340 | ost << prefix << "." << BOOST_PP_STRINGIZE( COMMAND ) << "("; | 
|---|
| 341 | // then print option along with each argument if set | 
|---|
| 342 | #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) | 
|---|
| 343 | #define BOOST_PP_LOCAL_MACRO(n) outputAsPython_print(~, n, ost) | 
|---|
| 344 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 345 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 346 | #endif | 
|---|
| 347 | ost << ")" << std::endl; | 
|---|
| 348 | } | 
|---|
| 349 |  | 
|---|
| 350 | // =========== time the action =========== | 
|---|
| 351 | // we need this here to have the correct function name | 
|---|
| 352 | void ACTION::startTimer() const { Chronos::getInstance().startTiming( std::string( TOKEN ) ); } | 
|---|
| 353 | void ACTION::endTimer() const { Chronos::getInstance().endTiming( std::string( TOKEN ) ); } | 
|---|
| 354 |  | 
|---|
| 355 | // =========== command for calling action directly =========== | 
|---|
| 356 | void COMMAND( | 
|---|
| 357 | #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) | 
|---|
| 358 | #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences) | 
|---|
| 359 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 360 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 361 | #endif | 
|---|
| 362 | ) | 
|---|
| 363 | { | 
|---|
| 364 | ACTION * const ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN ).clone()); | 
|---|
| 365 | //ACTION::PARAMS params; | 
|---|
| 366 | #if defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) | 
|---|
| 367 | #define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, paramreferences, ToCall->params.) | 
|---|
| 368 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 369 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 370 | #endif | 
|---|
| 371 | Action::insertAction( ToCall, Action::NonInteractive); | 
|---|
| 372 | }; | 
|---|
| 373 |  | 
|---|
| 374 | void BOOST_PP_CAT( COMMAND, _stringargs)( | 
|---|
| 375 | #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) | 
|---|
| 376 | #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, BOOST_PP_SEQ_TRANSFORM( type2string, , paramtypes), paramreferences) | 
|---|
| 377 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 378 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 379 | #endif | 
|---|
| 380 | ) { | 
|---|
| 381 | ACTION * const ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN ).clone()); | 
|---|
| 382 | //ACTION::PARAMS params; | 
|---|
| 383 | #if defined paramtypes && defined paramtypes && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) | 
|---|
| 384 | #define BOOST_PP_LOCAL_MACRO(n) valuetype_print(~, n, paramreferences, paramtypes, ToCall->params. ) | 
|---|
| 385 | #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1) | 
|---|
| 386 | #include BOOST_PP_LOCAL_ITERATE() | 
|---|
| 387 | #endif | 
|---|
| 388 | Action::insertAction( ToCall, Action::NonInteractive); | 
|---|
| 389 | }; | 
|---|
| 390 |  | 
|---|
| 391 | } | 
|---|
| 392 |  | 
|---|
| 393 | // free up defines | 
|---|
| 394 | #undef paramvalids | 
|---|
| 395 | #undef paramtypes | 
|---|
| 396 | #undef paramtokens | 
|---|
| 397 | #undef paramreferences | 
|---|
| 398 | #undef paramdescriptions | 
|---|
| 399 | #undef paramdefaults | 
|---|
| 400 | #undef MAXPARAMTYPES | 
|---|
| 401 | #undef MAXPARAMDEFAULTS | 
|---|
| 402 | #undef statetypes | 
|---|
| 403 | #undef statereferences | 
|---|
| 404 | #undef MAXSTATETYPES | 
|---|
| 405 | #undef PARAM_DEFAULT | 
|---|
| 406 |  | 
|---|
| 407 | #undef type2string | 
|---|
| 408 | #undef stringtype | 
|---|
| 409 | #undef initialiser_print | 
|---|
| 410 | #undef type_print | 
|---|
| 411 | #undef type_list | 
|---|
| 412 | #undef dialog_print | 
|---|
| 413 | #undef sequencer | 
|---|
| 414 | #undef valid_print | 
|---|
| 415 | #undef validcopy_print | 
|---|
| 416 | #undef value_print | 
|---|
| 417 | #undef valuetype_print | 
|---|
| 418 |  | 
|---|
| 419 | #undef ACTION | 
|---|
| 420 | #undef COMMAND | 
|---|
| 421 | #undef PARAMS | 
|---|
| 422 | #undef STATE | 
|---|
| 423 | #undef INSTANCE | 
|---|
| 424 |  | 
|---|
| 425 | #undef ACTIONNAME | 
|---|
| 426 | #undef CATEGORY | 
|---|
| 427 | #undef TOKEN | 
|---|