Chi-Tech
ChiObjectFactory Class Reference

#include <ChiObjectFactory.h>

Data Structures

struct  ObjectRegistryEntry
 

Public Types

using ObjectPtr = std::shared_ptr< ChiObject >
 
using ObjectGetInParamsFunc = chi::InputParameters(*)()
 
using ObjectConstructorFunc = ObjectPtr(*)(const chi::InputParameters &)
 

Public Member Functions

 ChiObjectFactory (const ChiObjectFactory &)=delete
 
 ChiObjectFactory (const ChiObjectFactory &&)=delete
 
ChiObjectFactoryoperator= (const ChiObjectFactory &)=delete
 
const std::map< std::string, ObjectRegistryEntry > & Registry () const
 
bool RegistryHasKey (const std::string &key) const
 
size_t MakeRegisteredObject (const chi::ParameterBlock &params) const
 
size_t MakeRegisteredObjectOfType (const std::string &type, const chi::ParameterBlock &params) const
 
chi::InputParameters GetRegisteredObjectParameters (const std::string &type) const
 
void DumpRegister () const
 Dumps the object registry to stdout. More...
 

Static Public Member Functions

static ChiObjectFactoryGetInstance () noexcept
 
template<typename T , typename base_T >
static char AddObjectToRegistry (const std::string &namespace_name, const std::string &object_name)
 
template<typename T >
static char AddObjectToRegistryParamsOnly (const std::string &namespace_name, const std::string &object_name)
 
static char AddSyntaxBlockToRegistry (const std::string &namespace_name, const std::string &block_name, ObjectGetInParamsFunc syntax_function)
 

Private Member Functions

 ChiObjectFactory ()=default
 
void AssertRegistryKeyAvailable (const std::string &key, const std::string &calling_function) const
 

Static Private Member Functions

template<typename T >
static chi::InputParameters CallGetInputParamsFunction ()
 
template<typename T , typename base_T >
static std::shared_ptr< base_T > CallObjectConstructor (const chi::InputParameters &params)
 

Private Attributes

std::map< std::string, ObjectRegistryEntryobject_registry_
 

Detailed Description

Singleton object for handling the registration and making of ChiObjects.

Definition at line 65 of file ChiObjectFactory.h.

Member Typedef Documentation

◆ ObjectConstructorFunc

◆ ObjectGetInParamsFunc

◆ ObjectPtr

using ChiObjectFactory::ObjectPtr = std::shared_ptr<ChiObject>

Definition at line 68 of file ChiObjectFactory.h.

Constructor & Destructor Documentation

◆ ChiObjectFactory() [1/3]

ChiObjectFactory::ChiObjectFactory ( const ChiObjectFactory )
delete

◆ ChiObjectFactory() [2/3]

ChiObjectFactory::ChiObjectFactory ( const ChiObjectFactory &&  )
delete

◆ ChiObjectFactory() [3/3]

ChiObjectFactory::ChiObjectFactory ( )
privatedefault

Private constructor because this is a singleton.

Member Function Documentation

◆ AddObjectToRegistry()

template<typename T , typename base_T >
static char ChiObjectFactory::AddObjectToRegistry ( const std::string &  namespace_name,
const std::string &  object_name 
)
inlinestatic

Definition at line 91 of file ChiObjectFactory.h.

◆ AddObjectToRegistryParamsOnly()

template<typename T >
static char ChiObjectFactory::AddObjectToRegistryParamsOnly ( const std::string &  namespace_name,
const std::string &  object_name 
)
inlinestatic

Definition at line 108 of file ChiObjectFactory.h.

◆ AddSyntaxBlockToRegistry()

static char ChiObjectFactory::AddSyntaxBlockToRegistry ( const std::string &  namespace_name,
const std::string &  block_name,
ObjectGetInParamsFunc  syntax_function 
)
inlinestatic

Definition at line 123 of file ChiObjectFactory.h.

◆ AssertRegistryKeyAvailable()

void ChiObjectFactory::AssertRegistryKeyAvailable ( const std::string &  key,
const std::string &  calling_function 
) const
private

Checks that the registry key is available and throws a std::logical_error if it is not.

Definition at line 144 of file ChiObjectFactory.cc.

◆ CallGetInputParamsFunction()

template<typename T >
static chi::InputParameters ChiObjectFactory::CallGetInputParamsFunction ( )
inlinestaticprivate

Utility redirection to call an object's static GetInputParameters function.

Definition at line 159 of file ChiObjectFactory.h.

◆ CallObjectConstructor()

template<typename T , typename base_T >
static std::shared_ptr< base_T > ChiObjectFactory::CallObjectConstructor ( const chi::InputParameters params)
inlinestaticprivate

Utility redirection to call an object's constructor with a specified list of input parameters.

Definition at line 168 of file ChiObjectFactory.h.

◆ DumpRegister()

void ChiObjectFactory::DumpRegister ( ) const

Dumps the object registry to stdout.

Dumps the registry to stdout.

Definition at line 117 of file ChiObjectFactory.cc.

◆ GetInstance()

ChiObjectFactory & ChiObjectFactory::GetInstance ( )
staticnoexcept

Access to the singleton

Definition at line 8 of file ChiObjectFactory.cc.

◆ GetRegisteredObjectParameters()

chi::InputParameters ChiObjectFactory::GetRegisteredObjectParameters ( const std::string &  type) const

Returns the input parameters of a registered object.

Definition at line 103 of file ChiObjectFactory.cc.

◆ MakeRegisteredObject()

size_t ChiObjectFactory::MakeRegisteredObject ( const chi::ParameterBlock params) const

Makes an object with the given parameters and places on the global object stack. Returns a handle to the object. The object type is obtained from a string parameter name chi_obj_type.

Definition at line 34 of file ChiObjectFactory.cc.

◆ MakeRegisteredObjectOfType()

size_t ChiObjectFactory::MakeRegisteredObjectOfType ( const std::string &  type,
const chi::ParameterBlock params 
) const

Makes an object with the given parameters and places on the global object stack. Returns a handle to the object.

Definition at line 55 of file ChiObjectFactory.cc.

◆ operator=()

ChiObjectFactory & ChiObjectFactory::operator= ( const ChiObjectFactory )
delete

◆ Registry()

const std::map< std::string, ChiObjectFactory::ObjectRegistryEntry > & ChiObjectFactory::Registry ( ) const

Returns a constant reference to the object registry.

Definition at line 17 of file ChiObjectFactory.cc.

◆ RegistryHasKey()

bool ChiObjectFactory::RegistryHasKey ( const std::string &  key) const

Checks if the object registry has a specific text key.

Definition at line 24 of file ChiObjectFactory.cc.

Field Documentation

◆ object_registry_

std::map<std::string, ObjectRegistryEntry> ChiObjectFactory::object_registry_
private

Definition at line 151 of file ChiObjectFactory.h.


The documentation for this class was generated from the following files: