source: src/Actions/ActionTraits.cpp@ aee2da

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 Candidate_v1.7.0 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 aee2da was b22179, checked in by Frederik Heber <heber@…>, 14 years ago

FIX: Removed OptionTrait's copy constructor as there are no pointers in it.

  • Property mode set to 100644
File size: 4.4 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) :
[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(
58 std::pair< std::string, OptionTrait *> (
59 iter->first,
[b22179]60 new OptionTrait(*iter->second)
[e4afb4]61 )
62 );
63 }
[c38826]64 //std::cout << "ActionTraits::ActionTraits(ActionTraits &) with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
[e4afb4]65}
[df32ee]66
[e4afb4]67/** Copy constructor for base class ActionTraits.
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 */
[b59da6]71ActionTraits::ActionTraits(const OptionTrait &_Traits, const std::string _MenuTitle, const int _MenuPosition) :
72 OptionTrait(_Traits),
73 MenuTitle(_MenuTitle),
74 MenuPosition(_MenuPosition)
[df32ee]75{
[c38826]76 //std::cout << "ActionTraits::ActionTraits(OptionTrait &) with " << getName() << ", type " << getTypeName() << " and description " << getDescription() << std::endl;
[df32ee]77}
78
[e4afb4]79/** Constructor for base class ActionTraits.
80 * Deletes all present Options.
[df32ee]81 */
[e4afb4]82ActionTraits::~ActionTraits()
[df32ee]83{
[e4afb4]84 for (options_iterator iter = Options.begin(); !Options.empty(); iter = Options.begin()) {
85 delete (iter->second);
86 Options.erase(iter);
87 }
[df32ee]88}
89
[e4afb4]90
[53be34]91/** Returns menu title for this ActionTrait.
92 * \return ActionTraits::MenuTitle as std::string
93 */
[e4afb4]94const std::string& ActionTraits::getMenuName() const
[53be34]95{
96 return MenuTitle;
97}
98
99/** Returns menu title for this ActionTrait.
100 * \return ActionTraits::MenuPosition as std::string
101 */
[b59da6]102int ActionTraits::getMenuPosition() const
[53be34]103{
104 return MenuPosition;
105}
106
107/** Returns Description for the given option of this ActionTrait.
[e4afb4]108 * \param &token token of option
109 * \return reference to OptionTrait
[53be34]110 */
[e4afb4]111OptionTrait const & ActionTraits::getOption(const std::string &token) const
[53be34]112{
[e4afb4]113 ASSERT(Options.find(token) != Options.end(),
114 "ActionTraits::getOption() - Option not found!");
115 return *(Options.find(token)->second);
[53be34]116}
117
[e4afb4]118/** States whether given option (token) is present or not.
119 * \param &token name of option
120 * \return true - option present, false - not
[df32ee]121 */
[e4afb4]122bool ActionTraits::hasOption(const std::string &token) const
[df32ee]123{
[e4afb4]124 return (Options.find(token) != Options.end());
[df32ee]125}
126
[e4afb4]127/** States whether this Action has options at all.
128 * \return true - options present, false - no options
[df32ee]129 */
[e4afb4]130bool ActionTraits::hasOptions() const
[df32ee]131{
[e4afb4]132 return (Options.begin() != Options.end());
[df32ee]133}
134
[53be34]135/** Forward iterator from beginning of list of options.
136 * \return iterator
137 */
138ActionTraits::options_iterator ActionTraits::getBeginIter()
139{
[e4afb4]140 return Options.begin();
[53be34]141}
142
143/** Forward iterator at end of list of options.
144 * \return iterator
145 */
146ActionTraits::options_iterator ActionTraits::getEndIter()
147{
[e4afb4]148 return Options.end();
[53be34]149}
150
151/** Constant forward iterator from beginning of list of options.
152 * \return constant iterator
153 */
154ActionTraits::options_const_iterator ActionTraits::getBeginIter() const
155{
[e4afb4]156 return Options.begin();
[53be34]157}
158
159/** Constant forward iterator at end of list of options.
160 * \return constant iterator
161 */
162ActionTraits::options_const_iterator ActionTraits::getEndIter() const
163{
[e4afb4]164 return Options.end();
[53be34]165}
166
167
Note: See TracBrowser for help on using the repository browser.