Changeset 2a6a2c


Ignore:
Timestamp:
Oct 30, 2010, 6:44:29 PM (14 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:
24fbf3
Parents:
bc2990
git-author:
Frederik Heber <heber@…> (10/26/10 09:44:19)
git-committer:
Frederik Heber <heber@…> (10/30/10 18:44:29)
Message:

Removed MapOfActions::populateActions().

  • Action prototypes are now instantiated within the object file, as they register automatically with the ActionRegistry and can henceforth be used.
    • new define INSTANCE with a sort of unique name.
    • instance is const and hence not to be used directly.
    • MapOfActions::populateActions() removed in CommandLineWindow, QtMainWindow and TextWindow classes.
    • NOTE: this hopefully remedies the problem of forgetting to add new Actions.
  • Registry does not cleanup() in its destructor, but function may be called from derived class if desired.
    • All Action prototypes are destroyed at end of program and hence cleanup() would cause memory corruption.
Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action_impl_pre.hpp

    rbc2990 r2a6a2c  
    4747#define STATE BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, State))
    4848#define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
     49#define INSTANCE BOOST_PP_CAT(this_, BOOST_PP_CAT(ACTIONNAME, _instance))
    4950
    5051// check if no lists given
     
    158159const char ACTION::NAME[] = TOKEN;
    159160
     161// (const) prototype to be placed into the ActionRegistry (must be deleted by registry itself)
     162const ACTION INSTANCE;
     163
    160164// =========== constructor ===========
    161165ACTION::ACTION () :
     
    223227#undef PARAMS
    224228#undef STATE
     229#undef INSTANCE
    225230
    226231#undef ACTIONNAME
  • src/Actions/MapOfActions.cpp

    rbc2990 r2a6a2c  
    4848
    4949#include "Actions/ActionRegistry.hpp"
    50 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
    51 #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
    52 #include "Actions/AnalysisAction/PointCorrelationAction.hpp"
    53 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
    54 #include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
    55 #include "Actions/AtomAction/AddAction.hpp"
    56 #include "Actions/AtomAction/ChangeElementAction.hpp"
    57 #include "Actions/AtomAction/RemoveAction.hpp"
    58 #include "Actions/AtomAction/RotateAroundOriginByAngleAction.hpp"
    59 #include "Actions/AtomAction/TranslateAction.hpp"
    60 #include "Actions/CommandAction/BondLengthTableAction.hpp"
    61 #include "Actions/CommandAction/ElementDbAction.hpp"
    62 #include "Actions/CommandAction/FastParsingAction.hpp"
    63 #include "Actions/CommandAction/HelpAction.hpp"
    64 #include "Actions/CommandAction/VerboseAction.hpp"
    65 #include "Actions/CommandAction/VersionAction.hpp"
    66 #include "Actions/CommandAction/WarrantyAction.hpp"
    67 #include "Actions/FragmentationAction/ConstructBondGraphAction.hpp"
    68 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
    69 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
    70 #include "Actions/FragmentationAction/FragmentationAction.hpp"
    71 #include "Actions/MoleculeAction/BondFileAction.hpp"
    72 #include "Actions/MoleculeAction/ChangeNameAction.hpp"
    73 #include "Actions/MoleculeAction/CopyAction.hpp"
    74 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
    75 #include "Actions/MoleculeAction/FillVoidWithMoleculeAction.hpp"
    76 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
    77 #include "Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp"
    78 #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
    79 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
    80 #include "Actions/MoleculeAction/SaveBondsAction.hpp"
    81 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
    82 #include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
    83 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
    84 #include "Actions/ParserAction/LoadXyzAction.hpp"
    85 #include "Actions/ParserAction/SaveXyzAction.hpp"
    86 #include "Actions/SelectionAction/AllAtomsAction.hpp"
    87 #include "Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp"
    88 #include "Actions/SelectionAction/AllAtomsInsideSphereAction.hpp"
    89 #include "Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp"
    90 #include "Actions/SelectionAction/AllMoleculesAction.hpp"
    91 #include "Actions/SelectionAction/AtomByElementAction.hpp"
    92 #include "Actions/SelectionAction/AtomByIdAction.hpp"
    93 #include "Actions/SelectionAction/ClearAllAtomsAction.hpp"
    94 #include "Actions/SelectionAction/ClearAllMoleculesAction.hpp"
    95 #include "Actions/SelectionAction/MoleculeByFormulaAction.hpp"
    96 #include "Actions/SelectionAction/MoleculeByIdAction.hpp"
    97 #include "Actions/SelectionAction/MoleculeOfAtomAction.hpp"
    98 #include "Actions/SelectionAction/NotAllAtomsAction.hpp"
    99 #include "Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp"
    100 #include "Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp"
    101 #include "Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp"
    102 #include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
    103 #include "Actions/SelectionAction/NotAtomByElementAction.hpp"
    104 #include "Actions/SelectionAction/NotAtomByIdAction.hpp"
    105 #include "Actions/SelectionAction/NotMoleculeByFormulaAction.hpp"
    106 #include "Actions/SelectionAction/NotMoleculeByIdAction.hpp"
    107 #include "Actions/SelectionAction/NotMoleculeOfAtomAction.hpp"
    108 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
    109 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
    110 #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
    111 #include "Actions/WorldAction/BoundInBoxAction.hpp"
    112 #include "Actions/WorldAction/CenterInBoxAction.hpp"
    113 #include "Actions/WorldAction/CenterOnEdgeAction.hpp"
    114 #include "Actions/WorldAction/ChangeBoxAction.hpp"
    115 #include "Actions/WorldAction/InputAction.hpp"
    116 #include "Actions/WorldAction/OutputAction.hpp"
    117 #include "Actions/WorldAction/RepeatBoxAction.hpp"
    118 #include "Actions/WorldAction/ScaleBoxAction.hpp"
    119 #include "Actions/WorldAction/SetDefaultNameAction.hpp"
    120 #include "Actions/WorldAction/SetGaussianBasisAction.hpp"
    121 #include "Actions/WorldAction/SetOutputFormatsAction.hpp"
    12250#include "Actions/Values.hpp"
    12351
     
    973901  } else
    974902    throw IllegalTypeException(__FILE__,__LINE__);
    975 }
    976 
    977 
    978 
    979 void MapOfActions::populateActions()
    980 {
    981   new AnalysisMolecularVolumeAction();
    982   new AnalysisPairCorrelationAction();
    983   new AnalysisPointCorrelationAction();
    984   new AnalysisPrincipalAxisSystemAction();
    985   new AnalysisSurfaceCorrelationAction();
    986 
    987   new AtomAddAction();
    988   new AtomChangeElementAction();
    989   new AtomRemoveAction();
    990   new AtomRotateAroundOriginByAngleAction();
    991   new AtomTranslateAction();
    992 
    993   new CommandBondLengthTableAction();
    994   new CommandElementDbAction();
    995   new CommandFastParsingAction();
    996   new CommandHelpAction();
    997   new CommandVerboseAction();
    998   new CommandVersionAction();
    999   new CommandWarrantyAction();
    1000 
    1001   new FragmentationConstructBondGraphAction();
    1002   new FragmentationDepthFirstSearchAction();
    1003   new FragmentationFragmentationAction();
    1004   new FragmentationSubgraphDissectionAction();
    1005 
    1006   new MoleculeBondFileAction();
    1007   new MoleculeChangeNameAction();
    1008   new MoleculeCopyAction();
    1009   new MoleculeFillWithMoleculeAction();
    1010   new MoleculeFillVoidWithMoleculeAction();
    1011   new MoleculeLinearInterpolationofTrajectoriesAction();
    1012   new MoleculeRotateAroundSelfByAngleAction();
    1013   new MoleculeRotateToPrincipalAxisSystemAction();
    1014   new MoleculeSaveAdjacencyAction();
    1015   new MoleculeSaveBondsAction();
    1016   new MoleculeSaveTemperatureAction();
    1017   new MoleculeSuspendInWaterAction();
    1018   new MoleculeVerletIntegrationAction();
    1019 
    1020   new ParserLoadXyzAction();
    1021   new ParserSaveXyzAction();
    1022 
    1023   new SelectionClearAllAtomsAction();
    1024   new SelectionClearAllMoleculesAction();
    1025   new SelectionAllAtomsAction();
    1026   new SelectionAllAtomsInsideCuboidAction();
    1027   new SelectionAllAtomsInsideSphereAction();
    1028   new SelectionAllAtomsOfMoleculeAction();
    1029   new SelectionAllMoleculesAction();
    1030   new SelectionAtomByElementAction();
    1031   new SelectionAtomByIdAction();
    1032   new SelectionMoleculeByIdAction();
    1033   new SelectionMoleculeByFormulaAction();
    1034   new SelectionMoleculeOfAtomAction();
    1035   new SelectionNotAllAtomsAction();
    1036   new SelectionNotAllAtomsInsideCuboidAction();
    1037   new SelectionNotAllAtomsInsideSphereAction();
    1038   new SelectionNotAllAtomsOfMoleculeAction();
    1039   new SelectionNotAllMoleculesAction();
    1040   new SelectionNotAtomByElementAction();
    1041   new SelectionNotAtomByIdAction();
    1042   new SelectionNotMoleculeByFormulaAction();
    1043   new SelectionNotMoleculeByIdAction();
    1044   new SelectionNotMoleculeOfAtomAction();
    1045 
    1046   new TesselationConvexEnvelopeAction();
    1047   new TesselationNonConvexEnvelopeAction();
    1048 
    1049   new WorldAddEmptyBoundaryAction();
    1050   new WorldBoundInBoxAction();
    1051   new WorldCenterInBoxAction();
    1052   new WorldCenterOnEdgeAction();
    1053   new WorldChangeBoxAction();
    1054   new WorldInputAction();
    1055   new WorldOutputAction();
    1056   new WorldRepeatBoxAction();
    1057   new WorldScaleBoxAction();
    1058   new WorldSetDefaultNameAction();
    1059   new WorldSetGaussianBasisAction();
    1060   new WorldSetOutputFormatsAction();
    1061 }
     903 }
    1062904
    1063905/** Adds all options to the CommandLineParser.
  • src/Actions/MapOfActions.hpp

    rbc2990 r2a6a2c  
    164164  std::map <std::string, std::pair<std::string,std::string> > MenuDescription;
    165165
    166   // instantiates and puts all known actions into the ActionRegistry
    167   void populateActions();
    168 
    169166  bool isCurrentValuePresent(const char *name) const;
    170167  void queryCurrentValue(const char * name, class atom * &_T);
  • src/Patterns/Registry_impl.hpp

    rbc2990 r2a6a2c  
    2525 */
    2626template <class T> Registry<T>::~Registry()
    27 {
    28   cleanup();
    29 }
     27{}
    3028
    3129/** Returns pointer to an instance named by \a name.
  • src/UIElements/CommandLineUI/CommandLineWindow.cpp

    rbc2990 r2a6a2c  
    3838CommandLineWindow::CommandLineWindow()
    3939{
    40   // create and register all command line callable actions
    41   MapOfActions::getInstance().populateActions();
    42 
    4340  // Add status indicators etc...
    4441  statusIndicator = new CommandLineStatusIndicator();
  • src/UIElements/Qt4/QtMainWindow.cpp

    rbc2990 r2a6a2c  
    7373  }
    7474
    75   // populate all actions
    76   MapOfActions::getInstance().populateActions();
    77 
    7875  // go through all actions and add them to its menu
    7976  for (std::map <std::string, QtMenu *>::iterator MenuRunner = NametoTextMenuMap.begin(); MenuRunner != NametoTextMenuMap.end(); ++MenuRunner) {
  • src/UIElements/TextUI/TextWindow.cpp

    rbc2990 r2a6a2c  
    6060  ShortcutList.insert('s');
    6161  ShortcutList.insert('q');
    62 
    63   // populate all actions
    64   MapOfActions::getInstance().populateActions();
    6562
    6663  // build the main menu
Note: See TracChangeset for help on using the changeset viewer.