10#ifndef Teuchos_OBJECT_BUILDER_H 
   11#define Teuchos_OBJECT_BUILDER_H 
   14#include "Teuchos_ParameterListAcceptor.hpp" 
   15#include "Teuchos_AbstractFactoryStd.hpp" 
   16#include "Teuchos_StandardParameterEntryValidators.hpp" 
   56template<
class ObjectType>
 
  133  std::string object_name_;
 
  134  std::string objectType_name_;
 
  138  std::string defaultObject_name_;
 
  143  void initializeDefaults_();
 
 
  151template<
class ObjectType>
 
  159template<
class ObjectType>
 
  160RCP<ObjectBuilder<ObjectType> >
 
  161objectBuilder(
const std::string& objectName, 
const std::string& objectTypeName)
 
  163  RCP<ObjectBuilder<ObjectType> > ob = 
rcp(
new ObjectBuilder<ObjectType>() );
 
  164  ob->setObjectName(objectName);
 
  165  ob->setObjectTypeName(objectTypeName);
 
  175template<
class ObjectType>
 
  178  this->initializeDefaults_();
 
 
  182template<
class ObjectType>
 
  188template<
class ObjectType>
 
  198  validParamList_ = null;
 
  200  this->getValidParameters();
 
 
  205template<
class ObjectType>
 
  210    this->getValidParameters();
 
  217    pl = parameterList();
 
  218    pl->setParameters(*this->getValidParameters());
 
  220  return objectValidator_->getStringValue(*
pl, objectType_name_, defaultObject_name_);
 
 
  224template<
class ObjectType>
 
  230    paramList->validateParameters(*this->getValidParameters());
 
 
  236template<
class ObjectType>
 
  244template<
class ObjectType>
 
  251    paramList_->validateParameters(*this->getValidParameters());
 
 
  259template<
class ObjectType>
 
  267template<
class ObjectType>
 
  271  if(!validParamList_.get()) {
 
  274    objectValidator_ = 
rcp(
 
  276        validObjectNames_, objectType_name_
 
  279    objectValidator_->validateString(defaultObject_name_,objectType_name_);
 
  281      objectType_name_, defaultObject_name_,
 
  282      (std::string(
"Determines the type of " + object_name_ + 
" object that will be built.\n")
 
  283        + 
"The parameters for each " + objectType_name_ + 
" are specified in this sublist" 
  289        &
sname = validObjectNames_[
i+1];
 
  291        object = objectArray_[
i]->create();
 
  293        *
object->getValidParameters()).disableRecursiveValidation();
 
  297  return validParamList_;
 
 
  300template<
class ObjectType>
 
  306  if (
is_null(validParamList_)) { 
 
  307    this->getValidParameters();
 
  313  validParamList_ = null;
 
 
  316template<
class ObjectType>
 
  322  if (
is_null(validParamList_)) { 
 
  323    this->getValidParameters();
 
  328             : this->getObjectName() );
 
  332    s_idx = objectValidator_->getIntegralValue(
sname, objectType_name_);
 
  335    object = objectArray_[
s_idx-1]->create();
 
  337        (std::string(
"Error!  ObjectBuilder attempted to create an object of type ")
 
  338         + validObjectNames_[
s_idx] + 
" and it came back as a null RCP!").
c_str()
 
  344      pl = parameterList();
 
  345      pl->setParameters(this->getValidParameters()->sublist(
sname));
 
  350      paramList_->validateParameters(*this->getValidParameters());
 
  352      pl = sublist(paramList_,
sname);
 
  355    object->setParameterList(
pl);
 
 
  361template<
class ObjectType>
 
  368  validParamList_ = null;
 
 
  372template<
class ObjectType>
 
  379  validParamList_ = null;
 
 
  383template<
class ObjectType>
 
  387  object_name_ = 
"Object";
 
  388  objectType_name_ = 
"Object Type";
 
  390  defaultObject_name_ = 
"None";
 
  391  validObjectNames_.resize(0);
 
  392  validObjectNames_.push_back(defaultObject_name_);
 
Templated Parameter List class.
 
Generic parameterlist driven bulider class.
 
RCP< const ParameterList > getValidParameters() const
 
RCP< ObjectType > create(const std::string &objectName="") const
 
RCP< const ParameterList > getParameterList() const
 
void setObjectFactory(const RCP< const AbstractFactory< ObjectType > > &objectFactory, const std::string &objectFactoryName)
Set a new Object factory object.
 
void setObjectTypeName(const std::string &objectTypeName)
Set the name of the parameterlist selector, e.g. "Object Type".
 
RCP< ParameterList > getNonconstParameterList()
 
void setObjectName(const std::string &objectName)
Set the name of the object this will be a builder for, e.g. "Object".
 
void setDefaultObject(const std::string &defaultObject_name)
Set the name of the desired object to be created when the parameter list does not specify which objec...
 
std::string getObjectName() const
Get the name of the Object that will be created on the next call to this->create().
 
RCP< ParameterList > unsetParameterList()
 
void setParameterList(const RCP< ParameterList > ¶mList)
 
Interface for objects that can accept a ParameterList.
 
Smart reference counting pointer class for automatic garbage collection.
 
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object.
 
bool is_null() const
Returns true if the underlying pointer is null.
 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call.
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
 
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.