62 virtual void printDoc(std::string
const& docString, std::ostream &out)
const {}
66 std::string
const& paramName,
67 std::string
const& sublistName
87 const std::string Direction_Doc =
"This sublist controls how direction is computed.";
90 PL_Newton.
sublist(
"Linear Solver");
104 setStringToIntegralParameter<int>(
107 "Selects the type of nonlinear solver to use",
108 tuple<std::string>(
"Line Search Based",
"Trust Region Based"),
116 linesearchMaxItersValiator =
rcp(
119 AcceptedTypes(
false).allowInt(
true).allowDouble(
true).allowString(
true)
124 ,
"The maximum number of inner linear search iterations allowed." 125 ,linesearchMaxItersValiator
132 linSolveTolValidator =
rcp(
135 AcceptedTypes(
false).allowDouble(
true).allowString(
true)
141 ,
"Select the linear solve tolerance" 142 ,linSolveTolValidator
145 return PL_Main_valid;
202 ECHO(
const bool param_isType_int1 = my_int_c_param.isType<
int>());
204 ECHO(
const bool param_isType_double1 = my_int_c_param.isType<
double>());
212 ECHO(
const int my_int = pl.
get<
int>(
"my int"));
222 ECHO(
const int my_int = pl.
get<
int>(
"my int"));
239 ECHO(
const int my_int =
getConst(pl).sublist(
"my sublist").get<int>(
"my int"));
254 ECHO(pl.
set(
"my int", 3,
"Some documentation"));
264 ECHO(pl.
set(
"my int", 3,
"Some documentation",
rcp(
new DummyValidator)));
267 TEST_NOTHROW(rcp_dynamic_cast<const DummyValidator>(my_int_param.validator(),
true));
301 ECHO(
const int my_int_1 = my_int_param.getValue<
int>(0));
331 ECHO(
char dummy_str_1[] =
"dummy str 1");
332 ECHO(pl.
set(
"dummy 1", dummy_str_1));
333 ECHO(
const std::string dummy_1 = pl.
get<std::string>(
"dummy 1"));
336 ECHO(
const char dummy_str_const_2[] =
"dummy str 2");
337 ECHO(pl.
set(
"dummy 2", dummy_str_const_2));
338 ECHO(
const std::string dummy_2 = pl.
get<std::string>(
"dummy 2"));
348 ECHO(
const std::string dummy_str =
"dummy str");
349 ECHO(pl.
set(
"my str", dummy_str));
350 ECHO(
const std::string my_str = pl.
get<std::string>(
"my str"));
364 ECHO(
char raw_str[] =
"dummy");
366 ECHO(
const char raw_c_str[] =
"dummy");
368 ECHO(
const std::string str =
"dummy");
424 ECHO(
int &my_int = pl.
get(
"my int", 3));
439 ECHO(
const bool param_was_removed_1 = pl.
remove(
"my int"));
444 ECHO(
const bool param_was_removed_2 = pl.
remove(
"my int",
false));
465 ECHO(pl.
sublist(
"my sublist",
false,
"My great sublist"));
496 ECHO(
const int my_int = pl.
sublist(
"my sublist").
get<
int>(
"my int"));
505 ECHO(
const int my_int =
getConst(pl).sublist(
"my sublist").get<int>(
"my int"));
530 const std::string Direction_Doc =
"This sublist controls how direction is computed.";
533 out <<
"PL_Main=\n" << PL_Main <<
"\n";
551 const std::string Direction_Doc =
"This sublist controls how direction is computed.";
556 out <<
"PL_Main=\n" << PL_Main <<
"\n";
576 ECHO(pl1.set(
"my int", 2));
586 ECHO(pl1.set(
"my int", 2));
602 ConstIter pl_itr = pl.
begin();
623 ConstIter pl_itr = pl.
begin();
647 A.set(
"Hello",
"World");
649 B.set(
"Hello",
"World");
690 A.set(
"Hello",
"World");
692 B.set(
"Hello",
"World");
701 A.sublist(
"Smith").set(
"People",4);
702 B.sublist(
"Jones").set(
"People",4);
730 ECHO(PL_Main.
set(
"Nonlinear Solver",
"Line Search Based"));
732 ECHO(
const int lineSearchValue = getIntegralValue<int>(PL_Main,
"Nonlinear Solver"));
734 ECHO(PL_Main.
set(
"Nonlinear Solver",
"Trust Region Based"));
735 ECHO(
const int trustRegionValue = getIntegralValue<int>(PL_Main,
"Nonlinear Solver"));
ParameterList createMainPL()
C++ Standard Library compatable filtered iterator.
#define TEST_INEQUALITY_CONST(v1, v2)
Assert the inequality of v1 and constant v2.
RCP< ParameterEntry > getEntryRCP(const std::string &name)
Retrieves the RCP for an entry with the name name if it exists.
#define TEST_NOTHROW(code)
Asserr that the statement 'code' does not thrown any excpetions.
#define ECHO(statement)
Echo the given statement before it is executed.
ConstIterator begin() const
An iterator pointing to the first entry.
T & get(const std::string &name, T def_value)
Return the parameter's value, or the default value if it is not there.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Set a parameter whose value has type T.
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
This object is held as the "value" in the Teuchos::ParameterList std::map.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
virtual void printDoc(std::string const &docString, std::ostream &out) const =0
Print documentation for this parameter.
#define TEST_ITER_EQUALITY(iter1, iter2)
Assert that two iterators are equal.
bool isSublist(const std::string &name) const
Whether the given sublist exists in this list.
#define TEST_THROW(code, ExceptType)
Assert that the statement 'code' throws the exception 'ExceptType' (otherwise the test fails)...
virtual const std::string getXMLTypeName() const =0
Get a string that should be used as a value of the type attribute when serializing it to XML...
const T & getConst(T &t)
Return a constant reference to an object given a non-const reference.
Ordinal numParams() const
Get the number of stored parameters.
ParameterList createValidMainPL()
ParameterEntry * getEntryPtr(const std::string &name)
Retrieves the pointer for an entry with the name name if it exists.
ParameterList & setEntry(const std::string &name, const ParameterEntry &entry)
Set a parameter directly as a ParameterEntry.
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
Validate the parameters in this list given valid selections in the input list.
Determines the types that are accepted.
ConstIterator end() const
An iterator pointing beyond the last entry.
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
bool remove(std::string const &name, bool throwIfNotExists=true)
Remove a parameter (does not depend on the type of the parameter).
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated Parameter List class.
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
Validate the parameters in this list given valid selections in the input list and set defaults for th...
bool isType(const std::string &name) const
Whether the given parameter exists in this list and has type T.
virtual ValidStringsList validStringValues() const =0
Return an array of strings of valid values if applicable.
RCP< const ParameterEntryValidator > validator() const
Return the (optional) validator object.
T * getPtr(const std::string &name)
Retrieves the pointer for parameter name of type T from a list. A null pointer is returned if this pa...
A list of parameters of arbitrary type.
ParameterList & setParameters(const ParameterList &source)
Abstract interface for an object that can validate a ParameterEntry's value.
const std::string & name() const
The name of this ParameterList.
Class uesd to validate a particular type of number.
TEST_ASSERT(castedDep1->getValuesAndValidators().size()==2)
bool isParameter(const std::string &name) const
Whether the given parameter exists in this list.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Creates an empty sublist and returns a reference to the sublist name. If the list already exists...
Smart reference counting pointer class for automatic garbage collection.
TEST_EQUALITY(rcp_dynamic_cast< const EnhancedNumberValidator< double > >(castedDep1->getValuesAndValidators().find("val1") ->second, true) ->getMax(), double1Vali->getMax())
Standard implementation of a ParameterEntryValidator that accepts numbers from a number of different ...
ParameterEntry & getEntry(const std::string &name)
Retrieves an entry with the name name.
Definition of Teuchos::as, for conversions between types.
virtual void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const =0
Validate a parameter entry value and throw std::exception (with a great error message) if validation ...