Changeset cf1d82 for src/Parameters
- Timestamp:
- Feb 13, 2013, 3:47:46 PM (12 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:
- 4d4ef8
- Parents:
- 6440c6
- git-author:
- Frederik Heber <heber@…> (01/10/13 16:02:33)
- git-committer:
- Frederik Heber <heber@…> (02/13/13 15:47:46)
- Location:
- src/Parameters
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parameters/Parameter.hpp
r6440c6 rcf1d82 19 19 20 20 #include "Value.hpp" 21 #include "ValueInterface.hpp" 21 22 #include "ParameterInterface.hpp" 22 23 … … 29 30 template <typename T> 30 31 class Parameter : 31 virtualpublic ParameterInterface,32 virtual public Value<T>32 public ParameterInterface, 33 public ValueInterface<T> 33 34 { 34 35 public: … … 44 45 virtual ~Parameter(); 45 46 46 // catch the following functions from Value<T> to add exception information 47 // wrap the following functions from ValueAsString to add exception information 48 bool isValidAsString(const std::string &_value) const throw(ParameterValidatorException); 47 49 const std::string getAsString() const throw(ParameterValueException); 50 void setAsString(const std::string &_value) throw(ParameterValueException); 51 52 // wrap the following functions from Value<T> to add exception information 53 bool isValid(const T &_value) const throw(ParameterValidatorException); 48 54 const T & get() const throw(ParameterValueException); 49 55 void set(const T & _value) throw(ParameterValueException); 50 void setAsString(const std::string &_value) throw(ParameterValueException); 56 bool isSet() const 57 { return value.isSet(); } 58 59 const Validator<T> & getValidator() const 60 { return value.getValidator(); } 61 Validator<T> & getValidator() 62 { return value.getValidator(); } 51 63 52 64 // comparator … … 59 71 //private: // TODO... 60 72 Parameter(); 73 74 private: 75 //!> contained value of this parameter 76 Value<T> value; 61 77 }; 62 78 -
src/Parameters/ParameterInterface.hpp
r6440c6 rcf1d82 24 24 */ 25 25 class ParameterInterface : 26 virtualpublic ValueAsString,26 public ValueAsString, 27 27 public Clone<ParameterInterface> 28 28 { -
src/Parameters/Parameter_impl.hpp
r6440c6 rcf1d82 21 21 Parameter<T>::Parameter(const Parameter<T> &instance) : 22 22 ParameterInterface(instance.getName()), 23 Value<T>(instance.getValidator())24 { 25 Value<T>::set(instance.Value<T>::get());23 value(instance.value.getValidator()) 24 { 25 value.set(instance.value.get()); 26 26 } 27 27 … … 32 32 Parameter<T>::Parameter() : 33 33 ParameterInterface("__no_name__"), 34 Value<T>()34 value() 35 35 {}; 36 36 … … 41 41 Parameter<T>::Parameter(const std::string &_name) : 42 42 ParameterInterface(_name), 43 Value<T>()43 value() 44 44 {}; 45 45 … … 52 52 Parameter<T>::Parameter(const std::string &_name, const T &_value) : 53 53 ParameterInterface(_name), 54 Value<T>()55 { 56 Value<T>::set(_value);54 value() 55 { 56 value.set(_value); 57 57 }; 58 58 … … 65 65 Parameter<T>::Parameter(const std::string &_name, const Validator<T> &_Validator) : 66 66 ParameterInterface(_name), 67 Value<T>(_Validator)67 value(_Validator) 68 68 {}; 69 69 … … 77 77 Parameter<T>::Parameter(const std::string &_name, const Validator<T> &_Validator, const T &_value) : 78 78 ParameterInterface(_name), 79 Value<T>(_Validator)80 { 81 Value<T>::set(_value);79 value(_Validator) 80 { 81 value.set(_value); 82 82 }; 83 83 … … 90 90 Parameter<T>::Parameter(const std::string &_name, const std::vector<T> &_ValidValues) : 91 91 ParameterInterface(_name), 92 Value<T>(_ValidValues)92 value(_ValidValues) 93 93 {}; 94 94 … … 102 102 Parameter<T>::Parameter(const std::string &_name, const std::vector<T> &_ValidValues, const T &_value) : 103 103 ParameterInterface(_name), 104 Value<T>(_ValidValues)105 { 106 Value<T>::set(_value);104 value(_ValidValues) 105 { 106 value.set(_value); 107 107 }; 108 108 … … 115 115 Parameter<T>::Parameter(const std::string &_name, const range<T> &_ValidRange) : 116 116 ParameterInterface(_name), 117 Value<T>(_ValidRange)117 value(_ValidRange) 118 118 {}; 119 119 … … 127 127 Parameter<T>::Parameter(const std::string &_name, const range<T> &_ValidRange, const T &_value) : 128 128 ParameterInterface(_name), 129 Value<T>(_ValidRange)130 { 131 Value<T>::set(_value);129 value(_ValidRange) 130 { 131 value.set(_value); 132 132 }; 133 133 … … 139 139 {}; 140 140 141 /** Catch call to Value<T>::getAsString() to add exception information. 141 /** Catch call to value.isValidAsString() to add exception information. 142 * 143 * @param _value value to set to 144 */ 145 template<typename T> 146 inline 147 bool Parameter<T>::isValidAsString(const std::string &_value) const throw(ParameterValidatorException) 148 { 149 try { 150 return value.isValidAsString(_value); 151 } catch(ParameterException &e) { 152 e << ParameterName(ParameterInterface::getName()); 153 throw; 154 } 155 } 156 157 158 /** Catch call to value.getAsString() to add exception information. 142 159 * 143 160 * @return parameter value as string … … 147 164 { 148 165 try { 149 return Value<T>::getAsString();150 } catch(ParameterException &e) { 151 e << ParameterName(ParameterInterface::getName()); 152 throw; 153 } 154 } 155 156 /** Catch call to Value<T>::get() to add exception information.166 return value.getAsString(); 167 } catch(ParameterException &e) { 168 e << ParameterName(ParameterInterface::getName()); 169 throw; 170 } 171 } 172 173 /** Catch call to value.isValid() to add exception information. 157 174 * 158 175 * @return parameter value as string 159 176 */ 160 177 template<typename T> 178 inline bool Parameter<T>::isValid(const T &_value) const throw(ParameterValidatorException) 179 { 180 try { 181 return value.isValid(_value); 182 } catch(ParameterException &e) { 183 e << ParameterName(ParameterInterface::getName()); 184 throw; 185 } 186 } 187 188 189 /** Catch call to value.get() to add exception information. 190 * 191 * @return parameter value as string 192 */ 193 template<typename T> 161 194 inline const T & Parameter<T>::get() const throw(ParameterValueException) 162 195 { 163 196 try { 164 return Value<T>::get();165 } catch(ParameterException &e) { 166 e << ParameterName(ParameterInterface::getName()); 167 throw; 168 } 169 } 170 171 /** Catch call to Value<T>::set() to add exception information.197 return value.get(); 198 } catch(ParameterException &e) { 199 e << ParameterName(ParameterInterface::getName()); 200 throw; 201 } 202 } 203 204 /** Catch call to value.set() to add exception information. 172 205 * 173 206 * @param _value value to set to … … 177 210 { 178 211 try { 179 Value<T>::set(_value);180 } catch(ParameterException &e) { 181 e << ParameterName(ParameterInterface::getName()); 182 throw; 183 } 184 } 185 186 /** Catch call to Value<T>::set() to add exception information.212 value.set(_value); 213 } catch(ParameterException &e) { 214 e << ParameterName(ParameterInterface::getName()); 215 throw; 216 } 217 } 218 219 /** Catch call to value.set() to add exception information. 187 220 * 188 221 * @param _value value to set to … … 192 225 { 193 226 try { 194 Value<T>::setAsString(_value);227 value.setAsString(_value); 195 228 } catch(ParameterException &e) { 196 229 e << ParameterName(ParameterInterface::getName()); … … 210 243 try { 211 244 status = status && 212 ( *dynamic_cast<const Value<T> *>(this) == dynamic_cast<const Value<T> &>(_instance));245 (value == _instance.value); 213 246 status = status && (ParameterInterface::getName() == _instance.ParameterInterface::getName()); 214 247 } catch(ParameterException &e) { … … 226 259 inline ParameterInterface* Parameter<T>::clone() const 227 260 { 228 Parameter<T> *instance = new Parameter<T>(ParameterInterface::getName(), Value<T>::getValidator());229 if ( Value<T>::ValueSet)230 instance->set( Value<T>::get());261 Parameter<T> *instance = new Parameter<T>(ParameterInterface::getName(), value.getValidator()); 262 if (value.ValueSet) 263 instance->set(value.get()); 231 264 return instance; 232 265 } -
src/Parameters/Value.hpp
r6440c6 rcf1d82 59 59 template <class T> 60 60 class Value : 61 virtualpublic ValueAsString,61 public ValueAsString, 62 62 public ValueInterface<T> 63 63 {
Note:
See TracChangeset
for help on using the changeset viewer.