The factory is responsible for:
- retriving a NEML2Object given the object name as a std::string
- creating a NEML2Object given the type of the NEML2Object as a std::string.
#include <Factory.h>
|
static Factory & | get () |
| Get the global Factory singleton.
|
|
template<class T > |
static std::shared_ptr< T > | get_object_ptr (const std::string §ion, const std::string &name, const OptionSet &additional_options=OptionSet(), bool force_create=true) |
| Retrive an object pointer under the given section with the given object name.
|
|
template<class T > |
static T & | get_object (const std::string §ion, const std::string &name, const OptionSet &additional_options=OptionSet(), bool force_create=true) |
| Retrive an object reference under the given section with the given object name.
|
|
static void | load_options (const OptionCollection &all_options) |
| Provide all objects' options to the factory. The factory is ready to manufacture objects after this call, e.g., through either manufacture, get_object, or get_object_ptr.
|
|
static const OptionCollection & | loaded_options () |
| Get the loaded options.
|
|
static void | clear () |
| Destruct all the objects.
|
|
static void | print (std::ostream &os=std::cout) |
| List all the manufactured objects.
|
|
◆ clear()
Destruct all the objects.
◆ create_object()
Manufacture a single NEML2Object.
- Parameters
-
section | The section which the object to be manufactured belongs to. |
options | The options of the object. |
◆ get()
◆ get_object()
Retrive an object reference under the given section with the given object name.
An exception is thrown if
- the object with the given name does not exist, or
- the object with the given name exists but does not have the correct type (e.g., dynamic case fails).
- Template Parameters
-
- Parameters
-
section | The section name under which the search happens. |
name | The name of the object to retrieve. |
additional_options | Additional input options to pass to the object constructor |
force_create | (Optional) Force the factory to create a new object even if the object has already been created. |
- Returns
- T & The object reference.
◆ get_object_ptr()
Retrive an object pointer under the given section with the given object name.
An exception is thrown if
- the object with the given name does not exist, or
- the object with the given name exists but does not have the correct type (e.g., dynamic case fails).
- Template Parameters
-
- Parameters
-
section | The section name under which the search happens. |
name | The name of the object to retrieve. |
additional_options | Additional input options to pass to the object constructor |
force_create | (Optional) Force the factory to create a new object even if the object has already been created. |
- Returns
- std::shared_ptr<T> The object pointer.
◆ load_options()
Provide all objects' options to the factory. The factory is ready to manufacture objects after this call, e.g., through either manufacture, get_object, or get_object_ptr.
- Parameters
-
all_options | The collection of all the options of the objects to be manufactured. |
◆ loaded_options()
◆ print()
void print |
( |
std::ostream & | os = std::cout | ) |
|
|
static |
List all the manufactured objects.
- Parameters
-
os | The stream to write to. |