Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action_impl_header.hpp

    r3139b2 r6ba9ba  
    1414#include <boost/preprocessor/comparison/equal.hpp>
    1515#include <boost/preprocessor/comparison/not_equal.hpp>
     16#include <boost/preprocessor/control/expr_if.hpp>
    1617#include <boost/preprocessor/control/if.hpp>
    1718#include <boost/preprocessor/debug/assert.hpp>
    1819#include <boost/preprocessor/iteration/local.hpp>
     20#include <boost/preprocessor/list/adt.hpp>
    1921#include <boost/preprocessor/punctuation/comma_if.hpp>
     22#include <boost/preprocessor/punctuation/paren.hpp>
    2023#include <boost/preprocessor/repetition/repeat.hpp>
    2124#include <boost/preprocessor/seq/elem.hpp>
     
    3134#include "Actions/ValueStorage.hpp"
    3235
     36#include "Parameters/Parameter.hpp"
     37
    3338// some derived names: if CATEGORY is not given, we don't prefix with it
    3439#ifdef CATEGORY
     
    4752#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)
    4853#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)
    4965
    5066// check user has given name and category
     
    7793#endif
    7894
    79 // check if paramdefaults is given, otherwise fill list with NODEFAULT
     95// check if paramdefaults is given, otherwise fill list with NOPARAM_DEFAULT
    8096// this does not work: paramdefaults has to be completely defined before
    8197// being used within option_print (used as an array there and not as
    8298// some function call still to be expanded)
    83 //#define paramdefaults (NODEFAULT)
     99//#define paramdefaults (NOPARAM_DEFAULT)
    84100//#define tempvalue(z,n,value)
    85 //  BOOST_PP_CAT(value,(NODEFAULT))
     101//  BOOST_PP_CAT(value,(NOPARAM_DEFAULT))
    86102//BOOST_PP_REPEAT(tempvalue, MAXPARAMTYPES, paramdefaults)
    87103//#undef tempvalue
     
    95111#endif
    96112
    97 // print a list of type ref followed by a separator, i.e. "int i;"
     113// print a list of type ref followed by a separator, i.e. "Parameter<int> i;"
    98114#define type_print(z,n,TYPELIST, VARLIST, separator) \
     115  Parameter < \
    99116  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
    100   BOOST_PP_SEQ_ELEM(n, VARLIST)\
     117  > \
     118  BOOST_PP_SEQ_ELEM(n, VARLIST) \
    101119  separator
    102120
     
    108126
    109127// prints Options.insert
    110 #ifdef paramdefaults
    111128#define option_print(z,n,unused, unused2) \
    112129  tester = Options. insert (\
     
    116133          BOOST_PP_SEQ_ELEM(n, paramtokens), \
    117134          &typeid( BOOST_PP_SEQ_ELEM(n, paramtypes) ), \
    118           BOOST_PP_SEQ_ELEM(n, paramdescriptions), \
    119           std::string( BOOST_PP_SEQ_ELEM(n, paramdefaults) ) )\
     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          )\
    120143      )\
    121144  ); \
    122145  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
    137146
    138147namespace MoleCuilder {
     
    205214
    206215  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);
    207220  #if defined paramtypes && defined paramreferences
    208221  #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, paramtypes, paramreferences, ;)
     
    219232
    220233private:
    221   virtual void getParametersfromValueStorage();
     234  //virtual void getParametersfromValueStorage();
    222235  virtual Action::state_ptr performCall();
    223236  virtual Action::state_ptr performUndo(Action::state_ptr);
     
    227240}
    228241
     242#undef paramvalids
    229243#undef paramtypes
    230244#undef paramtokens
     
    233247#undef paramdefaults
    234248#undef MAXPARAMTYPES
     249#undef MAXPARAMDEFAULTS
    235250#undef statetypes
    236251#undef statereferences
    237252#undef MAXSTATETYPES
     253#undef PARAM_DEFAULT
    238254
    239255#undef option_print
     256#undef sequencer
    240257#undef type_print
    241258#undef type_list
Note: See TracChangeset for help on using the changeset viewer.