https://mooseframework.inl.gov
Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Registry Class Reference

The registry is used as a global singleton to collect information on all available MooseObject and Action classes for use in a moose app/simulation. More...

#include <Registry.h>

Public Member Functions

 Registry (Registry const &)=delete
 Don't allow creation through copy/move construction or assignment. More...
 
Registryoperator= (Registry const &)=delete
 
 Registry (Registry &&)=delete
 
Registryoperator= (Registry &&)=delete
 

Static Public Member Functions

static RegistrygetRegistry ()
 Get the global Registry singleton. More...
 
template<typename T >
static char add (const RegistryEntryData &base_info)
 Adds information on a MooseObject to the registry. More...
 
template<typename T >
static char addAction (const RegistryEntryData &base_info)
 Adds information on an Action object to the registry. More...
 
template<typename T >
static std::string getClassName ()
 
static void registerObjectsTo (Factory &f, const std::set< std::string > &labels)
 This registers all MooseObjects known to the registry that have the given label(s) with the factory f. More...
 
static void registerActionsTo (ActionFactory &f, const std::set< std::string > &labels)
 This registers all Actions known to the registry that have the given label(s) with the factory f. More...
 
static char addKnownLabel (const std::string &label)
 addKnownLabel whitelists a label as valid for purposes of the checkLabels function. More...
 
static void addDataFilePath (const std::string &name, const std::string &in_tree_path, const bool app=true, const std::optional< std::string > &info={})
 register general search paths; "app" is whether or not the path is an app path More...
 
static void addAppDataFilePath (const std::string &app_name, const std::string &app_path)
 register search paths for an application (path determined relative to app_path); app_path should be passed as FILE from the application source file More...
 
static void addMissingDataFilePath (const std::string &name, const std::string &info)
 register a data file path as missing, along with info about how it can be added More...
 
static void addDeprecatedAppDataFilePath (const std::string &app_path)
 deprecated method; use addAppDataFilePath instead More...
 
static void addRepository (const std::string &repo_name, const std::string &repo_url)
 register a repository More...
 
static const std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > & allObjects ()
 Returns a per-label keyed map of all MooseObjects in the registry. More...
 
static const std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > & allActions ()
 Returns a per-label keyed map of all Actions in the registry. More...
 
static const RegistryEntryBaseobjData (const std::string &name)
 
static bool isRegisteredObj (const std::string &name)
 
static const std::map< std::string, std::string > & getDataFilePaths ()
 Returns a map of all registered data file paths (name -> path) More...
 
static std::string getDataFilePath (const std::string &name)
 Gets a data path for the registered name. More...
 
static const std::string & getRepositoryURL (const std::string &repo_name)
 Returns the repository URL associated with repo_name. More...
 
static const std::map< std::string, std::string > & getRepos ()
 Returns a map of all registered repositories. More...
 
template<typename T >
static std::string getRegisteredName ()
 returns the name() for a registered class More...
 

Private Member Functions

 Registry ()
 

Static Private Member Functions

static void setDataFilePaths (const std::map< std::string, std::string > &data_file_paths)
 Manually set the data file paths. More...
 
static void setRepos (const std::map< std::string, std::string > &repos)
 Manually set the repos. More...
 
static std::string determineDataFilePath (const std::string &name, const std::string &in_tree_path)
 Internal helper for determing a root data file path (in-tree vs installed) More...
 
static std::string appNameFromAppPath (const std::string &app_path)
 Internal helper for getting an application name from its path, for example: /path/to/FooBarBazApp.C -> foo_bar_baz, for use in addDeprecatedAppDataFilePath. More...
 
static void checkDataFilePathName (const std::string &name)
 Check a data file path for valid characters. More...
 
static void addDataFilePathCapability (const std::string &name, const std::optional< std::string > &path={}, const std::optional< std::string > &extra_info={})
 Add a data file path capability. More...
 

Private Attributes

std::map< std::string, std::shared_ptr< RegistryEntryBase > > _name_to_entry
 
std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > _per_label_objects
 
std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > _per_label_actions
 
std::set< std::string > _known_labels
 
std::map< std::string, std::string > _data_file_paths
 Data file registry; name -> in-tree path. More...
 
std::map< std::string, std::string > _repos
 Repository name -> repository URL; used for mooseDocumentedError. More...
 
std::map< std::string, std::string > _type_to_classname
 
class RegistryTest
 Friends for unit testing. More...
 
class DataFileUtilsTest
 
 FRIEND_TEST (RegistryTest, determineFilePath)
 
 FRIEND_TEST (RegistryTest, determineFilePathFailed)
 
 FRIEND_TEST (RegistryTest, appNameFromAppPath)
 
 FRIEND_TEST (RegistryTest, appNameFromAppPathFailed)
 
 FRIEND_TEST (RegistryTest, addDataFilePathCapability)
 

Detailed Description

The registry is used as a global singleton to collect information on all available MooseObject and Action classes for use in a moose app/simulation.

It must be global because we want+need to be able to register objects in global scope during static initialization time before other parts of the moose app execution have started running. This allows us to distribute registration across all the files that define the actual classes being registered so we don't have to have any central location with a bajillion includes that makes (especially incremental) compiles slow. The registry collects the app, name, and other information for each objects and makes it available to the moose object and action factories and others for general use. All public functions in this class modify and return data from the global singleton.

Definition at line 171 of file Registry.h.

Constructor & Destructor Documentation

◆ Registry() [1/3]

Registry::Registry ( Registry const &  )
delete

Don't allow creation through copy/move construction or assignment.

◆ Registry() [2/3]

Registry::Registry ( Registry &&  )
delete

◆ Registry() [3/3]

Registry::Registry ( )
inlineprivate

Definition at line 302 of file Registry.h.

Referenced by getRegistry().

302 {};

Member Function Documentation

◆ add()

template<typename T >
static char Registry::add ( const RegistryEntryData base_info)
inlinestatic

Adds information on a MooseObject to the registry.

The _build_ptr, _build_action_ptr, and _params_ptr objects of the info object should all be nullptr - these are set automatically by the add function itself using the templated type T.

Definition at line 183 of file Registry.h.

184  {
185  const auto info = std::make_shared<RegistryEntry<T>>(base_info);
186  getRegistry()._per_label_objects[info->_label].push_back(info);
187  getRegistry()._type_to_classname[typeid(T).name()] = info->name();
188  return 0;
189  }
std::string name(const ElemQuality q)
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
MPI_Info info
std::map< std::string, std::string > _type_to_classname
Definition: Registry.h:347
std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > _per_label_objects
Definition: Registry.h:340

◆ addAction()

template<typename T >
static char Registry::addAction ( const RegistryEntryData base_info)
inlinestatic

Adds information on an Action object to the registry.

The _build_ptr, _build_action_ptr, and _params_ptr objects of the info object should all be nullptr - these are set automatically by the addAction function itself using the templated type T.

Definition at line 195 of file Registry.h.

196  {
197  const auto info = std::make_shared<RegistryEntry<T>>(base_info);
198  getRegistry()._per_label_actions[info->_label].push_back(info);
199  getRegistry()._type_to_classname[typeid(T).name()] = info->_classname;
200  return 0;
201  }
std::string name(const ElemQuality q)
std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > _per_label_actions
Definition: Registry.h:341
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
MPI_Info info
std::map< std::string, std::string > _type_to_classname
Definition: Registry.h:347

◆ addAppDataFilePath()

void Registry::addAppDataFilePath ( const std::string &  app_name,
const std::string &  app_path 
)
static

register search paths for an application (path determined relative to app_path); app_path should be passed as FILE from the application source file

Definition at line 144 of file Registry.C.

Referenced by addDeprecatedAppDataFilePath().

145 {
146  // split the *App.C filename from its containing directory
147  const auto dir = MooseUtils::splitFileName(app_path).first;
148  // This works for both build/unity_src/ and src/base/ as the *App.C file location,
149  // in case __FILE__ doesn't get overriden in unity build
150  addDataFilePath(app_name, MooseUtils::pathjoin(dir, "../../data"));
151 }
static void addDataFilePath(const std::string &name, const std::string &in_tree_path, const bool app=true, const std::optional< std::string > &info={})
register general search paths; "app" is whether or not the path is an app path
Definition: Registry.C:92
std::filesystem::path pathjoin(const std::filesystem::path &p)
Definition: MooseUtils.C:59

◆ addDataFilePath()

void Registry::addDataFilePath ( const std::string &  name,
const std::string &  in_tree_path,
const bool  app = true,
const std::optional< std::string > &  info = {} 
)
static

register general search paths; "app" is whether or not the path is an app path

Definition at line 92 of file Registry.C.

Referenced by addAppDataFilePath().

96 {
98 
99  // Enforce that the folder is called "data", because we rely on the installed path
100  // to be within PREFIX/share/<name>/data (see determineDataFilePath())
101  if (is_app)
102  {
103  const std::string folder = std::filesystem::path(in_tree_path).filename().c_str();
104  if (folder != "data")
105  mooseError("While registering data file path '",
106  in_tree_path,
107  "' for '",
108  name,
109  "': The folder must be named 'data' and it is named '",
110  folder,
111  "'");
112  }
113 
114  // Find either the installed or in-tree path
115  const auto path = determineDataFilePath(name, in_tree_path);
116 
117  auto & dfp = getRegistry()._data_file_paths;
118  const auto it = dfp.find(name);
119  // Not registered yet
120  if (it == dfp.end())
121  {
122  dfp.emplace(name, path);
123  addDataFilePathCapability(name, path, info);
124  }
125  // Registered, but with a different value
126  else if (it->second != path)
127  mooseError("While registering data file path '",
128  path,
129  "' for '",
130  name,
131  "': the path '",
132  it->second,
133  "' is already registered");
134 }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
MPI_Info info
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
static std::string determineDataFilePath(const std::string &name, const std::string &in_tree_path)
Internal helper for determing a root data file path (in-tree vs installed)
Definition: Registry.C:198
static void addDataFilePathCapability(const std::string &name, const std::optional< std::string > &path={}, const std::optional< std::string > &extra_info={})
Add a data file path capability.
Definition: Registry.C:256
std::map< std::string, std::string > _data_file_paths
Data file registry; name -> in-tree path.
Definition: Registry.h:344
static void checkDataFilePathName(const std::string &name)
Check a data file path for valid characters.
Definition: Registry.C:247

◆ addDataFilePathCapability()

void Registry::addDataFilePathCapability ( const std::string &  name,
const std::optional< std::string > &  path = {},
const std::optional< std::string > &  extra_info = {} 
)
staticprivate

Add a data file path capability.

Definition at line 256 of file Registry.C.

Referenced by addDataFilePath(), and addMissingDataFilePath().

259 {
260  std::string doc = "Named data path '" + name + "' is ";
261  if (path)
262  doc += "available at '" + *path + "'";
263  else
264  doc += "not available";
265  if (extra_info)
266  doc += "; " + *extra_info;
267  doc += ".";
268 
269  auto & capabilities = Moose::internal::Capabilities::getCapabilities({});
270  capabilities.add("data_" + name, bool(path), doc);
271 }
std::string name(const ElemQuality q)
static Capabilities & getCapabilities(const GetCapabilitiesPassKey)
Get the singleton Capabilities.
Definition: Capabilities.C:52
Capability & add(const std::string_view name, const Moose::Capability::Value &value, const std::string_view doc)
Add a capability.

◆ addDeprecatedAppDataFilePath()

void Registry::addDeprecatedAppDataFilePath ( const std::string &  app_path)
static

deprecated method; use addAppDataFilePath instead

Definition at line 154 of file Registry.C.

155 {
156  const auto app_name = appNameFromAppPath(app_path);
157  mooseDeprecated("In ",
158  app_path,
159  ":\nregisterDataFilePath() is deprecated. Use registerAppDataFilePath(\"",
160  app_name,
161  "\") instead.");
162  addAppDataFilePath(app_name, app_path);
163 }
static std::string appNameFromAppPath(const std::string &app_path)
Internal helper for getting an application name from its path, for example: /path/to/FooBarBazApp.C -> foo_bar_baz, for use in addDeprecatedAppDataFilePath.
Definition: Registry.C:225
static void addAppDataFilePath(const std::string &app_name, const std::string &app_path)
register search paths for an application (path determined relative to app_path); app_path should be p...
Definition: Registry.C:144
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:363

◆ addKnownLabel()

char Registry::addKnownLabel ( const std::string &  label)
static

addKnownLabel whitelists a label as valid for purposes of the checkLabels function.

Definition at line 85 of file Registry.C.

86 {
87  getRegistry()._known_labels.insert(label);
88  return 0;
89 }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
std::set< std::string > _known_labels
Definition: Registry.h:342

◆ addMissingDataFilePath()

void Registry::addMissingDataFilePath ( const std::string &  name,
const std::string &  info 
)
static

register a data file path as missing, along with info about how it can be added

Definition at line 137 of file Registry.C.

138 {
139  checkDataFilePathName(name);
140  addDataFilePathCapability(name, {}, info);
141 }
MPI_Info info
static void addDataFilePathCapability(const std::string &name, const std::optional< std::string > &path={}, const std::optional< std::string > &extra_info={})
Add a data file path capability.
Definition: Registry.C:256
static void checkDataFilePathName(const std::string &name)
Check a data file path for valid characters.
Definition: Registry.C:247

◆ addRepository()

void Registry::addRepository ( const std::string &  repo_name,
const std::string &  repo_url 
)
static

register a repository

Definition at line 176 of file Registry.C.

177 {
178  auto & repos = getRegistry()._repos;
179  const auto [it, inserted] = repos.emplace(repo_name, repo_url);
180  if (!inserted && it->second != repo_url)
181  mooseError("Registry::registerRepository(): The repository '",
182  repo_name,
183  "' is already registered with a different URL '",
184  it->second,
185  "'.");
186 }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::map< std::string, std::string > _repos
Repository name -> repository URL; used for mooseDocumentedError.
Definition: Registry.h:346

◆ allActions()

static const std::map<std::string, std::vector<std::shared_ptr<RegistryEntryBase> > >& Registry::allActions ( )
inlinestatic

Returns a per-label keyed map of all Actions in the registry.

Definition at line 242 of file Registry.h.

Referenced by JsonSyntaxTree::JsonSyntaxTree(), and MooseApp::setupOptions().

243  {
245  }
std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > _per_label_actions
Definition: Registry.h:341
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24

◆ allObjects()

static const std::map<std::string, std::vector<std::shared_ptr<RegistryEntryBase> > >& Registry::allObjects ( )
inlinestatic

Returns a per-label keyed map of all MooseObjects in the registry.

Definition at line 237 of file Registry.h.

Referenced by JsonSyntaxTree::JsonSyntaxTree(), and MooseApp::setupOptions().

238  {
240  }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > _per_label_objects
Definition: Registry.h:340

◆ appNameFromAppPath()

std::string Registry::appNameFromAppPath ( const std::string &  app_path)
staticprivate

Internal helper for getting an application name from its path, for example: /path/to/FooBarBazApp.C -> foo_bar_baz, for use in addDeprecatedAppDataFilePath.

Definition at line 225 of file Registry.C.

Referenced by addDeprecatedAppDataFilePath().

226 {
227  // This is for deprecated use only. It assumes that the application name
228  // (binary name) in the build follows our normal naming of FooBarApp -> foo_bar.
229  // We need to convert the application source file to the above, for example:
230  // /path/to/FooBarBazApp.C -> foo_bar_baz
231  // Ideally, we would instead have the user specify this manually so that
232  // there is no ambiguity.
233  std::smatch match;
234  if (std::regex_search(app_path, match, std::regex("\\/([a-zA-Z0-9_]+)App\\.C$")))
235  {
236  std::string name = match[1]; // FooBarBaz
237  name = std::regex_replace(name, std::regex("(?!^)([A-Z])"), "_$1"); // Foo_Bar_Baz
238  name = MooseUtils::toLower(name); // foo_bar_baz
239  return name;
240  }
241 
242  mooseError(
243  "Registry::appNameFromAppPath(): Failed to parse application name from '", app_path, "'");
244 }
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::string toLower(std::string name)
Convert supplied string to lower case.

◆ checkDataFilePathName()

void Registry::checkDataFilePathName ( const std::string &  name)
staticprivate

Check a data file path for valid characters.

Definition at line 247 of file Registry.C.

Referenced by addDataFilePath(), and addMissingDataFilePath().

248 {
249  if (!std::regex_search(name, std::regex("[a-z0-9_]+")))
250  mooseError("Unallowed characters in data file path name '",
251  name,
252  "'; allowed characters = a-z, 0-9, _");
253 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311

◆ determineDataFilePath()

std::string Registry::determineDataFilePath ( const std::string &  name,
const std::string &  in_tree_path 
)
staticprivate

Internal helper for determing a root data file path (in-tree vs installed)

Definition at line 198 of file Registry.C.

Referenced by addDataFilePath().

199 {
200  // TODO: Track whether or not the application is installed in a better way
201  // than this, which will enable us to pick one or the other based on
202  // the install state. This probably also won't work with dynamic loading, where
203  // we can't necessarily get this information from the binary (as there could be
204  // multiple binary paths)
205 
206  // Installed data
207  const auto installed_path =
208  MooseUtils::pathjoin(Moose::getExecutablePath(), "..", "share", name, "data");
209  if (MooseUtils::checkFileReadable(installed_path, false, false, false))
210  return MooseUtils::canonicalPath(installed_path);
211 
212  // In tree data
213  if (MooseUtils::checkFileReadable(in_tree_path, false, false, false))
214  return MooseUtils::canonicalPath(in_tree_path);
215 
216  mooseError("Failed to determine data file path for '",
217  name,
218  "'. Paths searched:\n\n installed: ",
219  installed_path,
220  "\n in-tree: ",
221  in_tree_path);
222 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::string getExecutablePath()
Gets the directory the running executable is on Mac OS X and linux.
std::string canonicalPath(const std::string &path)
Definition: MooseUtils.C:1173
std::filesystem::path pathjoin(const std::filesystem::path &p)
Definition: MooseUtils.C:59
bool checkFileReadable(const std::string &filename, bool check_line_endings, bool throw_on_unreadable, bool check_for_git_lfs_pointer)
Definition: MooseUtils.C:254

◆ FRIEND_TEST() [1/5]

Registry::FRIEND_TEST ( RegistryTest  ,
determineFilePath   
)
private

◆ FRIEND_TEST() [2/5]

Registry::FRIEND_TEST ( RegistryTest  ,
determineFilePathFailed   
)
private

◆ FRIEND_TEST() [3/5]

Registry::FRIEND_TEST ( RegistryTest  ,
appNameFromAppPath   
)
private

◆ FRIEND_TEST() [4/5]

Registry::FRIEND_TEST ( RegistryTest  ,
appNameFromAppPathFailed   
)
private

◆ FRIEND_TEST() [5/5]

Registry::FRIEND_TEST ( RegistryTest  ,
addDataFilePathCapability   
)
private

◆ getClassName()

template<typename T >
static std::string Registry::getClassName ( )
inlinestatic

Definition at line 204 of file Registry.h.

205  {
206  return libmesh_map_find(getRegistry()._type_to_classname, typeid(T).name());
207  }
std::string name(const ElemQuality q)
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
std::map< std::string, std::string > _type_to_classname
Definition: Registry.h:347

◆ getDataFilePath()

std::string Registry::getDataFilePath ( const std::string &  name)
static

Gets a data path for the registered name.

Finds either the installed path or the in-tree path.

Definition at line 166 of file Registry.C.

167 {
168  const auto & dfps = getRegistry()._data_file_paths;
169  const auto it = dfps.find(name);
170  if (it == dfps.end())
171  mooseError("Registry::getDataFilePath(): A data file path for '", name, "' is not registered");
172  return it->second;
173 }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::map< std::string, std::string > _data_file_paths
Data file registry; name -> in-tree path.
Definition: Registry.h:344

◆ getDataFilePaths()

static const std::map<std::string, std::string>& Registry::getDataFilePaths ( )
inlinestatic

Returns a map of all registered data file paths (name -> path)

Definition at line 258 of file Registry.h.

Referenced by Moose::DataFileUtils::getPath(), and ConsoleUtils::outputDataFilePaths().

259  {
260  return getRegistry()._data_file_paths;
261  }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
std::map< std::string, std::string > _data_file_paths
Data file registry; name -> in-tree path.
Definition: Registry.h:344

◆ getRegisteredName()

template<typename T >
std::string Registry::getRegisteredName ( )
static

returns the name() for a registered class

Definition at line 352 of file Registry.h.

353 {
354  mooseDeprecated("Use Registry::getClassName() instead.");
355  return getClassName<T>();
356 }
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:363

◆ getRegistry()

Registry & Registry::getRegistry ( )
static

Get the global Registry singleton.

Definition at line 24 of file Registry.C.

Referenced by add(), addAction(), addDataFilePath(), addKnownLabel(), addRepository(), allActions(), allObjects(), getClassName(), getDataFilePath(), getDataFilePaths(), Moose::DataFileUtils::getPath(), getRepos(), getRepositoryURL(), isRegisteredObj(), objData(), registerActionsTo(), registerObjectsTo(), setDataFilePaths(), and setRepos().

25 {
26  // We need a naked new here (_not_ a smart pointer or object instance) due to what seems like a
27  // bug in clang's static object destruction when using dynamic library loading.
28  static Registry * registry_singleton = nullptr;
29  if (!registry_singleton)
30  registry_singleton = new Registry();
31  return *registry_singleton;
32 }
Registry()
Definition: Registry.h:302
The registry is used as a global singleton to collect information on all available MooseObject and Ac...
Definition: Registry.h:171

◆ getRepos()

static const std::map<std::string, std::string>& Registry::getRepos ( )
inlinestatic

Returns a map of all registered repositories.

Definition at line 274 of file Registry.h.

274 { return getRegistry()._repos; }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
std::map< std::string, std::string > _repos
Repository name -> repository URL; used for mooseDocumentedError.
Definition: Registry.h:346

◆ getRepositoryURL()

const std::string & Registry::getRepositoryURL ( const std::string &  repo_name)
static

Returns the repository URL associated with repo_name.

Definition at line 189 of file Registry.C.

Referenced by moose::internal::formatMooseDocumentedError().

190 {
191  const auto & repos = getRegistry()._repos;
192  if (const auto it = repos.find(repo_name); it != repos.end())
193  return it->second;
194  mooseError("Registry::getRepositoryURL(): The repository '", repo_name, "' is not registered.");
195 }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::map< std::string, std::string > _repos
Repository name -> repository URL; used for mooseDocumentedError.
Definition: Registry.h:346

◆ isRegisteredObj()

static bool Registry::isRegisteredObj ( const std::string &  name)
inlinestatic
Returns
true if an object with the given name is registered

Definition at line 252 of file Registry.h.

Referenced by MooseObject::MooseObject().

253  {
254  return getRegistry()._name_to_entry.count(name);
255  }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
std::map< std::string, std::shared_ptr< RegistryEntryBase > > _name_to_entry
Definition: Registry.h:339

◆ objData()

const RegistryEntryBase & Registry::objData ( const std::string &  name)
static

Definition at line 58 of file Registry.C.

59 {
60  auto & r = getRegistry();
61 
62  if (const auto it = r._name_to_entry.find(name); it != r._name_to_entry.end())
63  return *it->second;
64  else
65  mooseError("Object ", name, " is not registered yet");
66 }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311

◆ operator=() [1/2]

Registry& Registry::operator= ( Registry const &  )
delete

◆ operator=() [2/2]

Registry& Registry::operator= ( Registry &&  )
delete

◆ registerActionsTo()

void Registry::registerActionsTo ( ActionFactory f,
const std::set< std::string > &  labels 
)
static

This registers all Actions known to the registry that have the given label(s) with the factory f.

Definition at line 69 of file Registry.C.

Referenced by Moose::registerActions().

70 {
71  auto & r = getRegistry();
72 
73  for (const auto & label : labels)
74  {
75  r._known_labels.insert(label);
76  if (r._per_label_actions.count(label) == 0)
77  continue;
78 
79  for (const auto & obj : r._per_label_actions[label])
80  f.reg(obj);
81  }
82 }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
void reg(std::shared_ptr< RegistryEntryBase > obj)
Definition: ActionFactory.C:22

◆ registerObjectsTo()

void Registry::registerObjectsTo ( Factory f,
const std::set< std::string > &  labels 
)
static

This registers all MooseObjects known to the registry that have the given label(s) with the factory f.

Definition at line 35 of file Registry.C.

Referenced by Moose::registerObjects().

36 {
37  auto & r = getRegistry();
38 
39  for (const auto & label : labels)
40  {
41  r._known_labels.insert(label);
42  if (r._per_label_objects.count(label) == 0)
43  continue;
44 
45  for (const auto & obj : r._per_label_objects[label])
46  {
47  const auto name = obj->name();
48  r._name_to_entry[name] = obj;
49 
50  f.reg(obj);
51  if (!obj->_alias.empty())
52  f.associateNameToClass(name, obj->_classname);
53  }
54  }
55 }
std::string name(const ElemQuality q)
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
void reg(std::shared_ptr< RegistryEntryBase > obj)
Definition: Factory.C:23
void associateNameToClass(const std::string &name, const std::string &class_name)
Associates an object name with a class name.
Definition: Factory.C:290

◆ setDataFilePaths()

static void Registry::setDataFilePaths ( const std::map< std::string, std::string > &  data_file_paths)
inlinestaticprivate

Manually set the data file paths.

Used in unit testing.

Definition at line 309 of file Registry.h.

310  {
311  getRegistry()._data_file_paths = data_file_paths;
312  }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
std::map< std::string, std::string > _data_file_paths
Data file registry; name -> in-tree path.
Definition: Registry.h:344

◆ setRepos()

static void Registry::setRepos ( const std::map< std::string, std::string > &  repos)
inlinestaticprivate

Manually set the repos.

Used in unit testing

Definition at line 318 of file Registry.h.

319  {
320  getRegistry()._repos = repos;
321  }
static Registry & getRegistry()
Get the global Registry singleton.
Definition: Registry.C:24
std::map< std::string, std::string > _repos
Repository name -> repository URL; used for mooseDocumentedError.
Definition: Registry.h:346

Friends And Related Function Documentation

◆ DataFileUtilsTest

friend class DataFileUtilsTest
friend

Definition at line 293 of file Registry.h.

◆ RegistryTest

friend class RegistryTest
friend

Friends for unit testing.

Definition at line 292 of file Registry.h.

Member Data Documentation

◆ _data_file_paths

std::map<std::string, std::string> Registry::_data_file_paths
private

Data file registry; name -> in-tree path.

Definition at line 344 of file Registry.h.

Referenced by addDataFilePath(), getDataFilePath(), getDataFilePaths(), and setDataFilePaths().

◆ _known_labels

std::set<std::string> Registry::_known_labels
private

Definition at line 342 of file Registry.h.

Referenced by addKnownLabel().

◆ _name_to_entry

std::map<std::string, std::shared_ptr<RegistryEntryBase> > Registry::_name_to_entry
private

Definition at line 339 of file Registry.h.

Referenced by isRegisteredObj().

◆ _per_label_actions

std::map<std::string, std::vector<std::shared_ptr<RegistryEntryBase> > > Registry::_per_label_actions
private

Definition at line 341 of file Registry.h.

Referenced by addAction(), and allActions().

◆ _per_label_objects

std::map<std::string, std::vector<std::shared_ptr<RegistryEntryBase> > > Registry::_per_label_objects
private

Definition at line 340 of file Registry.h.

Referenced by add(), and allObjects().

◆ _repos

std::map<std::string, std::string> Registry::_repos
private

Repository name -> repository URL; used for mooseDocumentedError.

Definition at line 346 of file Registry.h.

Referenced by addRepository(), getRepos(), getRepositoryURL(), and setRepos().

◆ _type_to_classname

std::map<std::string, std::string> Registry::_type_to_classname
private

Definition at line 347 of file Registry.h.

Referenced by add(), addAction(), and getClassName().


The documentation for this class was generated from the following files: