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

A static registry used to register and build values of different types for the WebServerControl. More...

#include <WebServerControlTypeRegistry.h>

Classes

struct  Type
 
class  TypeBase
 Base registry class for a type that is used to build values. More...
 
class  ValueBase
 The base class for a value that is produced by this registry. More...
 

Static Public Member Functions

static WebServerControlTypeRegistrygetRegistry ()
 
template<typename DerivedValueType >
static char add (const std::string &type_name)
 Registers a type with string name type_name and the given derived type. More...
 
static bool isRegistered (const std::string &type)
 
static std::unique_ptr< ValueBasebuild (const std::string &type, const std::string &name)
 Builds a value with the type type, name name, and a default value. More...
 
static std::unique_ptr< ValueBasebuild (const std::string &type, const std::string &name, const miniJson::Json &json_value)
 Builds a value with the type type, name name, and a value parsed from json_value. More...
 

Static Private Member Functions

static const TypeBaseget (const std::string &type)
 Internal getter for the registration object for type type. More...
 

Private Attributes

std::map< std::string, std::unique_ptr< TypeBase > > _types
 The registration data. More...
 

Detailed Description

A static registry used to register and build values of different types for the WebServerControl.

Needed due to the complexities of parsing parameter types from generic JSON received by the web server.

Definition at line 30 of file WebServerControlTypeRegistry.h.

Member Function Documentation

◆ add()

template<typename DerivedValueType >
static char Moose::WebServerControlTypeRegistry::add ( const std::string &  type_name)
inlinestatic

Registers a type with string name type_name and the given derived type.

Definition at line 93 of file WebServerControlTypeRegistry.h.

Referenced by WebServerControl::registerScalarType(), and WebServerControl::registerVectorType().

94  {
95  static_assert(std::is_base_of_v<ValueBase, DerivedValueType>, "Is not derived from ValueBase");
96  getRegistry()._types.emplace(type_name, std::make_unique<Type<DerivedValueType>>(type_name));
97  return 0;
98  }
std::map< std::string, std::unique_ptr< TypeBase > > _types
The registration data.
static WebServerControlTypeRegistry & getRegistry()

◆ build() [1/2]

static std::unique_ptr<ValueBase> Moose::WebServerControlTypeRegistry::build ( const std::string &  type,
const std::string &  name 
)
inlinestatic

Builds a value with the type type, name name, and a default value.

Definition at line 108 of file WebServerControlTypeRegistry.h.

Referenced by build(), WebServerControl::execute(), and WebServerControl::startServer().

109  {
110  return get(type).build(name);
111  }
static std::unique_ptr< ValueBase > build(const std::string &type, const std::string &name)
Builds a value with the type type, name name, and a default value.

◆ build() [2/2]

static std::unique_ptr<ValueBase> Moose::WebServerControlTypeRegistry::build ( const std::string &  type,
const std::string &  name,
const miniJson::Json &  json_value 
)
inlinestatic

Builds a value with the type type, name name, and a value parsed from json_value.

Will throw ValueBase::Exception on a parsing error.

Definition at line 118 of file WebServerControlTypeRegistry.h.

119  {
120  return get(type).build(name, json_value);
121  }
static std::unique_ptr< ValueBase > build(const std::string &type, const std::string &name)
Builds a value with the type type, name name, and a default value.

◆ get()

static const TypeBase& Moose::WebServerControlTypeRegistry::get ( const std::string &  type)
inlinestaticprivate

Internal getter for the registration object for type type.

Definition at line 176 of file WebServerControlTypeRegistry.h.

177  {
178  auto & registry = getRegistry();
179  const auto it = registry._types.find(type);
180  if (it == registry._types.end())
181  mooseError("WebServerControlTypeRegistry: The type '", type, "' is not registered");
182  return *it->second;
183  }
static WebServerControlTypeRegistry & getRegistry()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302

◆ getRegistry()

WebServerControlTypeRegistry & Moose::WebServerControlTypeRegistry::getRegistry ( )
static
Returns
The WebServerControlTypeRegistry singleton

Definition at line 15 of file WebServerControlTypeRegistry.C.

Referenced by add(), get(), and isRegistered().

16 {
17  static WebServerControlTypeRegistry * registry_singleton = nullptr;
18  if (!registry_singleton)
19  registry_singleton = new WebServerControlTypeRegistry;
20  return *registry_singleton;
21 }

◆ isRegistered()

static bool Moose::WebServerControlTypeRegistry::isRegistered ( const std::string &  type)
inlinestatic
Returns
Whether or not the type type is registered.

Definition at line 103 of file WebServerControlTypeRegistry.h.

Referenced by WebServerControl::startServer().

103 { return getRegistry()._types.count(type); }
std::map< std::string, std::unique_ptr< TypeBase > > _types
The registration data.
static WebServerControlTypeRegistry & getRegistry()

Member Data Documentation

◆ _types

std::map<std::string, std::unique_ptr<TypeBase> > Moose::WebServerControlTypeRegistry::_types
private

The registration data.

Definition at line 186 of file WebServerControlTypeRegistry.h.

Referenced by add(), and isRegistered().


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