Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_ParameterLibraryBase.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Sacado Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
25 // (etphipp@sandia.gov).
26 //
27 // ***********************************************************************
28 // @HEADER
29 
30 #ifndef SACADO_PARAMETERLIBRARYBASE_HPP
31 #define SACADO_PARAMETERLIBRARYBASE_HPP
32 
33 #include <iostream>
34 
35 #include "Teuchos_Array.hpp"
36 
39 #include "Sacado_mpl_apply.hpp"
40 
41 namespace Sacado {
42 
43  using std::string;
44 
49  template <typename FamilyType, typename EntryType>
51 
52  protected:
53 
55  typedef std::map<string, Teuchos::RCP<FamilyType> > FamilyMap;
56 
57  public:
58 
60  typedef typename FamilyMap::iterator iterator;
61 
63  typedef typename FamilyMap::const_iterator const_iterator;
64 
67 
69  virtual ~ParameterLibraryBase();
70 
72  bool isParameter(const std::string& name) const;
73 
75  template <typename EvalType>
76  bool isParameterForType(const std::string& name) const;
77 
79 
83  bool addParameterFamily(const std::string& name, bool supports_ad,
84  bool supports_analytic);
85 
86 
88 
93  template <typename EvalType>
94  bool addEntry(const std::string& name,
96  const bool allow_overwrite = false);
97 
99  template <typename EvalType>
101  getEntry(const std::string& name);
102 
104  template <typename EvalType>
106  getEntry(const std::string& name) const;
107 
109  unsigned int size() const { return library.size(); }
110 
112  iterator begin() { return library.begin(); }
113 
115  const_iterator begin() const { return library.begin(); }
116 
118  iterator end() { return library.end(); }
119 
121  const_iterator end() const { return library.end(); }
122 
124  template <typename BaseValueType>
125  void
127  const Teuchos::Array<BaseValueType>& values,
129 
131 
135  void print(std::ostream& os, bool print_values = false) const;
136 
138  void clear() { library = FamilyMap(); }
139 
140  private:
141 
144 
147 
148  protected:
149 
152  };
153 
154  template <typename FamilyType, typename EntryType>
155  std::ostream&
156  operator << (std::ostream& os,
158  {
159  pl.print(os);
160  return os;
161  }
162 }
163 
164 // Include template definitions
166 
167 #endif
std::ostream & operator<<(std::ostream &os, const ParameterLibraryBase< FamilyType, EntryType > &pl)
bool addParameterFamily(const std::string &name, bool supports_ad, bool supports_analytic)
Create a new parameter family.
FamilyMap::iterator iterator
Iterator typename.
Teuchos::RCP< typename Sacado::mpl::apply< EntryType, EvalType >::type > getEntry(const std::string &name)
Return parameter entry.
bool isParameterForType(const std::string &name) const
Determine if parameter of name name has type type.
std::map< string, Teuchos::RCP< FamilyType > > FamilyMap
Map of all parameter families.
bool addEntry(const std::string &name, const Teuchos::RCP< typename Sacado::mpl::apply< EntryType, EvalType >::type > &entry, const bool allow_overwrite=false)
Add a new parameter using custom entry.
void print(std::ostream &os, bool print_values=false) const
Print parameter library.
F::template apply< A1, A2, A3, A4, A5 >::type type
const_iterator begin() const
Iterator pointing at beginning of library.
void fillVector(const Teuchos::Array< std::string > &names, const Teuchos::Array< BaseValueType > &values, ParameterVectorBase< FamilyType, BaseValueType > &pv)
Fill a vector with the supplied parameter names and values.
iterator begin()
Iterator pointing at beginning of library.
Class to provide a centralized library for setting/retrieving numerical parameter values...
ParameterLibraryBase & operator=(const ParameterLibraryBase &)
Private to prohibit copying.
unsigned int size() const
Return number of parameters in library.
FamilyMap library
Scalar parameter library.
FamilyMap::const_iterator const_iterator
Const iterator typename.
A class to store the active parameters in a code in an ordered fashion, along with their &quot;base&quot; value...
bool isParameter(const std::string &name) const
Determine if parameter of name name is in the library.
iterator end()
Iterator pointing at end of library.
const_iterator end() const
Iterator pointing at end of library.