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 linesearchMaxItersValidator =
rcp(
119 AcceptedTypes(
false).allowInt(
true).allowDouble(
true).allowString(
true)
124 ,
"The maximum number of inner linear search iterations allowed." 125 ,linesearchMaxItersValidator
131 linSolveTolValidator =
rcp(
134 AcceptedTypes(
false).allowDouble(
true).allowString(
true)
140 ,
"Select the linear solve tolerance" 141 ,linSolveTolValidator
147 elementsValidator =
rcp(
150 AcceptedTypes(
false).allowInt(
true).allowLongLong(
true).allowString(
true)
153 typedef long long LL;
155 "Elements", LL(72057594037927936ll)
156 ,
"Number of finite elements to generate" 160 return PL_Main_valid;
217 ECHO(
const bool param_isType_int1 = my_int_c_param.isType<
int>());
219 ECHO(
const bool param_isType_double1 = my_int_c_param.isType<
double>());
227 ECHO(
const int my_int = pl.
get<
int>(
"my int"));
237 ECHO(
const int my_int = pl.
get<
int>(
"my int"));
254 ECHO(
const int my_int =
getConst(pl).sublist(
"my sublist").get<int>(
"my int"));
269 ECHO(pl.
set(
"my int", 3,
"Some documentation"));
279 ECHO(pl.
set(
"my int", 3,
"Some documentation",
rcp(
new DummyValidator)));
282 TEST_NOTHROW(rcp_dynamic_cast<const DummyValidator>(my_int_param.validator(),
true));
316 ECHO(
const int my_int_1 = my_int_param.getValue<
int>(0));
346 ECHO(
char dummy_str_1[] =
"dummy str 1");
347 ECHO(pl.
set(
"dummy 1", dummy_str_1));
348 ECHO(
const std::string dummy_1 = pl.
get<std::string>(
"dummy 1"));
351 ECHO(
const char dummy_str_const_2[] =
"dummy str 2");
352 ECHO(pl.
set(
"dummy 2", dummy_str_const_2));
353 ECHO(
const std::string dummy_2 = pl.
get<std::string>(
"dummy 2"));
363 ECHO(
const std::string dummy_str =
"dummy str");
364 ECHO(pl.
set(
"my str", dummy_str));
365 ECHO(
const std::string my_str = pl.
get<std::string>(
"my str"));
379 ECHO(
char raw_str[] =
"dummy");
381 ECHO(
const char raw_c_str[] =
"dummy");
383 ECHO(
const std::string str =
"dummy");
439 ECHO(
int &my_int = pl.
get(
"my int", 3));
454 ECHO(
const bool param_was_removed_1 = pl.
remove(
"my int"));
459 ECHO(
const bool param_was_removed_2 = pl.
remove(
"my int",
false));
480 ECHO(pl.
sublist(
"my sublist",
false,
"My great sublist"));
511 ECHO(
const int my_int = pl.
sublist(
"my sublist").
get<
int>(
"my int"));
520 ECHO(
const int my_int =
getConst(pl).sublist(
"my sublist").get<int>(
"my int"));
545 const std::string Direction_Doc =
"This sublist controls how direction is computed.";
548 out <<
"PL_Main=\n" << PL_Main <<
"\n";
566 const std::string Direction_Doc =
"This sublist controls how direction is computed.";
571 out <<
"PL_Main=\n" << PL_Main <<
"\n";
591 ECHO(pl1.set(
"my int", 2));
601 ECHO(pl1.set(
"my int", 2));
617 ConstIter pl_itr = pl.
begin();
638 ConstIter pl_itr = pl.
begin();
662 A.set(
"Hello",
"World");
664 B.set(
"Hello",
"World");
705 A.set(
"Hello",
"World");
707 B.set(
"Hello",
"World");
716 A.sublist(
"Smith").set(
"People",4);
717 B.sublist(
"Jones").set(
"People",4);
745 ECHO(PL_Main.
set(
"Nonlinear Solver",
"Line Search Based"));
747 ECHO(
const int lineSearchValue = getIntegralValue<int>(PL_Main,
"Nonlinear Solver"));
749 ECHO(PL_Main.
set(
"Nonlinear Solver",
"Trust Region Based"));
750 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 ...