Ignore:
Timestamp:
Aug 28, 2010, 12:57:50 AM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
e3e6e2
Parents:
9ee38b
git-author:
Frederik Heber <heber@…> (08/26/10 13:23:21)
git-committer:
Frederik Heber <heber@…> (08/28/10 00:57:50)
Message:

Extended action generating macro framework to create specialized ActionState, too.

  • types, tokens, references -> param...
  • new statetypes, statereferences that have to be defined for additional variables in the state
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action_impl_header.hpp

    r9ee38b rb4fa106  
    2323#define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action))
    2424#define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME)
    25 #define STATE BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, State))
    2625#define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
    27 #define PARAMSDOT BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
    2826
    2927// check if no lists given
    30 #ifndef types
    31 #define MAXNOTOKENS 0
     28#ifndef paramtypes
     29#define MAXPARAMTYPES 0
    3230#else
    33 #define MAXNOTOKENS BOOST_PP_SEQ_SIZE(types)
     31#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)
    3432#endif
    3533
     
    4442
    4543// calculate numbers and check whether all have same size
    46 #ifdef tokens
    47 BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXNOTOKENS, BOOST_PP_SEQ_SIZE(tokens)),\
    48   ERROR: There are not the same number of "tokens" and "types" in: __FILE__ \
     44#ifdef paramtokens
     45BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXPARAMTYPES, BOOST_PP_SEQ_SIZE(paramtokens)),\
     46  ERROR: There are not the same number of "paramtokens" and "paramtypes" in: __FILE__ \
    4947)
    5048#endif
    51 #ifdef references
    52 BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXNOTOKENS, BOOST_PP_SEQ_SIZE(references)),\
    53   ERROR: There are not the same number of "tokens" and "references" in: __FILE__ \
     49#ifdef paramreferences
     50BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXPARAMTYPES, BOOST_PP_SEQ_SIZE(paramreferences)),\
     51  ERROR: There are not the same number of "paramtokens" and "paramreferences" in: __FILE__ \
    5452)
    5553#endif
    5654
    5755// print a list of type ref followed by a separator, i.e. "int i;"
    58 #define type_print(z,n,separator) \
    59   BOOST_PP_SEQ_ELEM(n, types) \
    60   BOOST_PP_SEQ_ELEM(n, references)\
     56#define type_print(z,n,TYPELIST, VARLIST, separator) \
     57  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
     58  BOOST_PP_SEQ_ELEM(n, VARLIST)\
    6159  separator
    6260
    6361// print a list of type ref followed, i.e. "int i, double position"
    64 #define type_list(z,n,unused) \
     62#define type_list(z,n,TYPELIST, VARLIST) \
    6563  BOOST_PP_COMMA_IF(n)\
    66   BOOST_PP_SEQ_ELEM(n, types) \
    67   BOOST_PP_SEQ_ELEM(n, references)
     64  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
     65  BOOST_PP_SEQ_ELEM(n, VARLIST)
    6866
    69 // prints dialog->query calls for types with tokens
    70 #define dialog_print(z,n,unused) \
    71   dialog->query<\
    72   BOOST_PP_SEQ_ELEM(n, types)\
    73   >(\
    74   BOOST_PP_SEQ_ELEM(n, tokens)\
    75   , ValueStorage::getInstance().getDescription(\
    76   BOOST_PP_SEQ_ELEM(n, tokens)\
    77   ));
    78 
    79 // prints set/queryCurrentValue (command) for references and tokens
    80 #define value_print(z,n,command) \
    81   ValueStorage::getInstance(). command (\
    82   BOOST_PP_SEQ_ELEM(n, tokens)\
    83   , \
    84   params.\
    85   BOOST_PP_SEQ_ELEM(n, references)\
    86   );
    87 
    88 #if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
    89 #define COMMANDFULL \
    90 void COMMAND( \
    91 BOOST_PP_REPEAT(MAXNOTOKENS, type_list, ~) \
    92 )
     67#if defined paramtypes && defined paramreferences
     68void COMMAND(
     69#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)
     70#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     71#include BOOST_PP_LOCAL_ITERATE()
     72    );
    9373# else
    94 #define COMMANDFULL void COMMAND()
     74void COMMAND();
    9575#endif
    9676
    97 COMMANDFULL;
     77class ACTION : public Action {
     78  friend
     79  #if defined paramtypes && defined paramreferences
     80  void COMMAND(
     81  #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)
     82  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     83  #include BOOST_PP_LOCAL_ITERATE()
     84      );
     85  # else
     86  void COMMAND();
     87  #endif
    9888
    99 class ACTION : public Action {
    100   friend COMMANDFULL;
    10189public:
    10290  ACTION();
     
    10997
    11098  struct PARAMS : ActionParameters {
    111   #if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
    112   #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, ;)
    113   #define BOOST_PP_LOCAL_LIMITS  (0, MAXNOTOKENS-1)
     99  #if defined paramtypes && defined paramreferences
     100  #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, paramtypes, paramreferences, ;)
     101  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
    114102  #include BOOST_PP_LOCAL_ITERATE()
    115   #undef BOOST_PP_LOCAL_MACRO
    116   #undef BOOST_PP_LOCAL_LIMITS
    117103  #endif
    118104  } params;
     
    129115};
    130116
    131 #undef types
    132 #undef tokens
    133 #undef references
    134 #undef MAXNOTOKENS
     117#undef paramtypes
     118#undef paramtokens
     119#undef paramreferences
     120#undef MAXPARAMTYPES
     121#undef statetypes
     122#undef statereferences
     123#undef MAXSTATETYPES
    135124
    136125#undef ACTION
    137 #undef ACTIONNAME
    138 #undef CATEGORY
    139126#undef COMMAND
    140127#undef COMMANDFULL
    141128#undef PARAMS
    142 #undef STATE
     129
     130#undef ACTIONNAME
     131#undef CATEGORY
    143132#undef TOKEN
Note: See TracChangeset for help on using the changeset viewer.