Changeset 83e90c for src/Actions


Ignore:
Timestamp:
Nov 7, 2011, 10:46:25 AM (13 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:
dad802
Parents:
aee2da
git-author:
Frederik Heber <heber@…> (09/21/11 18:56:31)
git-committer:
Frederik Heber <heber@…> (11/07/11 10:46:25)
Message:

New function ActionRegistry::fillRegistry() fills instead of static instances.

  • this replaces the static instances of each Action in Action_impl_pre.hpp.
  • we use a file that has to list all present actions, GlobalListOfActions.hpp, as it is not possible to build such a list with the preprocessor from all include files and use it afterwards, as e.g. the define COMMAND only has a _local_ meaning inside the include but the sequence of actions must be built up from _global_ ones.
  • Actions/Makefile.am: creates AllActionHeaders.hpp out of this list of present actions.
  • specialized Actions do not register themselves anymore.
Location:
src/Actions
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionRegistry.cpp

    raee2da r83e90c  
    2424#include "CodePatterns/Registry_impl.hpp"
    2525
     26#include "GlobalListOfActions.hpp"
     27
     28#include "AllActionHeaders.hpp"
     29
     30#include <boost/preprocessor/iteration/local.hpp>
     31#include <boost/preprocessor/seq/elem.hpp>
     32#include <boost/preprocessor/seq/size.hpp>
     33
    2634using namespace MoleCuilder;
    2735
     
    2937 */
    3038ActionRegistry::ActionRegistry()
    31 {}
     39{
     40  //std::cout << "ActionRegistry::ActionRegistry() called, instance is " << this << "." << std::endl;
     41  fillRegistry();
     42}
    3243
    3344/** Destructor for class ActionRegistry.
     
    3546ActionRegistry::~ActionRegistry()
    3647{
     48  //std::cout << "ActionRegistry::~ActionRegistry() called, instance is " << this << "." << std::endl;
    3749  cleanup();
     50}
     51
     52
     53/** Instantiates each existing Action.
     54 *
     55 */
     56void ActionRegistry::fillRegistry()
     57{
     58#define instance_print(z,n,list) \
     59        { \
     60        Action * presentAction = new \
     61        BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(n, list), Action) \
     62        (); \
     63        registerInstance(presentAction); \
     64        }
     65#define BOOST_PP_LOCAL_MACRO(n) instance_print(~, n, GLOBALLISTOFACTIONS)
     66#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(GLOBALLISTOFACTIONS)))
     67#include BOOST_PP_LOCAL_ITERATE()
     68#undef instance_print 
    3869}
    3970
  • src/Actions/ActionRegistry.hpp

    raee2da r83e90c  
    4444  ActionRegistry();
    4545  ~ActionRegistry();
     46
     47  void fillRegistry();
    4648};
    4749
  • src/Actions/Action_impl_pre.hpp

    raee2da r83e90c  
    174174
    175175// (const) prototype to be placed into the ActionRegistry (must be deleted by registry itself)
    176 const ACTION *INSTANCE = new ACTION();
     176//const ACTION INSTANCE;
     177//boost::shared_ptr< ACTION > INSTANCE( new ACTION() );
    177178
    178179// =========== constructor ===========
    179180ACTION::ACTION () :
    180   Action(ActionTrait<ACTION>())
     181  Action(ActionTrait< ACTION >(), false)
    181182{}
    182183
  • src/Actions/Makefile.am

    raee2da r83e90c  
    407407libMolecuilderActionPrototypes_la_includedir = $(includedir)/MoleCuilder/Actions/
    408408
     409BUILT_SOURCES += AllActionHeaders.hpp
     410
    409411#       UIElements/libMolecuilderUI.la
    410412nobase_libMolecuilderActions_la_include_HEADERS = ${ACTIONSHEADER}
    411 nobase_libMolecuilderActionPrototypes_la_include_HEADERS = ${ACTIONPROTOTYPESHEADER} ${ACTIONPROTOTYPESDEFS}
     413nobase_libMolecuilderActionPrototypes_la_include_HEADERS = ${ACTIONPROTOTYPESHEADER} ${ACTIONPROTOTYPESDEFS} AllActionHeaders.hpp
     414nodist_libMolecuilderActionPrototypes_la_include_HEADERS = AllActionHeaders.hpp
    412415
    413416## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
     
    447450#pkgconfigdir = $(libdir)/pkgconfig
    448451#pkgconfig_DATA = $(top_builddir)/MoleCuilder.pc
     452
     453AllActionHeaders.hpp: $(ACTIONPROTOTYPESHEADER)
     454        echo "#ifndef ALLACTIONHEADERS_HPP_" >$@; \
     455        echo "#define ALLACTIONHEADERS_HPP_" >>$@; \
     456        for file in $(ACTIONPROTOTYPESHEADER); do \
     457                echo "#include \"$$file\"" >>$@; \
     458        done; \
     459        echo "#endif /* ALLACTIONHEADERS_HPP_ */" >>$@;
     460
     461MOSTLYCLEANFILES += \
     462        AllActionHeaders.hpp
Note: See TracChangeset for help on using the changeset viewer.