https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WebServerControlTypeRegistry.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
12namespace Moose
13{
14WebServerControlTypeRegistry &
16{
17 static WebServerControlTypeRegistry * registry_singleton = nullptr;
18 if (!registry_singleton)
19 registry_singleton = new WebServerControlTypeRegistry;
20 return *registry_singleton;
21}
22
24WebServerControlTypeRegistry::query(const std::string & type)
25{
26 const auto & name_map = getRegistry()._name_map;
27 if (const auto it = name_map.find(type); it != name_map.end())
28 {
29 mooseAssert(it->second, "Item is nullptr");
30 return it->second.get();
31 }
32 return nullptr;
33}
34
36WebServerControlTypeRegistry::get(const std::string & type)
37{
38 if (const auto obj = query(type))
39 return *obj;
40 mooseError("WebServerControlTypeRegistry: The type '", type, "' is not registered");
41}
42
44 : _type(type)
45{
46}
47
49 const std::string & type)
50 : _name(name), _type(type)
51{
52}
53}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
ControlledValueBase(const std::string &name, const std::string &type)
Constructor.
Base registry class for a type that is used to build values.
A static registry used to register and build values of different types for the WebServerControl.
static const RegisteredTypeBase & get(const std::string &type)
Get the registration for the given type, erroring if it isn't registered.
static const RegisteredTypeBase * query(const std::string &type)
Query the registration for the given type.
static WebServerControlTypeRegistry & getRegistry()
std::map< std::string, std::unique_ptr< RegisteredTypeBase > > _name_map
The registration data.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...