Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action_impl_header.hpp

    r6ba9ba r3139b2  
    1414#include <boost/preprocessor/comparison/equal.hpp>
    1515#include <boost/preprocessor/comparison/not_equal.hpp>
    16 #include <boost/preprocessor/control/expr_if.hpp>
    1716#include <boost/preprocessor/control/if.hpp>
    1817#include <boost/preprocessor/debug/assert.hpp>
    1918#include <boost/preprocessor/iteration/local.hpp>
    20 #include <boost/preprocessor/list/adt.hpp>
    2119#include <boost/preprocessor/punctuation/comma_if.hpp>
    22 #include <boost/preprocessor/punctuation/paren.hpp>
    2320#include <boost/preprocessor/repetition/repeat.hpp>
    2421#include <boost/preprocessor/seq/elem.hpp>
     
    3431#include "Actions/ValueStorage.hpp"
    3532
    36 #include "Parameters/Parameter.hpp"
    37 
    3833// some derived names: if CATEGORY is not given, we don't prefix with it
    3934#ifdef CATEGORY
     
    5247#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)
    5348#endif
    54 #ifndef paramdefaults
    55 #define MAXPARAMDEFAULTS 0
    56 // 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 #else
    61 #define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults)
    62 #endif
    63 #define PARAM_DEFAULT(x) \
    64     (x, BOOST_PP_NIL)
    6549
    6650// check user has given name and category
     
    9377#endif
    9478
    95 // check if paramdefaults is given, otherwise fill list with NOPARAM_DEFAULT
     79// check if paramdefaults is given, otherwise fill list with NODEFAULT
    9680// this does not work: paramdefaults has to be completely defined before
    9781// being used within option_print (used as an array there and not as
    9882// some function call still to be expanded)
    99 //#define paramdefaults (NOPARAM_DEFAULT)
     83//#define paramdefaults (NODEFAULT)
    10084//#define tempvalue(z,n,value)
    101 //  BOOST_PP_CAT(value,(NOPARAM_DEFAULT))
     85//  BOOST_PP_CAT(value,(NODEFAULT))
    10286//BOOST_PP_REPEAT(tempvalue, MAXPARAMTYPES, paramdefaults)
    10387//#undef tempvalue
     
    11195#endif
    11296
    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;"
    11498#define type_print(z,n,TYPELIST, VARLIST, separator) \
    115   Parameter < \
    11699  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
    117   > \
    118   BOOST_PP_SEQ_ELEM(n, VARLIST) \
     100  BOOST_PP_SEQ_ELEM(n, VARLIST)\
    119101  separator
    120102
     
    126108
    127109// prints Options.insert
     110#ifdef paramdefaults
    128111#define option_print(z,n,unused, unused2) \
    129112  tester = Options. insert (\
     
    133116          BOOST_PP_SEQ_ELEM(n, paramtokens), \
    134117          &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) ) )\
    143120      )\
    144121  ); \
    145122  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
    146137
    147138namespace MoleCuilder {
     
    214205
    215206  struct PARAMS : ActionParameters {
    216     //!> constructor for class PARAMS, setting valid ranges
    217     PARAMS();
    218     //!> copy constructor for class PARAMS, setting valid ranges
    219     PARAMS(const PARAMS &p);
    220207  #if defined paramtypes && defined paramreferences
    221208  #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, paramtypes, paramreferences, ;)
     
    232219
    233220private:
    234   //virtual void getParametersfromValueStorage();
     221  virtual void getParametersfromValueStorage();
    235222  virtual Action::state_ptr performCall();
    236223  virtual Action::state_ptr performUndo(Action::state_ptr);
     
    240227}
    241228
    242 #undef paramvalids
    243229#undef paramtypes
    244230#undef paramtokens
     
    247233#undef paramdefaults
    248234#undef MAXPARAMTYPES
    249 #undef MAXPARAMDEFAULTS
    250235#undef statetypes
    251236#undef statereferences
    252237#undef MAXSTATETYPES
    253 #undef PARAM_DEFAULT
    254238
    255239#undef option_print
    256 #undef sequencer
    257240#undef type_print
    258241#undef type_list
Note: See TracChangeset for help on using the changeset viewer.