Ignore:
Timestamp:
May 31, 2012, 1:25:03 PM (13 years ago)
Author:
Michael Ankele <ankele@…>
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)
Message:

added string functions to ValueInterface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parameters/DiscreteValue_impl.hpp

    r30ebdd r047cad  
    5353bool DiscreteValue<T>::isValid(const T & _value) const
    5454{
    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  }
    5663}
    5764
     
    8188{
    8289  ASSERT(ValueSet,
    83       "DiscreteValue<T>::get() - requesting unset value.");
    84   return getValue();
     90      "DiscreteValue<>::get() - value has never been set.");
     91  return ValidValues[value];
    8592}
    8693
     
    9299void DiscreteValue<T>::set(const T & _value)
    93100{
    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;
    95107}
    96108
     
    128140void DiscreteValue<T>::appendValidValue(const T &_value)
    129141{
    130   ASSERT(!isValidValue(_value),
     142  ASSERT(!isValid(_value),
    131143      "DiscreteValue<>::appendValidValue() - value "+toString(_value)+" is already among the valid");
    132144  ValidValues.push_back(_value);
     
    150162 */
    151163template <class T>
    152 void DiscreteValue<T>::setValue(const T &_value)
    153 {
    154   const size_t index = findIndexOfValue(_value);
     164void DiscreteValue<T>::setAsString(const std::string _value)
     165{
     166  /*const size_t index = findIndexOfValue(_value);
    155167  ASSERT(index != (size_t)-1,
    156168      "DiscreteValue<>::set() - value "+toString(_value)+" is not valid.");
    157169  if (!ValueSet)
    158170    ValueSet = true;
    159   value = index;
     171  value = index;*/
    160172}
    161173
     
    167179 */
    168180template <class T>
    169 const T & DiscreteValue<T>::getValue() const
     181const std::string DiscreteValue<T>::getAsString() const
    170182{
    171183  ASSERT(ValueSet,
    172184      "DiscreteValue<>::get() - value has never been set.");
    173   return ValidValues[value];
     185  return toString(ValidValues[value]);
    174186}
    175187
     
    179191 */
    180192template <class T>
    181 bool DiscreteValue<T>::isValidValue(const T &_value) const
    182 {
    183   typename ValidRange::const_iterator iter = std::find(ValidValues.begin(), ValidValues.end(), _value);
     193bool DiscreteValue<T>::isValidAsString(const std::string _value) const
     194{
     195  /*typename ValidRange::const_iterator iter = std::find(ValidValues.begin(), ValidValues.end(), _value);
    184196  if (iter != ValidValues.end()) {
    185197    //std::cout << "Found " << _value << ":" << *iter << std::endl;
     
    188200    //std::cout << "Did not find " << _value << "." << std::endl;
    189201    return false;
    190   }
     202  }*/
     203  return true;
    191204}
    192205
Note: See TracChangeset for help on using the changeset viewer.