00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef SACADO_SCALARPARAMETERLIBRARY_HPP
00033 #define SACADO_SCALARPARAMETERLIBRARY_HPP
00034
00035 #include "Sacado_ParameterLibraryBase.hpp"
00036 #include "Sacado_ScalarParameterFamily.hpp"
00037 #include "Sacado_ScalarParameterVector.hpp"
00038
00039 #include "Teuchos_TestForException.hpp"
00040
00041 namespace Sacado {
00042
00047 class ScalarParameterLibrary :
00048 public ParameterLibraryBase<ScalarParameterFamily, ScalarParameterEntry> {
00049
00050 public:
00051
00053 ScalarParameterLibrary() {}
00054
00056 virtual ~ScalarParameterLibrary() {}
00057
00059 void setRealValueForAllTypes(const std::string& name, double value);
00060
00062
00065 template <class ValueType>
00066 void setValueAsConstant(const std::string& name,
00067 const ValueType& value);
00068
00070
00073 template <class ValueType>
00074 void setValueAsIndependent(const std::string& name,
00075 const ValueType& value);
00076
00078 template <class ValueType>
00079 const ValueType& getValue(const std::string& name) const;
00080
00082 static ScalarParameterLibrary& getInstance() {
00083 static ScalarParameterLibrary instance;
00084 return instance;
00085 }
00086
00088
00091 void
00092 fillVector(const Teuchos::Array<std::string>& names,
00093 ScalarParameterVector& pv);
00094
00095 private:
00096
00098 ScalarParameterLibrary(const ScalarParameterLibrary&);
00099
00101 ScalarParameterLibrary& operator = (const ScalarParameterLibrary&);
00102
00103 };
00104
00105 }
00106
00107 template <class ValueType>
00108 void
00109 Sacado::ScalarParameterLibrary::
00110 setValueAsConstant(const std::string& name, const ValueType& value)
00111 {
00112 FamilyMap::iterator it = library.find(name);
00113 TEST_FOR_EXCEPTION(
00114 it == library.end(),
00115 std::logic_error,
00116 std::string("Sacado::ScalarParameterLibrary::setValueAsConstant(): ")
00117 + "Invalid parameter family " + name);
00118 (*it).second->setValueAsConstant(value);
00119 }
00120
00121 template <class ValueType>
00122 void
00123 Sacado::ScalarParameterLibrary::
00124 setValueAsIndependent(const std::string& name, const ValueType& value)
00125 {
00126 FamilyMap::iterator it = library.find(name);
00127 TEST_FOR_EXCEPTION(
00128 it == library.end(),
00129 std::logic_error,
00130 std::string("Sacado::ScalarParameterLibrary::setValueAsIndependent(): ")
00131 + "Invalid parameter family " + name);
00132 (*it).second->setValueAsIndependent(value);
00133 }
00134
00135 template <class ValueType>
00136 const ValueType&
00137 Sacado::ScalarParameterLibrary::
00138 getValue(const std::string& name) const
00139 {
00140 FamilyMap::const_iterator it = library.find(name);
00141 TEST_FOR_EXCEPTION(
00142 it == library.end(),
00143 std::logic_error,
00144 std::string("Sacado::ScalarParameterLibrary::getValue(): ")
00145 + "Invalid parameter family " + name);
00146 return (*it).second->getValue<ValueType>();
00147 }
00148
00149 #endif