source: src/Actions/ActionTraits.cpp@ 34fbb3

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
Last change on this file since 34fbb3 was ce7fdc, checked in by Frederik Heber <heber@…>, 13 years ago

HUGE: All Action-related codes resides now in namespace MoleCuilder.

  • removed all namespace std in Actions..., replaced by MoleCuilder.
  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * ActionTraits.cpp
10 *
11 * Created on: Oct 26, 2010
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "CodePatterns/MemDebug.hpp"
21
22#include "Actions/ActionTraits.hpp"
23
24#include "CodePatterns/Assert.hpp"
25
26#include <iostream>
27#include <sstream>
28#include <string>
29#include <typeinfo>
30
31using namespace MoleCuilder;
32
33/** Copy constructor for base class ActionTraits.
34 * \param &_Traits source ActionTraits class to copy
35 */
36ActionTraits::ActionTraits(const std::string &_token) :
37 OptionTrait(_token,
38 &typeid(void),
39 "this is an invisible action",
40 "",
41 ""
42 )
43{
44 //std::cout << "ActionTraits::ActionTraits(string &) with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
45}
46
47/** Copy constructor for base class ActionTraits.
48 * we have to make our own copy in order to avoid references and deep-copy everything.
49 * \param &_Traits source ActionTraits class to copy
50 */
51ActionTraits::ActionTraits(const ActionTraits &_Traits) :
52 OptionTrait(_Traits.getName(),
53 _Traits.getType(),
54 _Traits.getDescription(),
55 _Traits.hasDefaultValue() ? _Traits.getDefaultValue() : "",
56 _Traits.hasShortForm() ? _Traits.getShortForm() : ""
57 ),
58 MenuTitle(_Traits.MenuTitle),
59 MenuPosition(_Traits.MenuPosition)
60{
61 for (options_const_iterator iter = _Traits.Options.begin(); iter != _Traits.Options.end(); ++iter) {
62 Options.insert(
63 std::pair< std::string, OptionTrait *> (
64 iter->first,
65 new OptionTrait(iter->second->getName(),iter->second->getType(),iter->second->getDescription(), iter->second->getDefaultValue(), iter->second->getShortForm())
66 )
67 );
68 }
69 //std::cout << "ActionTraits::ActionTraits(ActionTraits &) with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
70}
71
72/** Copy constructor for base class ActionTraits.
73 * we have to make our own copy in order to avoid references and deep-copy everything.
74 * \param &_Traits source OptionTrait class to copy
75 */
76ActionTraits::ActionTraits(const OptionTrait &_Traits, const std::string _MenuTitle, const int _MenuPosition) :
77 OptionTrait(_Traits),
78 MenuTitle(_MenuTitle),
79 MenuPosition(_MenuPosition)
80{
81 //std::cout << "ActionTraits::ActionTraits(OptionTrait &) with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
82}
83
84/** Constructor for base class ActionTraits.
85 * Deletes all present Options.
86 */
87ActionTraits::~ActionTraits()
88{
89 for (options_iterator iter = Options.begin(); !Options.empty(); iter = Options.begin()) {
90 delete (iter->second);
91 Options.erase(iter);
92 }
93}
94
95
96/** Returns menu title for this ActionTrait.
97 * \return ActionTraits::MenuTitle as std::string
98 */
99const std::string& ActionTraits::getMenuName() const
100{
101 return MenuTitle;
102}
103
104/** Returns menu title for this ActionTrait.
105 * \return ActionTraits::MenuPosition as std::string
106 */
107int ActionTraits::getMenuPosition() const
108{
109 return MenuPosition;
110}
111
112/** Returns Description for the given option of this ActionTrait.
113 * \param &token token of option
114 * \return reference to OptionTrait
115 */
116OptionTrait const & ActionTraits::getOption(const std::string &token) const
117{
118 ASSERT(Options.find(token) != Options.end(),
119 "ActionTraits::getOption() - Option not found!");
120 return *(Options.find(token)->second);
121}
122
123/** States whether given option (token) is present or not.
124 * \param &token name of option
125 * \return true - option present, false - not
126 */
127bool ActionTraits::hasOption(const std::string &token) const
128{
129 return (Options.find(token) != Options.end());
130}
131
132/** States whether this Action has options at all.
133 * \return true - options present, false - no options
134 */
135bool ActionTraits::hasOptions() const
136{
137 return (Options.begin() != Options.end());
138}
139
140/** Forward iterator from beginning of list of options.
141 * \return iterator
142 */
143ActionTraits::options_iterator ActionTraits::getBeginIter()
144{
145 return Options.begin();
146}
147
148/** Forward iterator at end of list of options.
149 * \return iterator
150 */
151ActionTraits::options_iterator ActionTraits::getEndIter()
152{
153 return Options.end();
154}
155
156/** Constant forward iterator from beginning of list of options.
157 * \return constant iterator
158 */
159ActionTraits::options_const_iterator ActionTraits::getBeginIter() const
160{
161 return Options.begin();
162}
163
164/** Constant forward iterator at end of list of options.
165 * \return constant iterator
166 */
167ActionTraits::options_const_iterator ActionTraits::getEndIter() const
168{
169 return Options.end();
170}
171
172
Note: See TracBrowser for help on using the repository browser.