Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_ParameterListModifier.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Teuchos: Common Tools Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef TEUCHOS_ParameterListModifier_hpp_
43 #define TEUCHOS_ParameterListModifier_hpp_
44 
49 #include "Teuchos_Describable.hpp"
50 #include "Teuchos_ParameterEntryValidator.hpp"
51 #include "Teuchos_map.hpp"
52 #include "Teuchos_RCP.hpp"
53 namespace Teuchos {
54 
55 
56 #ifndef DOXYGEN_SHOULD_SKIP_THIS
57 class ParameterList;
58 #endif
59 
68 class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT ParameterListModifier : public Describable {
69 
70 public:
71 
73 
74 
76  ParameterListModifier() = default;
77 
79  ParameterListModifier(const std::string &name);
80 
82  virtual ~ParameterListModifier();
83 
85 
87  ParameterListModifier& setName( const std::string &name );
89 
91 
93  inline const std::string& getName() const{
95  return name_;
96  }
97 
99 
111  void printDoc(
112  std::string const& docString,
113  std::ostream &out
114  ) const;
115 
116 
129  Array<std::string> findMatchingBaseNames(const ParameterList &paramList,
130  const std::string &baseName, const bool &findParameters = true,
131  const bool &findSublists = true) const;
132 
144  virtual void modify(ParameterList &paramList, ParameterList &validParamList) const {};
145 
146 
158  virtual void reconcile(ParameterList &paramList) const {};
159 
160 
173  int expandParameters(const std::string &paramTemplateName, ParameterList &paramList,
174  ParameterList &validParamList,
175  const Array<std::string> &excludeParameters=Array<std::string>()) const;
176 
177 
190  int expandSublists(const std::string &sublistTemplateName, ParameterList &paramList,
191  ParameterList &validParamList,
192  const Array<std::string> &excludeSublists=Array<std::string>()) const;
193 
194 
206  int setDefaultsInSublists(const std::string &paramName, ParameterList &paramList,
207  const Array<std::string> &sublistNames, const bool removeParam = true) const;
208 
209 
223  int expandSublistsUsingBaseName(const std::string &baseName, ParameterList &paramList,
224  ParameterList &validParamList, const bool &allowBaseName = true) const;
225 
226 
227 protected:
228  std::string name_ = "ANONYMOUS";
229 
230 };
231 
235 inline bool operator==(const ParameterListModifier& plm1, const ParameterListModifier& plm2)
236 {
237  return (
238  plm1.getName() == plm2.getName()
239  && typeid(plm1) == typeid(plm2)
240  );
241 }
242 
246 inline bool operator!=(const ParameterListModifier& plm1, const ParameterListModifier& plm2)
247 {
248  return !( plm1 == plm2 );
249 }
250 
251 // /////////////////////////////////////////////////////
252 // Inline and Template Function Definitions
253 
254 
255 inline
257 {
258  name_ = name_in;
259  return *this;
260 }
261 
262 
263 } // end of Teuchos namespace
264 
265 #endif
bool operator==(const ParameterListModifier &plm1, const ParameterListModifier &plm2)
Returns true if two ParameterListModifier objects are equal.
const std::string & getName() const
Get the name of *this modifier.
Abstract interface for an object that can modify both a parameter list and the parameter list being u...
ParameterListModifier & setName(const std::string &name)
Set the name of *this modifier.
virtual void modify(ParameterList &paramList, ParameterList &validParamList) const
Modify a parameter list and/or the valid parameter list being used to validate it and throw std::exce...
A list of parameters of arbitrary type.
Provides std::map class for deficient platforms.
virtual void reconcile(ParameterList &paramList) const
Reconcile a parameter list and/or the valid parameter list being used to validate it and throw std::e...
Base class for all objects that can describe themselves.
Reference-counted pointer class and non-member templated function implementations.
bool operator!=(const ParameterListModifier &plm1, const ParameterListModifier &plm2)
Returns true if two ParameterListModifier objects are not equal.