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 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_PARAMETERLIBRARYBASE_HPP
11 #define SACADO_PARAMETERLIBRARYBASE_HPP
12 
13 #include <iostream>
14 
15 #include "Teuchos_Array.hpp"
16 
19 #include "Sacado_mpl_apply.hpp"
20 
21 namespace Sacado {
22 
23  using std::string;
24 
29  template <typename FamilyType, typename EntryType>
31 
32  protected:
33 
35  typedef std::map<string, Teuchos::RCP<FamilyType> > FamilyMap;
36 
37  public:
38 
40  typedef typename FamilyMap::iterator iterator;
41 
43  typedef typename FamilyMap::const_iterator const_iterator;
44 
47 
49  virtual ~ParameterLibraryBase();
50 
52  bool isParameter(const std::string& name) const;
53 
55  template <typename EvalType>
56  bool isParameterForType(const std::string& name) const;
57 
59 
63  bool addParameterFamily(const std::string& name, bool supports_ad,
64  bool supports_analytic);
65 
66 
68 
73  template <typename EvalType>
74  bool addEntry(const std::string& name,
76  const bool allow_overwrite = false);
77 
79  template <typename EvalType>
81  getEntry(const std::string& name);
82 
84  template <typename EvalType>
86  getEntry(const std::string& name) const;
87 
89  unsigned int size() const { return library.size(); }
90 
92  iterator begin() { return library.begin(); }
93 
95  const_iterator begin() const { return library.begin(); }
96 
98  iterator end() { return library.end(); }
99 
101  const_iterator end() const { return library.end(); }
102 
104  template <typename BaseValueType>
105  void
107  const Teuchos::Array<BaseValueType>& values,
109 
111 
115  void print(std::ostream& os, bool print_values = false) const;
116 
118  void clear() { library = FamilyMap(); }
119 
120  private:
121 
124 
127 
128  protected:
129 
132  };
133 
134  template <typename FamilyType, typename EntryType>
135  std::ostream&
136  operator << (std::ostream& os,
138  {
139  pl.print(os);
140  return os;
141  }
142 }
143 
144 // Include template definitions
146 
147 #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.