34 void reg(std::shared_ptr<RegistryEntryBase> obj);
73 std::unique_ptr<MooseObject>
createUnique(
const std::string & obj_name,
75 const std::string &
name,
78 bool print_deprecated =
true);
79 std::shared_ptr<MooseObject>
create(
const std::string & obj_name,
80 const std::string &
name,
83 bool print_deprecated =
true);
96 std::unique_ptr<T>
createUnique(
const std::string & obj_name,
97 const std::string &
name,
100 template <
typename T>
101 std::shared_ptr<T>
create(
const std::string & obj_name,
102 const std::string &
name,
115 template <
typename T>
116 std::unique_ptr<T>
clone(
const T &
object);
125 template <
typename T>
194 const std::string & name,
247 template <
typename T>
250 const std::string & name,
255 if (!dynamic_cast<T *>(
object.
get()))
257 "'.\nInstead we received a parameters object for type '" + obj_name +
258 "'.\nDid you call the wrong \"add\" method in your Action?");
260 return std::unique_ptr<T>(
static_cast<T *
>(
object.release()));
263 template <
typename T>
266 const std::string & name,
270 return std::move(createUnique<T>(obj_name,
name, parameters, tid));
273 template <
typename T>
277 static_assert(std::is_base_of_v<MooseObject, T>,
"Not a MooseObject");
279 const auto tid =
object.template getParam<THREAD_ID>(
"_tid");
282 object.typeAndName(),
283 " is threaded but cloning does not work with threaded objects");
287 cloned_params +=
object.parameters();
288 if (
const auto hit_node =
object.parameters().getHitNode())
292 const auto type =
static_cast<const MooseBase &
>(object).type();
294 const auto name =
object.name() +
"_clone" + std::to_string(clone_count);
299 auto cloned_object = std::make_unique<T>(params);
305 return cloned_object;
308 template <
typename T>
312 static_assert(std::is_base_of_v<MooseObject, T>,
"Not a MooseObject");
314 const auto type =
static_cast<const MooseBase &
>(object).type();
315 const auto base =
object.parameters().getBase();
316 if (!base || (*base !=
"MooseMesh" && *base !=
"RelationshipManager"))
317 mooseError(
"Copy construction of ", type,
" objects is not supported.");
320 auto cloned_object = std::make_unique<T>(object);
325 return cloned_object;
std::set< std::pair< std::string, std::string > > _objects_by_label
set<label/appname, objectname> used to track if an object previously added is being added again - whi...
std::string name(const ElemQuality q)
void restrictRegisterableObjects(const std::vector< std::string > &names)
Calling this object with a non-empty vector will cause this factory to ignore registrations from any ...
void reportUnregisteredError(const std::string &obj_name) const
Prints error information when an object is not registered.
bool isRegistered(const std::string &obj_name) const
Returns a Boolean indicating whether an object type has been registered.
std::set< std::string > _deprecated_types
Set of deprecated object types that have been printed.
MooseApp & _app
Reference to the application.
Base class for everything in MOOSE with a name and a type.
Generic factory class for build all sorts of objects.
std::time_t parseTime(std::string)
Parse time string (mm/dd/yyyy HH:MM)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
std::string associatedClassName(const std::string &name) const
Get the associated class name for an object name.
FileLineInfoMap _name_to_line
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Base class for MOOSE-based applications.
std::unique_ptr< T > copyConstruct(const T &object)
Copy constructs the object object.
FileLineInfo getLineInfo(const std::string &name) const
Gets file and line information where an object was initially registered.
void deprecatedMessage(const std::string obj_name) const
Show the appropriate message for deprecated objects.
InputParameters & initialize(const std::string &type, const std::string &name, const InputParameters &from_params, const THREAD_ID tid)
Initializes the data structures and the parameters (in the InputParameterWarehouse) for the object wi...
std::map< std::string, std::time_t > _deprecated_time
Storage for deprecated object experiation dates.
void reg(std::shared_ptr< RegistryEntryBase > obj)
void associateNameToClass(const std::string &name, const std::string &class_name)
Associates an object name with a class name.
std::set< std::string > _registerable_objects
The list of objects that may be registered.
Every object that can be built by the factory should be derived from this class.
const auto & registeredObjects() const
Returns a reference to the map from names to RegistryEntryBase pointers.
std::vector< const InputParameters * > _currently_constructing
The object's parameters that are currently being constructed (if any).
std::map< std::string, std::string > _deprecated_name
Storage for the deprecated objects that have replacements.
std::string demangle(const char *name)
Holds file and line information.
std::map< std::string, std::string > _name_to_class
Object name to class name association.
void releaseSharedObjects(const MooseObject &moose_object, THREAD_ID tid=0)
Releases any shared resources created as a side effect of creating an object through the Factory::cre...
std::map< std::string, std::shared_ptr< RegistryEntryBase > > _name_to_object
Storage for pointers to the object registry entry.
void finalize(const std::string &type, const MooseObject &object)
Finalizes the creaction of object of type type.
std::vector< std::string > getConstructedObjects() const
Get a list of all constructed Moose Object types.
std::set< std::string > _constructed_types
Constructed Moose Object types.
std::map< const MooseObject *, unsigned int > _clone_counter
Counter for keeping track of the number of times an object with a given name has been cloned so that ...
std::unique_ptr< T > clone(const T &object)
Clones the object object.
A mapping between a series of keys to a FileLineInfo.
std::unique_ptr< MooseObject > createUnique(const std::string &obj_name, const std::string &name, const InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
const InputParameters * currentlyConstructing() const