25 const std::string obj_name = obj->name();
26 const std::string & label = obj->_label;
27 const std::string & deprecated_time = obj->_deprecated_time;
28 const std::string & replacement_name = obj->_replaced_by;
29 const std::string & file = obj->_file;
30 const int line = obj->_line;
33 auto key = std::make_pair(label, obj_name);
50 mooseError(
"Object '" + obj_name +
"' registered from multiple files: ",
59 if (!replacement_name.empty())
61 if (!deprecated_time.empty())
80 auto params = it->second->buildParameters();
81 params.addPrivateParam(
"_moose_app", &
_app);
86 std::unique_ptr<MooseObject>
88 const std::string & name,
91 bool print_deprecated )
94 mooseDeprecated(
"Factory::create() is deprecated, please use Factory::create<T>() instead");
98 auto & warehouse_params =
initialize(obj_name,
name, parameters, tid);
110 std::shared_ptr<MooseObject>
112 const std::string & name,
115 bool print_deprecated )
117 std::shared_ptr<MooseObject>
object =
120 if (
auto fep = std::dynamic_pointer_cast<FEProblemBase>(
object))
142 if (t_str.size() != 16)
143 mooseError(
"The deprecated time not formatted correctly; it must be given as mm/dd/yyyy HH:MM");
147 struct tm * t_end_info;
149 t_end_info = localtime(&t_end);
150 t_end_info->tm_mon = std::atoi(t_str.substr(0, 2).c_str()) - 1;
151 t_end_info->tm_mday = std::atoi(t_str.substr(3, 2).c_str());
152 t_end_info->tm_year = std::atoi(t_str.substr(6, 4).c_str()) - 1900;
153 t_end_info->tm_hour = std::atoi(t_str.substr(11, 2).c_str()) + 1;
154 t_end_info->tm_min = std::atoi(t_str.substr(14, 2).c_str());
155 t_end_info->tm_sec = 0;
156 t_end = mktime(t_end_info);
183 std::time_t t_end = time_it->second;
186 std::ostringstream msg;
193 msg <<
"***** Invalid Object: " << obj_name <<
" *****\n";
194 msg <<
"Expired on " << ctime(&t_end);
198 msg <<
"Update your application using the '" << name_it->second <<
"' object";
208 msg <<
"Deprecated Object: " << obj_name <<
"\n";
209 msg <<
"This object will be removed on " << ctime(&t_end);
213 msg <<
"Replace " << obj_name <<
" with " << name_it->second;
224 std::ostringstream oss;
227 oss <<
"A '" + obj_name +
"' is not a registered object.\n";
231 oss <<
"\nWe loaded objects from the following libraries and still couldn't find your " 233 std::copy(paths.begin(), paths.end(), infix_ostream_iterator<std::string>(oss,
"\n\t"));
237 oss <<
"\nIf you are trying to find this object in a dynamically loaded library, make sure that\n" 238 "the library can be found either in your \"Problem/library_path\" parameter or in the\n" 239 "MOOSE_LIBRARY_PATH environment variable.";
244 std::vector<std::string>
247 std::vector<std::string> list;
249 list.push_back(
name);
283 const std::string & name,
310 params.
set<std::string>(
"_type") = type;
332 const auto & object_params =
object.parameters();
333 if (orig_params.
n_parameters() != object_params.n_parameters())
335 std::set<std::string> orig, populated;
336 for (
const auto & it : orig_params)
337 orig.emplace(it.first);
338 for (
const auto & it : object_params)
339 populated.emplace(it.first);
341 std::set<std::string> diff;
342 std::set_difference(populated.begin(),
346 std::inserter(diff, diff.begin()));
350 std::stringstream ss;
351 for (
const auto &
name : diff)
353 object.mooseError(
"Attempted to set unregistered parameter(s):\n ", ss.str().substr(2));
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 show_trace
Set to true (the default) to print the stack trace with error and warning messages - false to omit it...
std::set< std::string > _deprecated_types
Set of deprecated object types that have been printed.
MooseApp & _app
Reference to the application.
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...
InputParameterWarehouse & getInputParameterWarehouse()
Get the InputParameterWarehouse for MooseObjects.
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)
void mooseDeprecationExpired(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Base class for MOOSE-based applications.
const hit::Node * getCurrentActionHitNode() const
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.
FileLineInfo getLineInfo(const std::string &name) const
Gets file and line information where an object was initially registered.
std::shared_ptr< FEProblemBase > & problemBase()
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 expiration 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.
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
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.
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::size_t n_parameters() const
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
std::set< std::string > getLoadedLibraryPaths() const
Return the paths of loaded libraries.