30 #include "Teuchos_Assert.hpp"
32 template <
typename FamilyType,
typename EntryType>
38 template <
typename FamilyType,
typename EntryType>
44 template <
typename FamilyType,
typename EntryType>
50 typename FamilyMap::const_iterator it = library.find(name);
52 return (it != library.end());
55 template <
typename FamilyType,
typename EntryType>
56 template <
class EvalType>
62 typename FamilyMap::const_iterator it = library.find(name);
65 if (it == library.end())
69 return (*it).second->template hasType<EvalType>();
72 template <
typename FamilyType,
typename EntryType>
77 bool supports_analytic)
80 if (isParameter(name))
83 Teuchos::RCP<FamilyType> f =
84 Teuchos::rcp(
new FamilyType(name, supports_ad, supports_analytic));
85 library.insert(std::pair< std::string,
86 Teuchos::RCP<FamilyType> >(name, f));
91 template <
typename FamilyType,
typename EntryType>
92 template <
class EvalType>
97 const bool allow_overwrite)
100 typename FamilyMap::iterator it = library.find(name);
103 TEUCHOS_TEST_FOR_EXCEPTION(it == library.end(),
105 std::string(
"Sacado::ParameterLibraryBase::addEntry(): ")
106 +
"Parameter family " + name
107 +
" is not in the library");
110 return (*it).second->template addEntry<EvalType>(entry, allow_overwrite);
113 template <
typename FamilyType,
typename EntryType>
114 template <
class EvalType>
115 Teuchos::RCP< typename Sacado::mpl::apply<EntryType,EvalType>::type >
120 typename FamilyMap::iterator it = library.find(name);
123 TEUCHOS_TEST_FOR_EXCEPTION(it == library.end(),
125 std::string(
"Sacado::ParameterLibraryBase::getEntry(): ")
126 +
"Parameter family " + name
127 +
" is not in the library");
130 return (*it).second->template getEntry<EvalType>();
133 template <
typename FamilyType,
typename EntryType>
134 template <
class EvalType>
135 Teuchos::RCP< const typename Sacado::mpl::apply<EntryType,EvalType>::type >
137 getEntry(
const std::string& name)
const
140 typename FamilyMap::const_iterator it = library.find(name);
143 TEUCHOS_TEST_FOR_EXCEPTION(it == library.end(),
145 std::string(
"Sacado::ParameterLibraryBase::getEntry(): ")
146 +
"Parameter family " + name
147 +
" is not in the library");
150 return (*it).second->template getEntry<EvalType>();
153 template <
typename FamilyType,
typename EntryType>
154 template <
typename BaseValueType>
157 fillVector(
const Teuchos::Array<std::string>& names,
158 const Teuchos::Array<BaseValueType>& values,
161 typename FamilyMap::iterator it;
164 for (
unsigned int i=0; i<names.size(); i++) {
165 it = library.find(names[i]);
166 TEUCHOS_TEST_FOR_EXCEPTION(
169 std::string(
"Sacado::ParameterLibraryBase::fillVector(): ")
170 +
"Invalid parameter family " + names[i]);
171 pv.
addParam((*it).second, values[i]);
175 template <
typename FamilyType,
typename EntryType>
178 print(std::ostream& os,
bool print_values)
const
180 os <<
"Library of all registered parameters:" << std::endl;
181 typename FamilyMap::const_iterator it = this->library.begin();
182 for (; it != this->library.end(); ++it) {
183 (*it).second->print(os, print_values);