27#include "neml2/base/OptionSet.h"
28#include "neml2/base/Factory.h"
32#include "neml2/base/Registry.h"
83 const std::string &
name()
const {
return _input_options.
name(); }
85 const std::string &
type()
const {
return _input_options.
type(); }
87 const std::string &
path()
const {
return _input_options.
path(); }
89 const std::string &
doc()
const {
return _input_options.
doc(); }
98 template <
typename T = NEML2Object>
99 const T *
host()
const;
102 template <
typename T = NEML2Object>
106 template <
typename T>
112 std::shared_ptr<T>
get_object(
const std::string & section,
const std::string &
name);
114 template <
class T = Solver>
117 template <
class T = Data>
120 template <
class T = Model>
123 template <
class T = Driver>
126 template <
class T = WorkScheduler>
142 const std::shared_ptr<Settings> _settings;
152 auto host_ptr =
dynamic_cast<const T *
>(_host ? _host :
this);
154 throw NEMLException(
"Internal error: Failed to retrieve host of object " +
name());
162 auto host_ptr =
dynamic_cast<T *
>(_host ? _host :
this);
164 throw NEMLException(
"Internal error: Failed to retrieve host of object " +
name());
174 throw NEMLException(
"Internal error: factory is nullptr for object " + this->
name());
175 return _factory->
get_object<T>(section, obj_name);
std::shared_ptr< T > get_object(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.
Definition Factory.h:154
The base class of all "manufacturable" objects in the NEML2 library.
Definition NEML2Object.h:51
NEML2Object(const NEML2Object &)=delete
std::shared_ptr< T > get_driver(const std::string &name)
Get a driver from the factory.
Definition NEML2Object.h:201
const T & resolve_tensor(const std::string &name)
Resolve a TensorName to a Tensor.
Definition NEML2Object.cxx:59
const std::string & name() const
A readonly reference to the object's name.
Definition NEML2Object.h:83
const T * host() const
Get a readonly pointer to the host.
Definition NEML2Object.h:150
std::shared_ptr< T > get_data(const std::string &name)
Get a data from the factory.
Definition NEML2Object.h:187
Factory * factory() const
Get the factory that created this object.
Definition NEML2Object.h:92
virtual void setup()
Setup this object.
Definition NEML2Object.h:80
const OptionSet & input_options() const
Definition NEML2Object.h:69
const std::string & type() const
A readonly reference to the object's type.
Definition NEML2Object.h:85
std::shared_ptr< T > get_object(const std::string §ion, const std::string &name)
Definition NEML2Object.h:170
NEML2Object(NEML2Object &&)=delete
NEML2Object & operator=(const NEML2Object &)=delete
const std::string & doc() const
A readonly reference to the object's docstring.
Definition NEML2Object.h:89
NEML2Object & operator=(NEML2Object &&)=delete
std::shared_ptr< T > get_model(const std::string &name)
Get a model from the factory.
Definition NEML2Object.h:194
std::shared_ptr< T > get_scheduler(const std::string &name)
Get a scheduler from the factory.
Definition NEML2Object.h:208
const std::string & path() const
A readonly reference to the object's path.
Definition NEML2Object.h:87
const Settings & settings() const
Settings.
Definition NEML2Object.h:95
static OptionSet expected_options()
Definition NEML2Object.cxx:33
virtual ~NEML2Object()=default
std::shared_ptr< T > get_solver(const std::string &name)
Get a solver from the factory.
Definition NEML2Object.h:180
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:51
const std::string & name() const
A readonly reference to the option set's name.
Definition OptionSet.h:74
const std::string & type() const
A readonly reference to the option set's type.
Definition OptionSet.h:78
T get(const std::string &) const
Definition OptionSet.h:242
const std::string & doc() const
A readonly reference to the option set's docstring.
Definition OptionSet.h:86
const std::string & path() const
A readonly reference to the option set's path.
Definition OptionSet.h:82
bool contains(const std::string &) const
Definition OptionSet.cxx:47
Definition DiagnosticsInterface.cxx:30
std::string name(ElasticConstant p)
Definition ElasticityConverter.cxx:30