Changeset b2c302 for src/Actions
- Timestamp:
- Apr 11, 2012, 4:56:55 PM (13 years ago)
- 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:
- e44956
- Parents:
- be21fa
- git-author:
- Frederik Heber <heber@…> (03/16/12 12:29:01)
- git-committer:
- Frederik Heber <heber@…> (04/11/12 16:56:55)
- Location:
- src/Actions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/Action.hpp
rbe21fa rb2c302 36 36 namespace MoleCuilder { 37 37 38 /** 39 * Base class for all actions. 38 /** Actions are Command patterns to allow for undoing and redoing. 39 * 40 * Each specific Action derives from this class to implement a certain functionality. 40 41 * 41 42 * Actions describe something that has to be done. 42 * Actions can be passed around, stored, performed and undone (Command-Pattern). 43 * Actions can be passed around, stored, performed and undone (Command-Pattern: 44 * http://en.wikipedia.org/wiki/Command_pattern). 45 * 46 * Unique to each Action is its ActionTrait, i.e. the options it requires 47 * to perform a certain function. E.g. in order to execute a "add atom" Action 48 * we need to know a position and an element. These options have certain 49 * properties, see \ref OptionTrait and \ref ActionTrait wherein these are stored. 50 * Essentially, each option is stored as an \ref OptionTrait instance and 51 * contains the token, default value, a description, the type, ... 52 * 53 * ActionTrait itself is also an OptionTrait because the command token may actually 54 * coincide with an option-token. E.g. this allows "...--add-atom 3" to mean 55 * both execute the action under token "add-atom" and that the option "add-atom" 56 * (the new atom's \ref element number) should contain 3. 57 * 58 * \ref ActionTrait contains a map of all associated options. With this in the cstor 59 * we register not only the Action with the \ref ActionRegistry but also each of 60 * its \link options OptionTrait \endlink with the \ref OptionRegistry. 61 * 62 * The token of the option is unique, but two Action's may share the same token if: 63 * -# they have the same default value 64 * -# they have the same type 65 * 66 * This requirement is easy because if you need to store some option of another 67 * type, simply think of a new suitable name for it. 68 * 69 * The actual value, i.e. "3" in the "add-atom" example, is taken from the 70 * ValueStorage, see \ref Dialog for how this is possible. 71 * 72 * \note There is a unit test that checks on the consistency of all registered 73 * options, also in "--enable-debug"-mode assertions will check that an option 74 * has not been registered before under another type. 75 * 43 76 */ 44 77 class Action -
src/Actions/ActionRegistry.hpp
rbe21fa rb2c302 30 30 * It is a singleton and can be called from anywhere. 31 31 * 32 * ActionRegistry::fillRegistry() is the essential function, called in the cstor, 33 * where all the prototypical Action's are instantiated. To this end, we sadly 34 * require a global list of all present actions (\note there is a regression test 35 * check on its completeness). We include \ref GlobalListOfActionsh.hpp where a 36 * boost::preprocessor sequence is contained that is then used to install each 37 * of the Action's in the registry. 38 * 32 39 */ 33 40 class ActionRegistry : public Singleton<ActionRegistry>, public Registry<Action> -
src/Actions/ValueStorage.hpp
rbe21fa rb2c302 84 84 #include "CodePatterns/Singleton.hpp" 85 85 86 /** ValueStorage serves as a mediator to MapOfActions. 86 /** ValueStorage is a container for any type of value. 87 * 87 88 * This is needed to relax inter-dependencies between the Queries and the Actions. 88 * I.e. this is the interface implemented in MapOfActions which both can safely rely on 89 * to store&retrieve/exchange values. 90 * 91 * \section ValueStorage ValueStorage howto 89 * 90 * The ValueStorage is necessary because we do not a-priori know about the 91 * type of a value as given by the user. The type is handled via RTTI (run-time 92 * type information), and the value is cast to string stored under a specific 93 * token in a map inside this class. 94 * 95 * Not any value can be stored in this container. We rely on OptionRegistry to allow 96 * only tokens whose type has been defined beforehand. I.e. for each option we 97 * require a specific and unique type. 98 * 99 * Then, there are three types of functions: 100 * -# queryCurrentValue: request a value under a specific token 101 * -# setCurrentValue: set/enter a value under a specific token 102 * -# isCurrentValuePresent: ask whether a value under a specific token is contained 103 * 104 * For the first two we have templated version and a number of specialized ones to 105 * deal with some types specific to this code: \ref atom, \ref Box, \ref element, 106 * \ref molecule, ... 107 * 108 * \section ValueStorage-extend ValueStorage extension howto 92 109 * 93 110 * If you ever need to add a particular class to the ValueStorage, do as follows: … … 98 115 * class' members to a stringstream or use an already implemented operator<< 99 116 * or operator<<, respectively. 117 * 118 * \section ValueStorage-further-info Further information 119 * 120 * If you want to know in detail how this all works with the options, where they 121 * come from and how values end up in the ValueStorage, then look at \ref actions 122 * and \ref userinterfaces. 100 123 * 101 124 */
Note:
See TracChangeset
for help on using the changeset viewer.