100 pl->set(
"String",
foo_ );
129 pl->set(
"String",
foo_ );
158 pl->set(
"String",
foo_ );
188 TEST_THROW( ob->setObjectName(
""), std::logic_error );
189 TEST_THROW( ob->setObjectTypeName(
""), std::logic_error );
193 TEST_THROW( ob = objectBuilder<Foo>(
"",
"Foo Type"), std::logic_error );
194 TEST_THROW( ob = objectBuilder<Foo>(
"Foo",
""), std::logic_error );
195 TEST_THROW( ob = objectBuilder<Foo>(
"",
""), std::logic_error );
199 ob->setObjectName(
"Foo");
200 ob->setObjectTypeName(
"Foo Type");
206 "Determines the type of Foo object that will be built.\nThe parameters for each Foo Type are specified in this sublist"
216 "Determines the type of Foo object that will be built.\nThe parameters for each Foo Type are specified in this sublist"
236 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
244 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
245 pl = ob->getValidParameters();
247 TEST_THROW( ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
""), std::logic_error );
254 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
257 TEST_THROW( ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A"), std::logic_error );
258 #else // TEUCHOS_DEBUG
259 TEST_NOTHROW( ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A") );
260 TEST_THROW( ob->getValidParameters(), std::logic_error );
261 #endif // TEUCHOS_DEBUG
265 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
266 TEST_NOTHROW( ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"New Foo A") );
277 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
278 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
281 pl->
set(
"Foo Type",
"Foo A");
285 ob->setParameterList(pl);
310 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
311 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
312 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
313 out <<
"op.getValidParamters():\n";
317 pl->
set(
"Foo Type",
"None");
318 ob->setParameterList(pl);
320 pl->
set(
"Foo Type",
"Foo B");
329 ob->unsetParameterList();
337 const RCP<Foo> foo = ob->create(
"Foo A");
341 ob->setParameterList(pl);
343 const RCP<Foo> foo = ob->create(
"Foo A");
349 TEST_THROW( foo = ob->create(
"Foo D"), std::logic_error );
354 #if !(__GNUC__ == 4 && __GNUC_MINOR__ == 8) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 9) && !(__GNUC__ == 5 && __GNUC_MINOR__ == 3) && !(__GNUC__ == 6 && __GNUC_MINOR__ == 2)
366 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
369 pl = parameterList();
371 pl->set(
"Hello",
"World");
372 TEST_THROW( ob->setParameterList(pl), std::logic_error );
374 TEST_THROW( ob->unsetParameterList(), std::logic_error );
376 #else // TEUCHOS_DEBUG
383 #endif // TEUCHOS_DEBUG
386 #endif // GCC 4.8, 4.9, 5.3, 6.2
400 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
404 nonconstPL->
set(
"Object Type",
"None");
415 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
418 pl = parameterList();
419 pl->
set(
"Object Type",
"None");
423 newPL = ob->getNonconstParameterList();
428 #if !(__GNUC__ == 4 && __GNUC_MINOR__ == 8) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 9) && !(__GNUC__ == 5 && __GNUC_MINOR__ == 3) && !(__GNUC__ == 6 && __GNUC_MINOR__ == 2)
438 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
440 pl->
set(
"Object Type",
"None");
441 ob->setParameterList(pl);
449 ob->setParameterList(pl);
450 pl->
set(
"Hello",
"World");
453 TEST_THROW( newPL = ob->unsetParameterList(), std::logic_error );
455 #else // TEUCHOS_DEBUG
459 #endif // TEUCHOS_DEBUG
462 #endif // GCC 4.8, 4.9, 5.3, 6.2
472 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
474 pl->
set(
"Object Type",
"Foo B");
475 TEST_THROW( ob->setParameterList(pl), std::logic_error );
479 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
480 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo B");
481 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo C");
483 validPL->
set(
"Object Type",
"Foo C");
493 objectValidator =
rcp(
495 validObjectNames,
"Object Type"
499 "Object Type",
"Foo C"
500 ,(std::string(
"Determines the type of Object object that will be built.\n")
501 +
"The parameters for each Object Type are specified in this sublist"
507 validPL->
set(
"Object Type",
"Foo A");
509 validPL->
set(
"Object Type",
"Foo B");
511 validPL->
set(
"Object Type",
"None");
524 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
525 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
526 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
529 ob->setParameterList(pl);
530 const RCP<Foo> foo = ob->create(
"Foo A");
540 ob->unsetParameterList();
546 ob->setParameterList(pl);
548 const RCP<Foo> foo = ob->create(
"Foo A");
553 const ParameterEntry& pe = outPL->sublist(
"Foo A").getEntry(
"String");
559 ob->unsetParameterList();
565 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
566 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
567 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
570 ob->setParameterList(pl);
577 ob->setParameterList(pl);
578 ob->setDefaultObject(
"Foo A");
585 ob->setParameterList(pl);
586 ob->setDefaultObject(
"None");
592 TEST_THROW(ob->setDefaultObject(
"Foo D"), std::logic_error);
594 ob->setDefaultObject(
"Foo D");
595 TEST_THROW(ob->getValidParameters(), std::logic_error);
596 #endif // TEUCHOS_DEBUG
601 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
602 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
603 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
605 ob->setParameterList(pl);
614 ob->setDefaultObject(
"Foo A");
620 ob->setDefaultObject(
"None");
628 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
629 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
630 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
637 ob->setDefaultObject(
"Foo A");
643 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.
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.
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.
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