Chi-Tech
|
#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 | |
ChiObjectFactory & | operator= (const ChiObjectFactory &)=delete |
const std::map< std::string, ObjectRegistryEntry > & | Registry () const |
bool | RegistryHasKey (const std::string &key) const |
size_t | MakeRegisteredObject (const chi::ParameterBlock ¶ms) const |
size_t | MakeRegisteredObjectOfType (const std::string &type, const chi::ParameterBlock ¶ms) const |
chi::InputParameters | GetRegisteredObjectParameters (const std::string &type) const |
void | DumpRegister () const |
Dumps the object registry to stdout. More... | |
Static Public Member Functions | |
static ChiObjectFactory & | GetInstance () 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 ¶ms) |
Private Attributes | |
std::map< std::string, ObjectRegistryEntry > | object_registry_ |
Singleton object for handling the registration and making of ChiObjects.
Definition at line 65 of file ChiObjectFactory.h.
using ChiObjectFactory::ObjectConstructorFunc = ObjectPtr (*)(const chi::InputParameters&) |
Definition at line 71 of file ChiObjectFactory.h.
using ChiObjectFactory::ObjectGetInParamsFunc = chi::InputParameters (*)() |
Definition at line 70 of file ChiObjectFactory.h.
using ChiObjectFactory::ObjectPtr = std::shared_ptr<ChiObject> |
Definition at line 68 of file ChiObjectFactory.h.
|
delete |
|
delete |
|
privatedefault |
Private constructor because this is a singleton.
|
inlinestatic |
Definition at line 91 of file ChiObjectFactory.h.
|
inlinestatic |
Definition at line 108 of file ChiObjectFactory.h.
|
inlinestatic |
Definition at line 123 of file ChiObjectFactory.h.
|
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.
|
inlinestaticprivate |
Utility redirection to call an object's static GetInputParameters
function.
Definition at line 159 of file ChiObjectFactory.h.
|
inlinestaticprivate |
Utility redirection to call an object's constructor with a specified list of input parameters.
Definition at line 168 of file ChiObjectFactory.h.
void ChiObjectFactory::DumpRegister | ( | ) | const |
Dumps the object registry to stdout.
Dumps the registry to stdout.
Definition at line 117 of file ChiObjectFactory.cc.
|
staticnoexcept |
Access to the singleton
Definition at line 8 of file ChiObjectFactory.cc.
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.
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.
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.
|
delete |
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.
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.
|
private |
Definition at line 151 of file ChiObjectFactory.h.