Changeset 047cad for src/Parameters/DiscreteValue_impl.hpp
- Timestamp:
- May 31, 2012, 1:25:03 PM (13 years ago)
- Branches:
- 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
- Children:
- 9b5eb0
- Parents:
- 30ebdd
- git-author:
- Michael Ankele <ankele@…> (04/16/12 12:30:32)
- git-committer:
- Michael Ankele <ankele@…> (05/31/12 13:25:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parameters/DiscreteValue_impl.hpp
r30ebdd r047cad 53 53 bool DiscreteValue<T>::isValid(const T & _value) const 54 54 { 55 return isValidValue(_value); 55 typename ValidRange::const_iterator iter = std::find(ValidValues.begin(), ValidValues.end(), _value); 56 if (iter != ValidValues.end()) { 57 //std::cout << "Found " << _value << ":" << *iter << std::endl; 58 return true; 59 } else { 60 //std::cout << "Did not find " << _value << "." << std::endl; 61 return false; 62 } 56 63 } 57 64 … … 81 88 { 82 89 ASSERT(ValueSet, 83 "DiscreteValue< T>::get() - requesting unset value.");84 return getValue();90 "DiscreteValue<>::get() - value has never been set."); 91 return ValidValues[value]; 85 92 } 86 93 … … 92 99 void DiscreteValue<T>::set(const T & _value) 93 100 { 94 setValue(_value); 101 const size_t index = findIndexOfValue(_value); 102 ASSERT(index != (size_t)-1, 103 "DiscreteValue<>::set() - value "+toString(_value)+" is not valid."); 104 if (!ValueSet) 105 ValueSet = true; 106 value = index; 95 107 } 96 108 … … 128 140 void DiscreteValue<T>::appendValidValue(const T &_value) 129 141 { 130 ASSERT(!isValid Value(_value),142 ASSERT(!isValid(_value), 131 143 "DiscreteValue<>::appendValidValue() - value "+toString(_value)+" is already among the valid"); 132 144 ValidValues.push_back(_value); … … 150 162 */ 151 163 template <class T> 152 void DiscreteValue<T>::set Value(const T &_value)153 { 154 const size_t index = findIndexOfValue(_value);164 void DiscreteValue<T>::setAsString(const std::string _value) 165 { 166 /*const size_t index = findIndexOfValue(_value); 155 167 ASSERT(index != (size_t)-1, 156 168 "DiscreteValue<>::set() - value "+toString(_value)+" is not valid."); 157 169 if (!ValueSet) 158 170 ValueSet = true; 159 value = index; 171 value = index;*/ 160 172 } 161 173 … … 167 179 */ 168 180 template <class T> 169 const T & DiscreteValue<T>::getValue() const181 const std::string DiscreteValue<T>::getAsString() const 170 182 { 171 183 ASSERT(ValueSet, 172 184 "DiscreteValue<>::get() - value has never been set."); 173 return ValidValues[value];185 return toString(ValidValues[value]); 174 186 } 175 187 … … 179 191 */ 180 192 template <class T> 181 bool DiscreteValue<T>::isValid Value(const T &_value) const182 { 183 typename ValidRange::const_iterator iter = std::find(ValidValues.begin(), ValidValues.end(), _value);193 bool DiscreteValue<T>::isValidAsString(const std::string _value) const 194 { 195 /*typename ValidRange::const_iterator iter = std::find(ValidValues.begin(), ValidValues.end(), _value); 184 196 if (iter != ValidValues.end()) { 185 197 //std::cout << "Found " << _value << ":" << *iter << std::endl; … … 188 200 //std::cout << "Did not find " << _value << "." << std::endl; 189 201 return false; 190 } 202 }*/ 203 return true; 191 204 } 192 205
Note:
See TracChangeset
for help on using the changeset viewer.