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
RevLine 
[df32ee]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
[d2b28f]15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
[ad011c]20#include "CodePatterns/MemDebug.hpp"
[d2b28f]21
[df32ee]22#include "Actions/ActionTraits.hpp"
23
[ad011c]24#include "CodePatterns/Assert.hpp"
[e4afb4]25
26#include <iostream>
27#include <sstream>
[df32ee]28#include <string>
[e4afb4]29#include <typeinfo>
[df32ee]30
[ce7fdc]31using namespace MoleCuilder;
32
[e4afb4]33/** Copy constructor for base class ActionTraits.
34 * \param &_Traits source ActionTraits class to copy
[df32ee]35 */
[e4afb4]36ActionTraits::ActionTraits(const std::string &_token) :
37 OptionTrait(_token,
38 &typeid(void),
39 "this is an invisible action",
40 "",
41 ""
42 )
43{
[c38826]44 //std::cout << "ActionTraits::ActionTraits(string &) with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
[e4afb4]45}
[df32ee]46
[e4afb4]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
[df32ee]50 */
[e4afb4]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() : ""
[b59da6]57 ),
58 MenuTitle(_Traits.MenuTitle),
59 MenuPosition(_Traits.MenuPosition)
[e4afb4]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 }
[c38826]69 //std::cout << "ActionTraits::ActionTraits(ActionTraits &) with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
[e4afb4]70}
[df32ee]71
[e4afb4]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
[df32ee]75 */
[b59da6]76ActionTraits::ActionTraits(const OptionTrait &_Traits, const std::string _MenuTitle, const int _MenuPosition) :
77 OptionTrait(_Traits),
78 MenuTitle(_MenuTitle),
79 MenuPosition(_MenuPosition)
[df32ee]80{
[c38826]81 //std::cout << "ActionTraits::ActionTraits(OptionTrait &) with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
[df32ee]82}
83
[e4afb4]84/** Constructor for base class ActionTraits.
85 * Deletes all present Options.
[df32ee]86 */
[e4afb4]87ActionTraits::~ActionTraits()
[df32ee]88{
[e4afb4]89 for (options_iterator iter = Options.begin(); !Options.empty(); iter = Options.begin()) {
90 delete (iter->second);
91 Options.erase(iter);
92 }
[df32ee]93}
94
[e4afb4]95
[53be34]96/** Returns menu title for this ActionTrait.
97 * \return ActionTraits::MenuTitle as std::string
98 */
[e4afb4]99const std::string& ActionTraits::getMenuName() const
[53be34]100{
101 return MenuTitle;
102}
103
104/** Returns menu title for this ActionTrait.
105 * \return ActionTraits::MenuPosition as std::string
106 */
[b59da6]107int ActionTraits::getMenuPosition() const
[53be34]108{
109 return MenuPosition;
110}
111
112/** Returns Description for the given option of this ActionTrait.
[e4afb4]113 * \param &token token of option
114 * \return reference to OptionTrait
[53be34]115 */
[e4afb4]116OptionTrait const & ActionTraits::getOption(const std::string &token) const
[53be34]117{
[e4afb4]118 ASSERT(Options.find(token) != Options.end(),
119 "ActionTraits::getOption() - Option not found!");
120 return *(Options.find(token)->second);
[53be34]121}
122
[e4afb4]123/** States whether given option (token) is present or not.
124 * \param &token name of option
125 * \return true - option present, false - not
[df32ee]126 */
[e4afb4]127bool ActionTraits::hasOption(const std::string &token) const
[df32ee]128{
[e4afb4]129 return (Options.find(token) != Options.end());
[df32ee]130}
131
[e4afb4]132/** States whether this Action has options at all.
133 * \return true - options present, false - no options
[df32ee]134 */
[e4afb4]135bool ActionTraits::hasOptions() const
[df32ee]136{
[e4afb4]137 return (Options.begin() != Options.end());
[df32ee]138}
139
[53be34]140/** Forward iterator from beginning of list of options.
141 * \return iterator
142 */
143ActionTraits::options_iterator ActionTraits::getBeginIter()
144{
[e4afb4]145 return Options.begin();
[53be34]146}
147
148/** Forward iterator at end of list of options.
149 * \return iterator
150 */
151ActionTraits::options_iterator ActionTraits::getEndIter()
152{
[e4afb4]153 return Options.end();
[53be34]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{
[e4afb4]161 return Options.begin();
[53be34]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{
[e4afb4]169 return Options.end();
[53be34]170}
171
172
Note: See TracBrowser for help on using the repository browser.