Go to the documentation of this file.
22 const std::string & obj_name,
25 const std::string & deprecated_time,
26 const std::string & replacement_name,
27 const std::string & file,
31 auto key = std::make_pair(label, obj_name);
48 mooseError(
"Object '" + obj_name +
"' registered from multiple files: ",
58 if (!replacement_name.empty())
60 if (!deprecated_time.empty())
94 const std::string & name,
97 bool print_deprecated )
100 mooseDeprecated(
"Factory::create() is deprecated, please use Factory::create<T>() instead");
117 params.
set<std::string>(
"_type") = obj_name;
131 auto obj = (*func)(params);
133 auto fep = std::dynamic_pointer_cast<FEProblemBase>(obj);
141 if (orig_params.n_parameters() != parameters.n_parameters())
143 std::set<std::string> orig, populated;
144 for (
const auto & it : orig_params)
145 orig.emplace(it.first);
146 for (
const auto & it : parameters)
147 populated.emplace(it.first);
149 std::set<std::string> diff;
150 std::set_difference(populated.begin(),
154 std::inserter(diff, diff.begin()));
158 std::stringstream ss;
159 for (
const auto & name : diff)
161 mooseError(
"attempted to set unregistered parameter(s) for ",
187 if (t_str.size() != 16)
188 mooseError(
"The deprecated time not formatted correctly; it must be given as mm/dd/yyyy HH:MM");
192 struct tm * t_end_info;
194 t_end_info = localtime(&t_end);
195 t_end_info->tm_mon = std::atoi(t_str.substr(0, 2).c_str()) - 1;
196 t_end_info->tm_mday = std::atoi(t_str.substr(3, 2).c_str());
197 t_end_info->tm_year = std::atoi(t_str.substr(6, 4).c_str()) - 1900;
198 t_end_info->tm_hour = std::atoi(t_str.substr(11, 2).c_str()) + 1;
199 t_end_info->tm_min = std::atoi(t_str.substr(14, 2).c_str());
200 t_end_info->tm_sec = 0;
201 t_end = mktime(t_end_info);
208 std::map<std::string, std::time_t>::iterator time_it =
_deprecated_time.find(obj_name);
219 std::time_t t_end = time_it->second;
222 std::ostringstream msg;
224 std::map<std::string, std::string>::iterator name_it =
_deprecated_name.find(obj_name);
229 msg <<
"***** Invalid Object: " << obj_name <<
" *****\n";
230 msg <<
"Expired on " << ctime(&t_end);
234 msg <<
"Update your application using the '" << name_it->second <<
"' object";
244 msg <<
"Deprecated Object: " << obj_name <<
"\n";
245 msg <<
"This object will be removed on " << ctime(&t_end);
249 msg <<
"Replace " << obj_name <<
" with " << name_it->second;
262 std::ostringstream oss;
265 oss <<
"A '" + obj_name +
"' is not a registered object.\n";
269 oss <<
"\nWe loaded objects from the following libraries and still couldn't find your "
275 oss <<
"\nIf you are trying to find this object in a dynamically linked library, make sure that\n"
276 "the library can be found either in your \"Problem/library_path\" parameter or in the\n"
277 "MOOSE_LIBRARY_PATH environment variable.";
282 std::vector<std::string>
285 std::vector<std::string> list;
287 list.push_back(name);
InputParameterWarehouse & getInputParameterWarehouse()
Get the InputParameterWarehouse for MooseObjects.
std::shared_ptr< MooseObject > MooseObjectPtr
alias to wrap shared pointer type
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>())
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
std::map< std::string, std::string > _deprecated_name
Storage for the deprecated objects that have replacements.
FileLineInfoMap _name_to_line
std::map< std::string, paramsPtr > _name_to_params_pointer
Storage for pointers to the parameters objects.
void reportUnregisteredError(const std::string &obj_name) const
Prints error information when an object is not registered.
void associateNameToClass(const std::string &name, const std::string &class_name)
Associates an object name with a class name.
std::time_t parseTime(std::string)
Parse time string (mm/dd/yyyy HH:MM)
FileLineInfo getLineInfo(const std::string &name) const
Gets file and line information where an object was initially registered.
virtual void checkRegistryLabels()
std::set< std::string > getLoadedLibraryPaths() const
Return the loaded library filenames in a std::set.
std::map< std::string, std::string > _name_to_class
Object name to class name association.
std::set< std::string > _registerable_objects
The list of objects that may be registered.
Holds file and line information.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Every object that can be built by the factory should be derived from this class.
MooseObjectPtr(*)(const InputParameters ¶meters) buildPtr
alias for method to build objects
std::vector< std::string > getConstructedObjects() const
Get a list of all constructed Moose Object types.
std::map< std::string, buildPtr > _name_to_build_pointer
Storage for pointers to the object.
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 mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Class for containing MooseEnum item information.
void deprecatedMessage(const std::string obj_name)
Show the appropriate message for deprecated objects.
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
void reg(const std::string &obj_name, const std::string &file="", int line=-1)
Register a new object.
std::string associatedClassName(const std::string &name) const
Get the associated class name for an object name.
void regExecFlag(const ExecFlagType &flag)
Add a new flag to the app.
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::map< std::string, std::time_t > _deprecated_time
Storage for deprecated object experiation dates.
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.
Base class for MOOSE-based applications.
std::shared_ptr< FEProblemBase > & problemBase()
std::set< std::string > _constructed_types
Constructed Moose Object types.
void addExecFlag(const ExecFlagType &flag)
WARNING: This is an internal method for MOOSE, if you need the add new ExecFlagTypes then use the reg...
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...
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
void mooseDeprecationExpired(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
MooseApp & _app
Reference to the application.
InputParameters(*)() paramsPtr
alias for validParams function
InputParameters getADValidParams(const std::string &name)