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