https://mooseframework.inl.gov
Public Member Functions | Private Attributes | List of all members
Moose::WebServerControlTypeRegistry::RegisteredType< ControlledValue, ValueType > Struct Template Reference

Derived registry item. More...

#include <WebServerControlTypeRegistry.h>

Inheritance diagram for Moose::WebServerControlTypeRegistry::RegisteredType< ControlledValue, ValueType >:
[legend]

Public Member Functions

 RegisteredType (const std::string &type, std::function< ValueType(const nlohmann::json &)> &&parse_function)
 
virtual std::unique_ptr< ControlledValueBasebuild (const std::string &name) const override final
 Builds a value with the given type, name name, and a default value. More...
 
virtual std::unique_ptr< ControlledValueBasebuild (const std::string &name, const nlohmann::json &json_value) const override final
 Builds a value with the given type, name name, and JSON value json_value. More...
 
const std::string & type () const
 

Private Attributes

const std::function< ValueType(const nlohmann::json &)> _parse_function
 Function that converts from json -> the value for the ValueType. More...
 

Detailed Description

template<class ControlledValue, class ValueType>
struct Moose::WebServerControlTypeRegistry::RegisteredType< ControlledValue, ValueType >

Derived registry item.

Stores how to build the value and how to parse the value from JSON.

Template Parameters
ControlledValueThe derived ControlledValueBase class that contains the implementation for setting the controllable value
ValueTypeThe underlying type of the value to be controlled

Definition at line 128 of file WebServerControlTypeRegistry.h.

Constructor & Destructor Documentation

◆ RegisteredType()

template<class ControlledValue , class ValueType >
Moose::WebServerControlTypeRegistry::RegisteredType< ControlledValue, ValueType >::RegisteredType ( const std::string &  type,
std::function< ValueType(const nlohmann::json &)> &&  parse_function 
)
inline

Definition at line 130 of file WebServerControlTypeRegistry.h.

132  : RegisteredTypeBase(type), _parse_function(parse_function)
133  {
134  }
const std::function< ValueType(const nlohmann::json &)> _parse_function
Function that converts from json -> the value for the ValueType.

Member Function Documentation

◆ build() [1/2]

template<class ControlledValue , class ValueType >
virtual std::unique_ptr<ControlledValueBase> Moose::WebServerControlTypeRegistry::RegisteredType< ControlledValue, ValueType >::build ( const std::string &  name) const
inlinefinaloverridevirtual

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

This will be called by the WebServerControl on ranks that are not rank 0. It will be used during the sync step, where the value is broadcasted to the rest of the ranks and then set locally.

Implements Moose::WebServerControlTypeRegistry::RegisteredTypeBase.

Definition at line 137 of file WebServerControlTypeRegistry.h.

138  {
139  return std::make_unique<ControlledValue>(name, type());
140  }
std::string name(const ElemQuality q)

◆ build() [2/2]

template<class ControlledValue , class ValueType >
virtual std::unique_ptr<ControlledValueBase> Moose::WebServerControlTypeRegistry::RegisteredType< ControlledValue, ValueType >::build ( const std::string &  name,
const nlohmann::json &  json_value 
) const
inlinefinaloverridevirtual

Builds a value with the given type, name name, and JSON value json_value.

This will be called on receipt of a controllable value on rank 0 in the WebServerControl. It will at that point parse the value from JSON and store it. Later on during sync, it will be used to broadcast the value and then locally set it.

Implements Moose::WebServerControlTypeRegistry::RegisteredTypeBase.

Definition at line 142 of file WebServerControlTypeRegistry.h.

143  {
144  return std::make_unique<ControlledValue>(name, type(), _parse_function(json_value));
145  }
std::string name(const ElemQuality q)
const std::function< ValueType(const nlohmann::json &)> _parse_function
Function that converts from json -> the value for the ValueType.

◆ type()

const std::string& Moose::WebServerControlTypeRegistry::RegisteredTypeBase::type ( ) const
inlineinherited
Returns
The string representation of the type

Definition at line 93 of file WebServerControlTypeRegistry.h.

Referenced by Moose::WebServerControlTypeRegistry::RegisteredType< ControlledValue, ValueType >::build().

93 { return _type; }
const std::string _type
The string representation of the underlying type.

Member Data Documentation

◆ _parse_function

template<class ControlledValue , class ValueType >
const std::function<ValueType(const nlohmann::json &)> Moose::WebServerControlTypeRegistry::RegisteredType< ControlledValue, ValueType >::_parse_function
private

Function that converts from json -> the value for the ValueType.

Definition at line 149 of file WebServerControlTypeRegistry.h.

Referenced by Moose::WebServerControlTypeRegistry::RegisteredType< ControlledValue, ValueType >::build().


The documentation for this struct was generated from the following file: