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) 367 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
370 pl = parameterList();
372 pl->set(
"Hello",
"World");
373 TEST_THROW( ob->setParameterList(pl), std::logic_error );
375 TEST_THROW( ob->unsetParameterList(), std::logic_error );
378 #else // TEUCHOS_DEBUG 385 #endif // TEUCHOS_DEBUG 401 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
405 nonconstPL->
set(
"Object Type",
"None");
416 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
419 pl = parameterList();
420 pl->
set(
"Object Type",
"None");
424 newPL = ob->getNonconstParameterList();
429 #if !(__GNUC__ == 4 && __GNUC_MINOR__ == 8) 439 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
441 pl->
set(
"Object Type",
"None");
442 ob->setParameterList(pl);
450 ob->setParameterList(pl);
451 pl->
set(
"Hello",
"World");
454 TEST_THROW( newPL = ob->unsetParameterList(), std::logic_error );
457 #else // TEUCHOS_DEBUG 461 #endif // TEUCHOS_DEBUG 474 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
476 pl->
set(
"Object Type",
"Foo B");
477 TEST_THROW( ob->setParameterList(pl), std::logic_error );
481 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
482 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo B");
483 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo C");
485 validPL->
set(
"Object Type",
"Foo C");
495 objectValidator =
rcp(
497 validObjectNames,
"Object Type" 501 "Object Type",
"Foo C" 502 ,(std::string(
"Determines the type of Object object that will be built.\n")
503 +
"The parameters for each Object Type are specified in this sublist" 509 validPL->
set(
"Object Type",
"Foo A");
511 validPL->
set(
"Object Type",
"Foo B");
513 validPL->
set(
"Object Type",
"None");
526 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
527 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
528 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
531 ob->setParameterList(pl);
532 const RCP<Foo> foo = ob->create(
"Foo A");
542 ob->unsetParameterList();
548 ob->setParameterList(pl);
550 const RCP<Foo> foo = ob->create(
"Foo A");
555 const ParameterEntry& pe = outPL->sublist(
"Foo A").getEntry(
"String");
561 ob->unsetParameterList();
567 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
568 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
569 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
572 ob->setParameterList(pl);
579 ob->setParameterList(pl);
580 ob->setDefaultObject(
"Foo A");
587 ob->setParameterList(pl);
588 ob->setDefaultObject(
"None");
594 TEST_THROW(ob->setDefaultObject(
"Foo D"), std::logic_error);
596 ob->setDefaultObject(
"Foo D");
597 TEST_THROW(ob->getValidParameters(), std::logic_error);
598 #endif // TEUCHOS_DEBUG 603 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
604 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
605 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
607 ob->setParameterList(pl);
616 ob->setDefaultObject(
"Foo A");
622 ob->setDefaultObject(
"None");
630 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
631 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
632 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
639 ob->setDefaultObject(
"Foo A");
645 ob->setDefaultObject(
"None");
RCP< ParameterList > unsetParameterList()
Unset the parameter list that was set using setParameterList().
virtual std::string getString() const =0
#define TEST_NOTHROW(code)
Asserr that the statement 'code' does not thrown any excpetions.
T & get(const std::string &name, T def_value)
Return the parameter's value, or the default value if it is not there.
virtual RCP< const ParameterList > getValidParameters() const
Return a ParameterList containing all of the valid parameters that this->setParameterList(...) will accept, along with any validators.
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.
std::string getString() const
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)...
RCP< const ParameterList > getParameterList() const
Get const version of the parameter list that was set using setParameterList().
T * get() const
Get the raw C++ pointer to the underlying 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.
std::string getString() const
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
const std::string ObjectType_name
RCP< const ParameterList > getValidParameters() const
Return a ParameterList containing all of the valid parameters that this->setParameterList(...) will accept, along with any validators.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated Parameter List class.
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.
RCP< const ParameterList > getValidParameters() const
Return a ParameterList containing all of the valid parameters that this->setParameterList(...) will accept, along with any validators.
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.
TEST_ASSERT(castedDep1->getValuesAndValidators().size()==2)
bool isParameter(const std::string &name) const
Whether the given parameter exists in this list.
std::string docString() const
Return the (optional) documentation std::string.
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.
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
ParameterEntry & getEntry(const std::string &name)
Retrieves an entry with the name name.