NEML2 2.0.0
Loading...
Searching...
No Matches
Factory Class Reference

Detailed Description

The factory is responsible for:

  1. retriving a NEML2Object given the object name as a std::string
  2. creating a NEML2Object given the type of the NEML2Object as a std::string.

#include <Factory.h>

Public Member Functions

 Factory (InputFile)
 
InputFileinput_file ()
 Get the input file.
 
const InputFileinput_file () const
 Get the input file.
 
const std::shared_ptr< Settings > & settings () const
 Global settings.
 
bool has_object (const std::string &section, const std::string &name)
 Check if an object with the given name exists under the given section.
 
template<class T >
std::shared_ptr< T > get_object (const std::string &section, 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 = Solver>
std::shared_ptr< T > get_solver (const std::string &name)
 Get a solver by its name.
 
template<class T = Data>
std::shared_ptr< T > get_data (const std::string &name)
 Get a data by its name.
 
template<class T = Model>
std::shared_ptr< T > get_model (const std::string &name)
 Get a model by its name.
 
template<class T = Driver>
std::shared_ptr< T > get_driver (const std::string &name)
 Get a driver by its name.
 
template<class T = WorkScheduler>
std::shared_ptr< T > get_scheduler (const std::string &name)
 Get a scheduler by its name.
 
void clear ()
 Delete all factories and destruct all the objects.
 
void print (std::ostream &os=std::cout)
 List all the manufactured objects.
 

Protected Member Functions

void create_object (const std::string &section, const OptionSet &options)
 Manufacture a single NEML2Object.
 

Constructor & Destructor Documentation

◆ Factory()

Member Function Documentation

◆ clear()

void clear ( )

Delete all factories and destruct all the objects.

◆ create_object()

void create_object ( const std::string & section,
const OptionSet & options )
protected

Manufacture a single NEML2Object.

Parameters
sectionThe section which the object to be manufactured belongs to.
optionsThe options of the object.

◆ get_data()

template<class T >
std::shared_ptr< T > get_data ( const std::string & name)

Get a data by its name.

◆ get_driver()

template<class T >
std::shared_ptr< T > get_driver ( const std::string & name)

Get a driver by its name.

◆ get_model()

template<class T >
std::shared_ptr< T > get_model ( const std::string & name)

Get a model by its name.

◆ get_object()

template<class T >
std::shared_ptr< T > get_object ( const std::string & section,
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.

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
TThe type of the NEML2Object
Parameters
sectionThe section name under which the search happens.
nameThe name of the object to retrieve.
additional_optionsAdditional 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.

◆ get_scheduler()

template<class T >
std::shared_ptr< T > get_scheduler ( const std::string & name)

Get a scheduler by its name.

◆ get_solver()

template<class T >
std::shared_ptr< T > get_solver ( const std::string & name)

Get a solver by its name.

◆ has_object()

bool has_object ( const std::string & section,
const std::string & name )

Check if an object with the given name exists under the given section.

◆ input_file() [1/2]

InputFile & input_file ( )
inline

Get the input file.

◆ input_file() [2/2]

const InputFile & input_file ( ) const
inline

Get the input file.

◆ print()

void print ( std::ostream & os = std::cout)

List all the manufactured objects.

Parameters
osThe stream to write to.

◆ settings()

const std::shared_ptr< Settings > & settings ( ) const
inline

Global settings.