source: src/Actions/ActionTrait.cpp@ aec098

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 aec098 was 955b91, checked in by Frederik Heber <heber@…>, 13 years ago

FIX: Removed using namespace std in Vector.hpp.

  • this caused some follow-up problems in other LinearAlgebra modules,
mostly stuff from iostream not having std
prefix then.
this also caused more of them in MoleCuilder modules, mostly due to string,
stringstream, and numeric_limits with std
prefix.
  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * ActionTrait.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/ActionTrait.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 ActionTrait.
34 * \param &_Traits source ActionTrait class to copy
35 */
36ActionTrait::ActionTrait(const std::string &_token) :
37 OptionTrait(_token,
38 &typeid(void),
39 "this is an invisible action",
40 "",
41 ""
42 )
43{
44 //std::cout << "ActionTrait::ActionTrait(std::string &) on instance " << this << " with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
45}
46
47/** Copy constructor for base class ActionTrait.
48 * we have to make our own copy in order to avoid references and deep-copy everything.
49 * \param &_Traits source ActionTrait class to copy
50 */
51ActionTrait::ActionTrait(const ActionTrait &_Traits) :
52 OptionTrait(_Traits),
53 MenuTitle(_Traits.MenuTitle),
54 MenuPosition(_Traits.MenuPosition)
55{
56 for (options_const_iterator iter = _Traits.Options.begin(); iter != _Traits.Options.end(); ++iter) {
57 Options.insert(
58 std::make_pair(
59 iter->first,
60 new OptionTrait(*iter->second)
61 )
62 );
63 }
64 //std::cout << "ActionTrait::ActionTrait(ActionTrait &) on instance " << this << " with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
65}
66
67/** Copy constructor for base class ActionTrait.
68 * we have to make our own copy in order to avoid references and deep-copy everything.
69 * \param &_Traits source OptionTrait class to copy
70 */
71ActionTrait::ActionTrait(const OptionTrait &_Traits, const std::string _MenuTitle, const int _MenuPosition) :
72 OptionTrait(_Traits),
73 MenuTitle(_MenuTitle),
74 MenuPosition(_MenuPosition)
75{
76 //std::cout << "ActionTrait::ActionTrait(OptionTrait &) on instance " << this << " with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
77}
78
79/** Constructor for base class ActionTrait.
80 * Deletes all present Options.
81 */
82ActionTrait::~ActionTrait()
83{
84 //std::cout << "ActionTrait::~ActionTrait() on instance " << this << " with name " << getName() << " called." << std::endl;
85 for (options_iterator iter = Options.begin(); iter != Options.end(); ++iter) {
86 //std::cout << "ActionTrait::~ActionTrait() removes option instance " << iter->second << " with name " << iter->first << "." << std::endl;
87 delete iter->second;
88 }
89 Options.clear();
90}
91
92
93/** Returns menu title for this ActionTrait.
94 * \return ActionTrait::MenuTitle as std::string
95 */
96const std::string& ActionTrait::getMenuName() const
97{
98 return MenuTitle;
99}
100
101/** Returns menu title for this ActionTrait.
102 * \return ActionTrait::MenuPosition as std::string
103 */
104int ActionTrait::getMenuPosition() const
105{
106 return MenuPosition;
107}
108
109/** Returns Description for the given option of this ActionTrait.
110 * \param &token token of option
111 * \return reference to OptionTrait
112 */
113OptionTrait const & ActionTrait::getOption(const std::string &token) const
114{
115 ASSERT(Options.find(token) != Options.end(),
116 "ActionTrait::getOption() - Option not found!");
117 return *(Options.find(token)->second);
118}
119
120/** States whether given option (token) is present or not.
121 * \param &token name of option
122 * \return true - option present, false - not
123 */
124bool ActionTrait::hasOption(const std::string &token) const
125{
126 return (Options.find(token) != Options.end());
127}
128
129/** States whether this Action has options at all.
130 * \return true - options present, false - no options
131 */
132bool ActionTrait::hasOptions() const
133{
134 return (Options.begin() != Options.end());
135}
136
137/** Forward iterator from beginning of list of options.
138 * \return iterator
139 */
140ActionTrait::options_iterator ActionTrait::getBeginIter()
141{
142 return Options.begin();
143}
144
145/** Forward iterator at end of list of options.
146 * \return iterator
147 */
148ActionTrait::options_iterator ActionTrait::getEndIter()
149{
150 return Options.end();
151}
152
153/** Constant forward iterator from beginning of list of options.
154 * \return constant iterator
155 */
156ActionTrait::options_const_iterator ActionTrait::getBeginIter() const
157{
158 return Options.begin();
159}
160
161/** Constant forward iterator at end of list of options.
162 * \return constant iterator
163 */
164ActionTrait::options_const_iterator ActionTrait::getEndIter() const
165{
166 return Options.end();
167}
168
169/** Output operator for ActionTrait.
170 *
171 * \param &out stream to output to
172 */
173std::ostream &operator<<(std::ostream &out, const ActionTrait &a)
174{
175 out << "ActionTrait(" << &a << ") with " << static_cast<const OptionTrait &>(a) << " has the following options: " << std::endl;
176 for (ActionTrait::options_const_iterator iter = a.getBeginIter();
177 iter != a.getEndIter();
178 ++iter) {
179 out << "\t - " << *iter->second << ")" << std::endl;
180 }
181 return out;
182}
183
Note: See TracBrowser for help on using the repository browser.