Changeset a7b777c
- Timestamp:
- Jul 28, 2010, 1:01:02 PM (14 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:
- 2ad482, 4c9a97, 9106c6
- Parents:
- 677e13 (diff), b2d8d0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/Action.cpp
r677e13 ra7b777c 34 34 { 35 35 if(_doRegister){ 36 ActionRegistry::getInstance().register Action(this);36 ActionRegistry::getInstance().registerInstance(this); 37 37 } 38 38 } -
src/Actions/ActionRegistry.cpp
r677e13 ra7b777c 1 1 /* 2 * ActionRegistry.cpp2 * Registry<Action>.cpp 3 3 * 4 4 * Created on: Jan 7, 2010 … … 9 9 10 10 #include "Actions/ActionRegistry.hpp" 11 #include "Actions/Action.hpp"12 13 11 #include "Patterns/Singleton_impl.hpp" 14 15 #include <string> 16 #include "Helpers/Assert.hpp" 17 #include <iostream> 18 19 using namespace std; 12 #include "Patterns/Registry_impl.hpp" 20 13 21 14 /** Constructor for class ActionRegistry. 22 15 */ 23 16 ActionRegistry::ActionRegistry() 24 { 25 } 17 {} 26 18 27 19 /** Destructor for class ActionRegistry. 28 20 */ 29 21 ActionRegistry::~ActionRegistry() 22 {} 23 24 /** Just passes on call to Registry<Action>::getByName(). 25 * \param name name of Action 26 * \return pointer to Action 27 */ 28 Action* ActionRegistry::getActionByName(const std::string name) 30 29 { 31 map<const string,Action*>::iterator iter; 32 for(iter=actionMap.begin();iter!=actionMap.end();++iter) { 33 delete iter->second; 34 } 35 actionMap.clear(); 30 return getByName(name); 36 31 } 37 32 38 /** Returns pointer to an action named by \a name.39 * \param name name of action40 * \return pointer to Action33 /** Just passes on call to Registry<Action>::isPresentByName(). 34 * \param name name of Action 35 * \return true - Action instance present, false - not 41 36 */ 42 Action* ActionRegistry::getActionByName(const std::string name){ 43 map<const string,Action*>::iterator iter; 44 iter = actionMap.find(name); 45 ASSERT(iter!=actionMap.end(),"Query for an action not stored in registry"); 46 return iter->second; 37 bool ActionRegistry::isActionPresentByName(const std::string name) 38 { 39 return isPresentByName(name); 47 40 } 48 41 49 /** States whether action is present or not.50 * \note This iss needed as ActionRegistry::getActionByName() ASSERT()s that action is in map.51 * \param name name of action52 * \return true - Action present, false - Action absent53 */54 bool ActionRegistry::isActionByNamePresent(const std::string name){55 map<const string,Action*>::iterator iter;56 iter = actionMap.find(name);57 return iter!=actionMap.end();58 }59 60 /** Registers an Action with the ActionRegistry.61 * \param *action pointer to Action.62 */63 void ActionRegistry::registerAction(Action* action){64 pair<map<const string,Action*>::iterator,bool> ret;65 //cout << "Trying to register action with name " << action->getName() << "." << endl;66 ret = actionMap.insert(pair<const string,Action*>(action->getName(),action));67 ASSERT(ret.second,"Two actions with the same name added to registry");68 }69 70 /** Unregisters an Action.71 * \param *action pointer to Action.72 */73 void ActionRegistry::unregisterAction(Action* action){74 //cout << "Unregistering action with name " << action->getName() << "." << endl;75 actionMap.erase(action->getName());76 }77 78 /** Returns an iterator pointing to the start of the map of Action's.79 * \return begin iterator80 */81 std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter()82 {83 return actionMap.begin();84 }85 86 /** Returns an iterator pointing to the end of the map of Action's.87 * \return end iterator88 */89 std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter()90 {91 return actionMap.end();92 }93 94 /** Returns a const iterator pointing to the start of the map of Action's.95 * \return constant begin iterator96 */97 std::map<const std::string,Action*>::const_iterator ActionRegistry::getBeginIter() const98 {99 return actionMap.begin();100 }101 102 /** Returns a const iterator pointing to the end of the map of Action's.103 * \return constant end iterator104 */105 std::map<const std::string,Action*>::const_iterator ActionRegistry::getEndIter() const106 {107 return actionMap.end();108 }109 110 /** Prints the contents of the ActionRegistry \a &m to \a &ost.111 * \param &ost output stream112 * \param &m reference to ActionRegistry113 * \return reference to the above out stream for concatenation114 */115 ostream& operator<<(ostream& ost, const ActionRegistry& m)116 {117 ost << "ActionRegistry contains:" << endl;118 for (std::map<const std::string,Action*>::const_iterator iter = m.getBeginIter(); iter != m.getEndIter(); ++iter) {119 ost << "\t" << iter->first << " with pointer " << iter->second << endl;120 }121 return ost;122 };123 124 125 126 42 CONSTRUCT_SINGLETON(ActionRegistry) 43 CONSTRUCT_REGISTRY(Action) -
src/Actions/ActionRegistry.hpp
r677e13 ra7b777c 1 1 /* 2 * ActionRegistry.hpp2 * Registry<Action>.hpp 3 3 * 4 4 * Created on: Jan 7, 2010 … … 13 13 #include <map> 14 14 15 #include "Patterns/Registry.hpp" 15 16 #include "Patterns/Singleton.hpp" 17 #include "Actions/Action.hpp" 16 18 17 class Action; 18 19 class ActionRegistry : public Singleton<ActionRegistry> 19 /** Action Registry. 20 * 21 * The Action registry is a storage for any Action instance to retrieved by name. 22 * It is a singleton and can be called from anywhere. 23 * 24 */ 25 class ActionRegistry : public Singleton<ActionRegistry>, public Registry<Action> 20 26 { 21 27 friend class Singleton<ActionRegistry>; 28 //friend class Registry<Action>; 29 22 30 public: 23 Action* getActionByName(const std::string); 24 bool isActionByNamePresent(const std::string name); 25 void registerAction(Action*); 26 void unregisterAction(Action*); 27 28 std::map<const std::string,Action*>::iterator getBeginIter(); 29 std::map<const std::string,Action*>::const_iterator getBeginIter() const; 30 std::map<const std::string,Action*>::iterator getEndIter(); 31 std::map<const std::string,Action*>::const_iterator getEndIter() const; 32 33 private: 34 std::map<const std::string,Action*> actionMap; 31 Action* getActionByName(const std::string name); 32 bool isActionPresentByName(const std::string name); 35 33 36 34 private: 37 35 ActionRegistry(); 38 virtual~ActionRegistry();36 ~ActionRegistry(); 39 37 }; 40 38 41 std::ostream& operator<<(std::ostream& ost, const ActionRegistry& m);42 43 39 #endif /* ACTIONREGISTRY_HPP_ */ -
src/Descriptors/MoleculeNameDescriptor.cpp
r677e13 ra7b777c 30 30 31 31 molecule *MoleculeNameDescriptor_impl::find(){ 32 World::MoleculeSet molecules = getMolecules();32 World::MoleculeSet &molecules = getMolecules(); 33 33 World::MoleculeSet::iterator res = molecules.begin(); 34 34 for (; res != molecules.end(); res++) -
src/Descriptors/MoleculePtrDescriptor.cpp
r677e13 ra7b777c 34 34 35 35 molecule *MoleculePtrDescriptor_impl::find(){ 36 World::MoleculeSet molecules = getMolecules();36 World::MoleculeSet &molecules = getMolecules(); 37 37 World::MoleculeSet::iterator res = molecules.find(ptr->getId()); 38 38 return (res!=molecules.end())?((*res).second):0; -
src/Patterns/ObservedContainer_impl.hpp
r677e13 ra7b777c 17 17 18 18 template <class Container> 19 inline ObservedContainer<Container>::ObservedContainer(const ObservedContainer &src) :19 inline ObservedContainer<Container>::ObservedContainer(const ObservedContainer<Container> &src) : 20 20 content(src.content), 21 21 obs(src.obs) … … 29 29 inline 30 30 ObservedContainer<Container>& 31 ObservedContainer<Container>::operator=(const ObservedContainer &rhs){31 ObservedContainer<Container>::operator=(const ObservedContainer<Container> &rhs){ 32 32 content=rhs.content; 33 33 return *this; -
src/UIElements/CommandLineUI/CommandLineWindow.cpp
r677e13 ra7b777c 44 44 for (std::list<std::string>::iterator CommandRunner = CommandLineParser::getInstance().SequenceOfActions.begin(); CommandRunner != CommandLineParser::getInstance().SequenceOfActions.end(); ++CommandRunner) { 45 45 cout << "Checking presence of " << *CommandRunner << ": "; 46 if (ActionRegistry::getInstance().isAction ByNamePresent(*CommandRunner)) {46 if (ActionRegistry::getInstance().isActionPresentByName(*CommandRunner)) { 47 47 cout << "calling " << *CommandRunner << endl; 48 48 ActionRegistry::getInstance().getActionByName(*CommandRunner)->call();
Note:
See TracChangeset
for help on using the changeset viewer.