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 );
365 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
368 pl = parameterList();
370 pl->set(
"Hello",
"World");
371 TEST_THROW( ob->setParameterList(pl), std::logic_error );
373 TEST_THROW( ob->unsetParameterList(), std::logic_error );
376 #else // TEUCHOS_DEBUG
383 #endif // TEUCHOS_DEBUG
391 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
395 nonconstPL->
set(
"Object Type",
"None");
406 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
409 pl = parameterList();
410 pl->
set(
"Object Type",
"None");
414 newPL = ob->getNonconstParameterList();
427 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
429 pl->
set(
"Object Type",
"None");
430 ob->setParameterList(pl);
438 ob->setParameterList(pl);
439 pl->
set(
"Hello",
"World");
442 TEST_THROW( newPL = ob->unsetParameterList(), std::logic_error );
445 #else // TEUCHOS_DEBUG
449 #endif // TEUCHOS_DEBUG
460 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
462 pl->
set(
"Object Type",
"Foo B");
463 TEST_THROW( ob->setParameterList(pl), std::logic_error );
467 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
468 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo B");
469 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo C");
471 validPL->
set(
"Object Type",
"Foo C");
481 objectValidator =
rcp(
483 validObjectNames,
"Object Type"
487 "Object Type",
"Foo C"
488 ,(std::string(
"Determines the type of Object object that will be built.\n")
489 +
"The parameters for each Object Type are specified in this sublist"
495 validPL->
set(
"Object Type",
"Foo A");
497 validPL->
set(
"Object Type",
"Foo B");
499 validPL->
set(
"Object Type",
"None");
512 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
513 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
514 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
517 ob->setParameterList(pl);
518 const RCP<Foo> foo = ob->create(
"Foo A");
528 ob->unsetParameterList();
534 ob->setParameterList(pl);
536 const RCP<Foo> foo = ob->create(
"Foo A");
541 const ParameterEntry& pe = outPL->sublist(
"Foo A").getEntry(
"String");
547 ob->unsetParameterList();
553 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
554 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
555 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
558 ob->setParameterList(pl);
565 ob->setParameterList(pl);
566 ob->setDefaultObject(
"Foo A");
573 ob->setParameterList(pl);
574 ob->setDefaultObject(
"None");
580 TEST_THROW(ob->setDefaultObject(
"Foo D"), std::logic_error);
582 ob->setDefaultObject(
"Foo D");
583 TEST_THROW(ob->getValidParameters(), std::logic_error);
584 #endif // TEUCHOS_DEBUG
589 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
590 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
591 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
593 ob->setParameterList(pl);
602 ob->setDefaultObject(
"Foo A");
608 ob->setDefaultObject(
"None");
616 ob->setObjectFactory(abstractFactoryStd<Foo,FooA>(),
"Foo A");
617 ob->setObjectFactory(abstractFactoryStd<Foo,FooB>(),
"Foo B");
618 ob->setObjectFactory(abstractFactoryStd<Foo,FooC>(),
"Foo C");
625 ob->setDefaultObject(
"Foo A");
631 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.
bool is_null(const boost::shared_ptr< T > &p)
Returns true if p.get()==NULL.
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 const parameter list of all of the valid parameters that this->setParameterList(...) will accept.
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.
#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 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_
Base class objects that can accept a parameter list.
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 const parameter list of all of the valid parameters that this->setParameterList(...) will accept.
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 const parameter list of all of the valid parameters that this->setParameterList(...) will accept.
std::string getString() const
virtual RCP< const ParameterList > getValidParameters() const
Return a const parameter list of all of the valid parameters that this->setParameterList(...) will accept.
std::string getString() const