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 
103  void printDoc(
104  std::string const& docString,
105  std::ostream &out
106  ) const;
107 
108 
121  Array<std::string> findMatchingBaseNames(const ParameterList &paramList,
122  const std::string &baseName, const bool &findParameters = true,
123  const bool &findSublists = true) const;
124 
136  virtual void modify(ParameterList &paramList, ParameterList &validParamList) const {};
137 
138 
150  virtual void reconcile(ParameterList &paramList) const {};
151 
152 
165  int expandParameters(const std::string &paramTemplateName, ParameterList &paramList,
166  ParameterList &validParamList,
167  const Array<std::string> &excludeParameters=Array<std::string>()) const;
168 
169 
182  int expandSublists(const std::string &sublistTemplateName, ParameterList &paramList,
183  ParameterList &validParamList,
184  const Array<std::string> &excludeSublists=Array<std::string>()) const;
185 
186 
198  int setDefaultsInSublists(const std::string &paramName, ParameterList &paramList,
199  const Array<std::string> &sublistNames, const bool removeParam = true) const;
200 
201 
215  int expandSublistsUsingBaseName(const std::string &baseName, ParameterList &paramList,
216  ParameterList &validParamList, const bool &allowBaseName = true) const;
217 
218 
219 protected:
220  std::string name_ = "ANONYMOUS";
221 
222 };
223 
224 
225 // /////////////////////////////////////////////////////
226 // Inline and Template Function Definitions
227 
228 
229 inline
231 {
232  name_ = name_in;
233  return *this;
234 }
235 
236 
237 } // end of Teuchos namespace
238 
239 #endif
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.