[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"
|
---|
[992839] | 56 | #include "Actions/toPythonString.hpp"
|
---|
[f10b0c] | 57 | #include "Parameters/Parameter.hpp"
|
---|
| 58 |
|
---|
[649aaa] | 59 |
|
---|
[e4afb4] | 60 | // some derived names: if CATEGORY is not given, we don't prefix with it
|
---|
| 61 | #ifdef CATEGORY
|
---|
[9ee38b] | 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))
|
---|
[e4afb4] | 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
|
---|
[2a6a2c] | 72 | #define INSTANCE BOOST_PP_CAT(this_, BOOST_PP_CAT(ACTIONNAME, _instance))
|
---|
[9ee38b] | 73 |
|
---|
| 74 | // check if no lists given
|
---|
[b4fa106] | 75 | #ifndef paramtypes
|
---|
| 76 | #define MAXPARAMTYPES 0
|
---|
[9ee38b] | 77 | #else
|
---|
[b4fa106] | 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)
|
---|
[9ee38b] | 84 | #endif
|
---|
[6ba9ba] | 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)
|
---|
[9ee38b] | 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
|
---|
[b4fa106] | 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__ \
|
---|
[9ee38b] | 106 | )
|
---|
| 107 | #endif
|
---|
[b4fa106] | 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__ \
|
---|
[9ee38b] | 117 | )
|
---|
| 118 | #endif
|
---|
| 119 |
|
---|
| 120 | // print a list of type ref followed by a separator, i.e. "int i;"
|
---|
[b4fa106] | 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)\
|
---|
[9ee38b] | 129 | separator
|
---|
| 130 |
|
---|
| 131 | // print a list of type ref followed, i.e. "int i, double position"
|
---|
[b4fa106] | 132 | #define type_list(z,n,TYPELIST,VARLIST) \
|
---|
[9ee38b] | 133 | BOOST_PP_COMMA_IF(n)\
|
---|
[b4fa106] | 134 | BOOST_PP_SEQ_ELEM(n, TYPELIST) \
|
---|
| 135 | BOOST_PP_SEQ_ELEM(n, VARLIST)
|
---|
[9ee38b] | 136 |
|
---|
[b4fa106] | 137 | // prints dialog->query calls for paramtypes with tokens
|
---|
[9ee38b] | 138 | #define dialog_print(z,n,unused) \
|
---|
| 139 | dialog->query<\
|
---|
[b4fa106] | 140 | BOOST_PP_SEQ_ELEM(n, paramtypes)\
|
---|
[f10b0c] | 141 | >( params. \
|
---|
| 142 | BOOST_PP_SEQ_ELEM(n, paramreferences)\
|
---|
| 143 | ,\
|
---|
[b4fa106] | 144 | BOOST_PP_SEQ_ELEM(n, paramtokens)\
|
---|
[e4afb4] | 145 | , Traits.getDescription()\
|
---|
| 146 | );
|
---|
[9ee38b] | 147 |
|
---|
[46b181] | 148 | // prints command line call for this Action for paramtypes with tokens
|
---|
| 149 | #define outputAsCLI_print(z,n,output) \
|
---|
| 150 | output << \
|
---|
[477012] | 151 | BOOST_PP_IF(n, " --", "--") \
|
---|
| 152 | << \
|
---|
[46b181] | 153 | BOOST_PP_SEQ_ELEM(n, paramtokens) \
|
---|
[f6ff216] | 154 | << " " << toCLIString(params. \
|
---|
[9b56f34] | 155 | BOOST_PP_SEQ_ELEM(n, paramreferences) \
|
---|
[f6ff216] | 156 | .get());
|
---|
[46b181] | 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 |
|
---|
[477012] | 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, ", ", "") \
|
---|
[992839] | 169 | << "\"" << toPythonString(params. \
|
---|
[477012] | 170 | BOOST_PP_SEQ_ELEM(n, paramreferences) \
|
---|
| 171 | .get()) \
|
---|
| 172 | << "\"";
|
---|
| 173 |
|
---|
[6ba9ba] | 174 | // print an initialiser list, i.e. "var( token, valid (,default) )(,)"
|
---|
| 175 | #define valid_print(z,n,TOKENLIST, VARLIST, VALIDLIST, DEFAULTLIST) \
|
---|
[649aaa] | 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) \
|
---|
[6ba9ba] | 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) )) \
|
---|
[649aaa] | 186 | )
|
---|
| 187 |
|
---|
[6ba9ba] | 188 | // print an initialiser list, i.e. "var( valid . var )(,)"
|
---|
[649aaa] | 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 |
|
---|
[9ee38b] | 197 | // prints set/queryCurrentValue (command) for paramreferences and paramtokens
|
---|
[f10b0c] | 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)\
|
---|
[9ee38b] | 203 | );
|
---|
| 204 |
|
---|
[88ba1f] | 205 | // prints set/queryCurrentValue (command) for paramreferences and paramtokens
|
---|
[f10b0c] | 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) \
|
---|
[88ba1f] | 211 | );
|
---|
| 212 |
|
---|
| 213 | #define stringtype std::string
|
---|
| 214 |
|
---|
| 215 | #define type2string(s, data, elem) \
|
---|
| 216 | stringtype
|
---|
| 217 |
|
---|
| 218 |
|
---|
[3139b2] | 219 | //#include "Actions/ActionTraits.hpp"
|
---|
[0b2ce9] | 220 | #include "UIElements/Dialog.hpp"
|
---|
| 221 |
|
---|
[e4afb4] | 222 | #ifdef paramtokens
|
---|
| 223 | #define statenecessary 1
|
---|
| 224 | #endif
|
---|
| 225 | #ifndef statetokens
|
---|
| 226 | #define statenecessary 1
|
---|
| 227 | #endif
|
---|
[9ee38b] | 228 |
|
---|
[ce7fdc] | 229 | namespace MoleCuilder {
|
---|
| 230 |
|
---|
[b4fa106] | 231 | // =========== memento to remember the state when undoing ===========
|
---|
[e4afb4] | 232 | #ifdef statenecessary
|
---|
[b4fa106] | 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 | {}
|
---|
[0b2ce9] | 250 |
|
---|
[b4fa106] | 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 | };
|
---|
[e4afb4] | 258 | #endif /* statenecessary */
|
---|
[0b2ce9] | 259 |
|
---|
[2a6a2c] | 260 | // (const) prototype to be placed into the ActionRegistry (must be deleted by registry itself)
|
---|
[83e90c] | 261 | //const ACTION INSTANCE;
|
---|
| 262 | //boost::shared_ptr< ACTION > INSTANCE( new ACTION() );
|
---|
[2a6a2c] | 263 |
|
---|
[b4fa106] | 264 | // =========== constructor ===========
|
---|
[0b2ce9] | 265 | ACTION::ACTION () :
|
---|
[c09f94] | 266 | #if defined BASECLASS
|
---|
| 267 | BASECLASS(ActionTraits< ACTION >())
|
---|
| 268 | #else
|
---|
[126867] | 269 | Action(ActionTraits< ACTION >())
|
---|
[c09f94] | 270 | #endif
|
---|
[0b2ce9] | 271 | {}
|
---|
| 272 |
|
---|
[b4fa106] | 273 | // =========== destructor ===========
|
---|
[0b2ce9] | 274 | ACTION::~ACTION ()
|
---|
[e4afb4] | 275 | {
|
---|
| 276 | //std::cout << "Action ACTION is being destroyed." << std::endl;
|
---|
| 277 | }
|
---|
[0b2ce9] | 278 |
|
---|
[649aaa] | 279 | // =========== parameter constructor ===========
|
---|
| 280 | ACTION::PARAMS::PARAMS()
|
---|
| 281 | #if defined paramtokens && defined paramreferences && defined paramvalids
|
---|
| 282 | :
|
---|
[6ba9ba] | 283 | #define BOOST_PP_LOCAL_MACRO(n) valid_print(~, n, paramtokens, paramreferences, paramvalids, paramdefaults)
|
---|
[649aaa] | 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 |
|
---|
[af5384] | 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 |
|
---|
[b4fa106] | 307 | // =========== fill a dialog ===========
|
---|
[0b2ce9] | 308 | Dialog* ACTION::fillDialog(Dialog *dialog) {
|
---|
| 309 | ASSERT(dialog,"No Dialog given when filling actionname's dialog");
|
---|
[b4fa106] | 310 | #if BOOST_PP_EQUAL(MAXPARAMTYPES,0)
|
---|
[e4afb4] | 311 | dialog->queryEmpty(TOKEN, Traits.getDescription());
|
---|
[0b2ce9] | 312 | #else
|
---|
| 313 | #define BOOST_PP_LOCAL_MACRO(n) dialog_print(~, n, ~)
|
---|
[b4fa106] | 314 | #define BOOST_PP_LOCAL_LIMITS (0, MAXPARAMTYPES-1)
|
---|
[0b2ce9] | 315 | #include BOOST_PP_LOCAL_ITERATE()
|
---|
| 316 | #endif
|
---|
| 317 | return dialog;
|
---|
| 318 | };
|
---|
| 319 |
|
---|
[46b181] | 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
|
---|
[f6ff216] | 330 | if (status) {
|
---|
| 331 | ost << "--" << TOKEN;
|
---|
| 332 | #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
|
---|
| 333 | ost << " ";
|
---|
| 334 | #endif
|
---|
| 335 | }
|
---|
[46b181] | 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 |
|
---|
[477012] | 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 |
|
---|
[862b6a] | 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 |
|
---|
[b4fa106] | 362 | // =========== command for calling action directly ===========
|
---|
| 363 | void COMMAND(
|
---|
[f10b0c] | 364 | #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
|
---|
[b4fa106] | 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
|
---|
[05736a] | 369 | )
|
---|
[0b2ce9] | 370 | {
|
---|
[1d3563] | 371 | ACTION *ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN )); //->clone(params);
|
---|
[ddde10] | 372 | //ACTION::PARAMS params;
|
---|
[f10b0c] | 373 | #if defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
|
---|
| 374 | #define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, paramreferences, ToCall->params.)
|
---|
[b4fa106] | 375 | #define BOOST_PP_LOCAL_LIMITS (0, MAXPARAMTYPES-1)
|
---|
[0b2ce9] | 376 | #include BOOST_PP_LOCAL_ITERATE()
|
---|
| 377 | #endif
|
---|
[975b83] | 378 | Action::insertAction( ToCall, Action::NonInteractive);
|
---|
[0b2ce9] | 379 | };
|
---|
| 380 |
|
---|
[88ba1f] | 381 | void BOOST_PP_CAT( COMMAND, _stringargs)(
|
---|
[f10b0c] | 382 | #if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
|
---|
[88ba1f] | 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 | ) {
|
---|
[1d3563] | 388 | ACTION *ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN )); //->clone(params);
|
---|
[88ba1f] | 389 | //ACTION::PARAMS params;
|
---|
[f10b0c] | 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. )
|
---|
[88ba1f] | 392 | #define BOOST_PP_LOCAL_LIMITS (0, MAXPARAMTYPES-1)
|
---|
| 393 | #include BOOST_PP_LOCAL_ITERATE()
|
---|
| 394 | #endif
|
---|
[975b83] | 395 | Action::insertAction( ToCall, Action::NonInteractive);
|
---|
[88ba1f] | 396 | };
|
---|
| 397 |
|
---|
[ce7fdc] | 398 | }
|
---|
| 399 |
|
---|
[b4fa106] | 400 | // free up defines
|
---|
[649aaa] | 401 | #undef paramvalids
|
---|
[b4fa106] | 402 | #undef paramtypes
|
---|
| 403 | #undef paramtokens
|
---|
| 404 | #undef paramreferences
|
---|
[649aaa] | 405 | #undef paramdescriptions
|
---|
| 406 | #undef paramdefaults
|
---|
[b4fa106] | 407 | #undef MAXPARAMTYPES
|
---|
[6ba9ba] | 408 | #undef MAXPARAMDEFAULTS
|
---|
[b4fa106] | 409 | #undef statetypes
|
---|
| 410 | #undef statereferences
|
---|
| 411 | #undef MAXSTATETYPES
|
---|
[6ba9ba] | 412 | #undef PARAM_DEFAULT
|
---|
[0b2ce9] | 413 |
|
---|
[88ba1f] | 414 | #undef type2string
|
---|
| 415 | #undef stringtype
|
---|
[a02f78] | 416 | #undef initialiser_print
|
---|
| 417 | #undef type_print
|
---|
| 418 | #undef type_list
|
---|
| 419 | #undef dialog_print
|
---|
[6ba9ba] | 420 | #undef sequencer
|
---|
[649aaa] | 421 | #undef valid_print
|
---|
| 422 | #undef validcopy_print
|
---|
[a02f78] | 423 | #undef value_print
|
---|
[88ba1f] | 424 | #undef valuetype_print
|
---|
[a02f78] | 425 |
|
---|
[9ee38b] | 426 | #undef ACTION
|
---|
| 427 | #undef COMMAND
|
---|
| 428 | #undef PARAMS
|
---|
| 429 | #undef STATE
|
---|
[2a6a2c] | 430 | #undef INSTANCE
|
---|
[b4fa106] | 431 |
|
---|
| 432 | #undef ACTIONNAME
|
---|
| 433 | #undef CATEGORY
|
---|
[9ee38b] | 434 | #undef TOKEN
|
---|