68 pl->set(
"String",
foo_ );
97 pl->set(
"String",
foo_ );
126 pl->set(
"String",
foo_ );
156 TEST_THROW( ob->setObjectName(
""), std::logic_error );
157 TEST_THROW( ob->setObjectTypeName(
""), std::logic_error );
161 TEST_THROW( ob = objectBuilder<Foo>(
"",
"Foo Type"), std::logic_error );
162 TEST_THROW( ob = objectBuilder<Foo>(
"Foo",
""), std::logic_error );
163 TEST_THROW( ob = objectBuilder<Foo>(
"",
""), std::logic_error );
167 ob->setObjectName(
"Foo");
168 ob->setObjectTypeName(
"Foo Type");
174 "Determines the type of Foo object that will be built.\nThe parameters for each Foo Type are specified in this sublist"
184 "Determines the type of Foo object that will be built.\nThe parameters for each Foo Type are specified in this sublist"
204 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
212 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
213 pl = ob->getValidParameters();
215 TEST_THROW( ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
""), std::logic_error );
222 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
225 TEST_THROW( ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A"), std::logic_error );
226 #else // TEUCHOS_DEBUG
227 TEST_NOTHROW( ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A") );
228 TEST_THROW( ob->getValidParameters(), std::logic_error );
229 #endif // TEUCHOS_DEBUG
233 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
234 TEST_NOTHROW( ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"New Foo A") );
245 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
246 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
249 pl->
set(
"Foo Type",
"Foo A");
253 ob->setParameterList(pl);
278 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
279 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
280 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
281 out <<
"op.getValidParamters():\n";
285 pl->
set(
"Foo Type",
"None");
286 ob->setParameterList(pl);
288 pl->
set(
"Foo Type",
"Foo B");
297 ob->unsetParameterList();
305 const RCP<Foo> foo = ob->create(
"Foo A");
309 ob->setParameterList(pl);
311 const RCP<Foo> foo = ob->create(
"Foo A");
317 TEST_THROW( foo = ob->create(
"Foo D"), std::logic_error );
322 #if !(__GNUC__ == 4 && __GNUC_MINOR__ == 8) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 9) && !(__GNUC__ == 5 && __GNUC_MINOR__ == 3) && !(__GNUC__ == 6 && __GNUC_MINOR__ == 2)
334 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
337 pl = parameterList();
339 pl->set(
"Hello",
"World");
340 TEST_THROW( ob->setParameterList(pl), std::logic_error );
342 TEST_THROW( ob->unsetParameterList(), std::logic_error );
344 #else // TEUCHOS_DEBUG
351 #endif // TEUCHOS_DEBUG
354 #endif // GCC 4.8, 4.9, 5.3, 6.2
368 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
372 nonconstPL->
set(
"Object Type",
"None");
383 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
386 pl = parameterList();
387 pl->
set(
"Object Type",
"None");
391 newPL = ob->getNonconstParameterList();
396 #if !(__GNUC__ == 4 && __GNUC_MINOR__ == 8) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 9) && !(__GNUC__ == 5 && __GNUC_MINOR__ == 3) && !(__GNUC__ == 6 && __GNUC_MINOR__ == 2)
406 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
408 pl->
set(
"Object Type",
"None");
409 ob->setParameterList(pl);
417 ob->setParameterList(pl);
418 pl->
set(
"Hello",
"World");
421 TEST_THROW( newPL = ob->unsetParameterList(), std::logic_error );
423 #else // TEUCHOS_DEBUG
427 #endif // TEUCHOS_DEBUG
430 #endif // GCC 4.8, 4.9, 5.3, 6.2
440 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
442 pl->
set(
"Object Type",
"Foo B");
443 TEST_THROW( ob->setParameterList(pl), std::logic_error );
447 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
448 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo B");
449 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo C");
451 validPL->
set(
"Object Type",
"Foo C");
461 objectValidator =
rcp(
463 validObjectNames,
"Object Type"
467 "Object Type",
"Foo C"
468 ,(std::string(
"Determines the type of Object object that will be built.\n")
469 +
"The parameters for each Object Type are specified in this sublist"
475 validPL->
set(
"Object Type",
"Foo A");
477 validPL->
set(
"Object Type",
"Foo B");
479 validPL->
set(
"Object Type",
"None");
492 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
493 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
494 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
497 ob->setParameterList(pl);
498 const RCP<Foo> foo = ob->create(
"Foo A");
508 ob->unsetParameterList();
514 ob->setParameterList(pl);
516 const RCP<Foo> foo = ob->create(
"Foo A");
521 const ParameterEntry& pe = outPL->sublist(
"Foo A").getEntry(
"String");
527 ob->unsetParameterList();
533 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
534 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
535 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
538 ob->setParameterList(pl);
545 ob->setParameterList(pl);
546 ob->setDefaultObject(
"Foo A");
553 ob->setParameterList(pl);
554 ob->setDefaultObject(
"None");
560 TEST_THROW(ob->setDefaultObject(
"Foo D"), std::logic_error);
562 ob->setDefaultObject(
"Foo D");
563 TEST_THROW(ob->getValidParameters(), std::logic_error);
564 #endif // TEUCHOS_DEBUG
569 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
570 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
571 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
573 ob->setParameterList(pl);
582 ob->setDefaultObject(
"Foo A");
588 ob->setDefaultObject(
"None");
596 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
597 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
598 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
605 ob->setDefaultObject(
"Foo A");
611 ob->setDefaultObject(
"None");
RCP< ParameterList > unsetParameterList()
Unset the parameter list that was set using setParameterList().
std::string getString() const
RCP< const ParameterList > getParameterList() const
Get const version of the parameter list that was set using setParameterList().
#define TEST_ASSERT(v1)
Assert the given statement is true.
virtual std::string getString() const =0
#define TEST_NOTHROW(code)
Asserr that the statement 'code' does not thrown any excpetions.
RCP< const ParameterList > getValidParameters() const
Return a ParameterList containing all of the valid parameters that this->setParameterList(...) will accept, along with any validators.
T & get(const std::string &name, T def_value)
Return the parameter's value, or the default value if it is not there.
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.
#define TEST_THROW(code, ExceptType)
Assert that the statement 'code' throws the exception 'ExceptType' (otherwise the test fails)...
T * get() const
Get the raw C++ pointer to the underlying object.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Templated set method.
bool isParameter(const std::string &name) const
Whether the given parameter exists in this list.
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
const std::string ObjectType_name
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated Parameter List class.
bool isSublist(const std::string &name) const
Whether the given sublist exists in this list.
RCP< ParameterList > getNonconstParameterList()
Get a nonconst version of the parameter list that was set using setParameterList().
virtual void setDefaults()=0
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void printValidParameters(const ParameterListAcceptor ¶mListAccpetor, std::ostream &out, const bool showDoc=true)
Pretty print the valid parameters from a ParameterListAccpetor object.
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.
ParameterList & setParameters(const ParameterList &source)
RCP< ParameterList > paramList_
Interface for objects that can accept a ParameterList.
void push_back(const value_type &x)
void setParameterList(const RCP< ParameterList > ¶mList)
Set parameters from a parameter list and return with default values.
RCP< const ParameterList > getValidParameters() const
Return a ParameterList containing all of the valid parameters that this->setParameterList(...) will accept, along with any validators.
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.
std::string docString() const
Return the (optional) documentation std::string.
ParameterEntry & getEntry(const std::string &name)
Retrieves an entry with the name name.
RCP< const ParameterList > getValidParameters() const
Return a ParameterList containing all of the valid parameters that this->setParameterList(...) will accept, along with any validators.
std::string getString() const
virtual RCP< const ParameterList > getValidParameters() const
Return a ParameterList containing all of the valid parameters that this->setParameterList(...) will accept, along with any validators.
std::string getString() const