https://mooseframework.inl.gov
Functions
Moose::WebServerControlTypeRegistration Namespace Reference

Defines classes for registering values that can be parsed, communicated, and stored in the WebServerControl. More...

Functions

template<class T >
char registerType (const std::string type_name, std::function< T(const nlohmann::json &)> &&parse_function)
 Register a generic type to be controlled by the WebServerControl. More...
 
template<class T >
char registerScalarType (const std::string &type_name)
 Register a scalar type to be controlled by the WebServerControl. More...
 
template<class T >
char registerVectorType (const std::string &type_name)
 Register a vector type to be controlled by the WebServerControl. More...
 
 registerWebServerControlScalar (bool)
 
 registerWebServerControlScalar (Real)
 
 registerWebServerControlScalar (int)
 
 registerWebServerControlScalar (std::string)
 
 registerWebServerControlVector (Real)
 
 registerWebServerControlVector (int)
 
 registerWebServerControlVector (std::string)
 
 registerWebServerControlType (RealEigenMatrix, [](const nlohmann::json &json_value) -> RealEigenMatrix { const auto vec_of_vec=json_value.get< std::vector< std::vector< double >>>();const auto nrows=vec_of_vec.size();if(nrows==0) return RealEigenMatrix::Zero(0, 0);const auto ncols=vec_of_vec[0].size();RealEigenMatrix matrix;matrix.resize(nrows, ncols);for(const auto i :make_range(nrows)) { const auto &row=vec_of_vec[i];if(row.size() !=ncols) throw std::runtime_error("Matrix is jagged");for(const auto j :index_range(row)) matrix(i, j)=row[j];} return matrix;})
 

Detailed Description

Defines classes for registering values that can be parsed, communicated, and stored in the WebServerControl.

Registers the base parameter types that are controllable in the WebServerControl.

You can use the common macros from the header file to register custom types as controllable in your own application or derived WebServerControl.

Function Documentation

◆ registerScalarType()

template<class T >
char Moose::WebServerControlTypeRegistration::registerScalarType ( const std::string &  type_name)

Register a scalar type to be controlled by the WebServerControl.

This should be used through the registerWebServerControlScalar macro.

Uses nlohmann::json to perform the type conversion.

Parameters
type_nameName of the type; this is the name that the client will associate with the value when it is communicated

Definition at line 72 of file WebServerControlTypeRegistration.h.

73 {
74  const auto parse_function = [](const nlohmann::json & json_value) -> T
75  { return json_value.get<T>(); };
76  return registerType<T>(type_name, std::move(parse_function));
77 }

◆ registerType()

template<class T >
char Moose::WebServerControlTypeRegistration::registerType ( const std::string  type_name,
std::function< T(const nlohmann::json &)> &&  parse_function 
)

Register a generic type to be controlled by the WebServerControl.

This should be used through the registerWebServerControlType macro.

Parameters
type_nameName of the type; this is the name that the client will associate with the value when it is communicated
parse_functionFunction that parses the value from a JSON value

Definition at line 53 of file WebServerControlTypeRegistration.h.

55 {
57  type_name, std::move(parse_function));
58 }
A static registry used to register and build values of different types for the WebServerControl.
static char add(const std::string &type_name, std::function< ValueType(const nlohmann::json &)> &&parse_function)
Register a type in the registry.
Class containing a value to be controlled.

◆ registerVectorType()

template<class T >
char Moose::WebServerControlTypeRegistration::registerVectorType ( const std::string &  type_name)

Register a vector type to be controlled by the WebServerControl.

This should be used through the registerWebServerControlVector macro.

Uses nlohmann::json to perform the type conversion.

Parameters
type_nameName of the type in the vector; this is the name that the client will associate with the value when it is communicated

Definition at line 91 of file WebServerControlTypeRegistration.h.

92 {
93  using vector_T = std::vector<T>;
94  const auto parse_function = [](const nlohmann::json & json_value) -> vector_T
95  { return json_value.get<vector_T>(); };
96  return registerType<vector_T>("std::vector<" + type_name + ">", std::move(parse_function));
97 }

◆ registerWebServerControlScalar() [1/4]

Moose::WebServerControlTypeRegistration::registerWebServerControlScalar ( bool  )

◆ registerWebServerControlScalar() [2/4]

Moose::WebServerControlTypeRegistration::registerWebServerControlScalar ( Real  )

◆ registerWebServerControlScalar() [3/4]

Moose::WebServerControlTypeRegistration::registerWebServerControlScalar ( int  )

◆ registerWebServerControlScalar() [4/4]

Moose::WebServerControlTypeRegistration::registerWebServerControlScalar ( std::string  )

◆ registerWebServerControlType()

Moose::WebServerControlTypeRegistration::registerWebServerControlType ( RealEigenMatrix  ,
[] (const nlohmann::json &json_value) -> RealEigenMatrix { const auto vec_of_vec=json_value.get< std::vector< std::vector< double >>>();const auto nrows=vec_of_vec.size();if(nrows==0) return RealEigenMatrix::Zero(0, 0);const auto ncols=vec_of_vec[0].size();RealEigenMatrix matrix;matrix.resize(nrows, ncols);for(const auto i :make_range(nrows)) { const auto &row=vec_of_vec[i];if(row.size() !=ncols) throw std::runtime_error("Matrix is jagged");for(const auto j :index_range(row)) matrix(i, j)=row[j];} return matrix;}   
)

◆ registerWebServerControlVector() [1/3]

Moose::WebServerControlTypeRegistration::registerWebServerControlVector ( Real  )

◆ registerWebServerControlVector() [2/3]

Moose::WebServerControlTypeRegistration::registerWebServerControlVector ( int  )

◆ registerWebServerControlVector() [3/3]

Moose::WebServerControlTypeRegistration::registerWebServerControlVector ( std::string  )