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