source: src/Actions/ActionTrait.cpp@ abae35

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 abae35 was 3139b2, checked in by Frederik Heber <heber@…>, 13 years ago

Renamed ActionTrait and ActionTraits.

  • the specialized Trait contains multiple OptionTraits, hence is now called ActionTrait_s_, where its base class (that just has the OptionTrait for itself) is called ActionTrait.
  • This caused many changes in other Action related files.
  • Property mode set to 100644
File size: 5.1 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/*
[3139b2]9 * ActionTrait.cpp
[df32ee]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
[3139b2]22#include "Actions/ActionTrait.hpp"
[df32ee]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
[3139b2]33/** Copy constructor for base class ActionTrait.
34 * \param &_Traits source ActionTrait class to copy
[df32ee]35 */
[3139b2]36ActionTrait::ActionTrait(const std::string &_token) :
[e4afb4]37 OptionTrait(_token,
38 &typeid(void),
39 "this is an invisible action",
40 "",
41 ""
42 )
43{
[3139b2]44 //std::cout << "ActionTrait::ActionTrait(string &) on instance " << this << " with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
[e4afb4]45}
[df32ee]46
[3139b2]47/** Copy constructor for base class ActionTrait.
[e4afb4]48 * we have to make our own copy in order to avoid references and deep-copy everything.
[3139b2]49 * \param &_Traits source ActionTrait class to copy
[df32ee]50 */
[3139b2]51ActionTrait::ActionTrait(const ActionTrait &_Traits) :
[b22179]52 OptionTrait(_Traits),
[b59da6]53 MenuTitle(_Traits.MenuTitle),
54 MenuPosition(_Traits.MenuPosition)
[e4afb4]55{
56 for (options_const_iterator iter = _Traits.Options.begin(); iter != _Traits.Options.end(); ++iter) {
57 Options.insert(
[dad802]58 std::make_pair(
[e4afb4]59 iter->first,
[b22179]60 new OptionTrait(*iter->second)
[e4afb4]61 )
62 );
63 }
[3139b2]64 //std::cout << "ActionTrait::ActionTrait(ActionTrait &) on instance " << this << " with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
[e4afb4]65}
[df32ee]66
[3139b2]67/** Copy constructor for base class ActionTrait.
[e4afb4]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
[df32ee]70 */
[3139b2]71ActionTrait::ActionTrait(const OptionTrait &_Traits, const std::string _MenuTitle, const int _MenuPosition) :
[b59da6]72 OptionTrait(_Traits),
73 MenuTitle(_MenuTitle),
74 MenuPosition(_MenuPosition)
[df32ee]75{
[3139b2]76 //std::cout << "ActionTrait::ActionTrait(OptionTrait &) on instance " << this << " with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
[df32ee]77}
78
[3139b2]79/** Constructor for base class ActionTrait.
[e4afb4]80 * Deletes all present Options.
[df32ee]81 */
[3139b2]82ActionTrait::~ActionTrait()
[df32ee]83{
[3139b2]84 //std::cout << "ActionTrait::~ActionTrait() on instance " << this << " with name " << getName() << " called." << std::endl;
[dad802]85 for (options_iterator iter = Options.begin(); iter != Options.end(); ++iter) {
[3139b2]86 //std::cout << "ActionTrait::~ActionTrait() removes option instance " << iter->second << " with name " << iter->first << "." << std::endl;
[dad802]87 delete iter->second;
[e4afb4]88 }
[dad802]89 Options.clear();
[df32ee]90}
91
[e4afb4]92
[53be34]93/** Returns menu title for this ActionTrait.
[3139b2]94 * \return ActionTrait::MenuTitle as std::string
[53be34]95 */
[3139b2]96const std::string& ActionTrait::getMenuName() const
[53be34]97{
98 return MenuTitle;
99}
100
101/** Returns menu title for this ActionTrait.
[3139b2]102 * \return ActionTrait::MenuPosition as std::string
[53be34]103 */
[3139b2]104int ActionTrait::getMenuPosition() const
[53be34]105{
106 return MenuPosition;
107}
108
109/** Returns Description for the given option of this ActionTrait.
[e4afb4]110 * \param &token token of option
111 * \return reference to OptionTrait
[53be34]112 */
[3139b2]113OptionTrait const & ActionTrait::getOption(const std::string &token) const
[53be34]114{
[e4afb4]115 ASSERT(Options.find(token) != Options.end(),
[3139b2]116 "ActionTrait::getOption() - Option not found!");
[e4afb4]117 return *(Options.find(token)->second);
[53be34]118}
119
[e4afb4]120/** States whether given option (token) is present or not.
121 * \param &token name of option
122 * \return true - option present, false - not
[df32ee]123 */
[3139b2]124bool ActionTrait::hasOption(const std::string &token) const
[df32ee]125{
[e4afb4]126 return (Options.find(token) != Options.end());
[df32ee]127}
128
[e4afb4]129/** States whether this Action has options at all.
130 * \return true - options present, false - no options
[df32ee]131 */
[3139b2]132bool ActionTrait::hasOptions() const
[df32ee]133{
[e4afb4]134 return (Options.begin() != Options.end());
[df32ee]135}
136
[53be34]137/** Forward iterator from beginning of list of options.
138 * \return iterator
139 */
[3139b2]140ActionTrait::options_iterator ActionTrait::getBeginIter()
[53be34]141{
[e4afb4]142 return Options.begin();
[53be34]143}
144
145/** Forward iterator at end of list of options.
146 * \return iterator
147 */
[3139b2]148ActionTrait::options_iterator ActionTrait::getEndIter()
[53be34]149{
[e4afb4]150 return Options.end();
[53be34]151}
152
153/** Constant forward iterator from beginning of list of options.
154 * \return constant iterator
155 */
[3139b2]156ActionTrait::options_const_iterator ActionTrait::getBeginIter() const
[53be34]157{
[e4afb4]158 return Options.begin();
[53be34]159}
160
161/** Constant forward iterator at end of list of options.
162 * \return constant iterator
163 */
[3139b2]164ActionTrait::options_const_iterator ActionTrait::getEndIter() const
[53be34]165{
[e4afb4]166 return Options.end();
[53be34]167}
168
[d41313]169/** Output operator for ActionTrait.
170 *
171 * \param &out stream to output to
172 */
[3139b2]173std::ostream &operator<<(std::ostream &out, const ActionTrait &a)
[d41313]174{
175 out << "ActionTrait(" << &a << ") with " << static_cast<const OptionTrait &>(a) << " has the following options: " << std::endl;
[3139b2]176 for (ActionTrait::options_const_iterator iter = a.getBeginIter();
[d41313]177 iter != a.getEndIter();
178 ++iter) {
179 out << "\t - " << *iter->second << ")" << std::endl;
180 }
181 return out;
182}
[53be34]183
Note: See TracBrowser for help on using the repository browser.