Parameter
-
template<typename T>
class Parameter : public vslib::IParameter Public Functions
-
inline Parameter(Component &parent, std::string_view name) noexcept
requires fgc4 Constructor for parameters of non-numeric types and thus with no limits.
-
inline Parameter(Component &parent, std::string_view name, LimitType<T> limit_min = std::numeric_limits<LimitType<T>>::lowest(), LimitType<T> limit_max = std::numeric_limits<LimitType<T>>::max())
requires fgc4 Constructor for parameters with optional numeric-type limits.
-
inline operator T() const
Provides the access to the value and performs an implicit conversion to the desired type
- Returns:
Read-buffer value.
-
inline std::optional<fgc4::utils::Warning> checkLimits(T value) const noexcept
requires fgc4 Checks whether the provided array values fall within the numerical limits specified for this Parameter.
- Parameters:
value – New parameter values to be checked
- Returns:
Warning with relevant information if check not successful, nothing otherwise Checks limits of all arithmetic types, if they are defined.
Fallback of checking limits for cases not comparable directly with double type: strings, enumerations, non-numerical arrays, etc.@param value New parameter value to be checked @return Warning with relevant information if check not successful, nothing otherwise
- Returns:
Empty optional return (success) Validates the provided JSON value against the scalar Parameter type.
@param json_value JSON object containing command value to be validated @return If validation not successful returns Warning with relevant information, nothing otherwise
-
inline std::optional<fgc4::utils::Warning> setJsonValueImpl(const StaticJson &json_value)
Sets the provided JSON value to the write buffer. Handles boolean, std::string, numerical types, and arrays.
- Parameters:
json_value – JSON object containing new parameter value to be set
- Returns:
If not successful returns Warning with relevant information, nothing otherwise
Public Members
- const auto &operator[](uint64_t index) const requires fgc4 Component & m_parent
< Name of this Parameter
Provides element-access to the values stored in the value, provided the type stored is a std::array.
- Param index:
Index of the array to be accessed. If invalid, an out_of_range exception will be thrown
- Param other:
- Return:
Value stored at the requested index Provides ordering for the Parameters, allowing to compare them to allow interactions as if they were of the stored type.
- Return:
Ordering between the current Parameter and the one we compared the object to Explicit conversion value getter function. It removes issues with implicit conversion of a complex type, e.g. arrays, enums, etc.
- Return:
Value held in the read buffer cast explictly to the Parameter type Returns the write buffer value to be validated.
Getter for the initialization flag of the Parameter.@return Write buffer value with explict cast to the underlying type
Getter for the validate flag of the Parameter.@return True if the Parameter has been initialized, false otherwise
Getter for the Parameter name.@return True if the Parameter has been validated, false otherwise
Getter for whether the lower numerical limit is defined.@return Parameter name
Getter for whether the upper numerical limit is defined.@return True if the lower limit is defined, false otherwise
Getter for the lower limit of the held value.@return True if the upper limit is defined, false otherwise
Getter for the upper limit of the held value.@return Lower limit of allowed stored value
Provides connection to begin() method of underlying container, if the Parameter type is an array.@return Upper limit of allowed stored value
Provides connection to cbegin() method of underlying container, if the Parameter type is an array.@return Mutable access to the beginning of the stored std::array
Provides connection to end() method of underlying container, if the Parameter type is an array.@return Non-mutable access to the beginning of the stored std::array
Provides connection to cend() method of underlying container, if the Parameter type is an array.@return Mutable access to the end of the stored std::array
Serializes this Parameter using JSON serialization class.@return Non-mutable access to the end of the stored std::array
Sets the provided JSON-serialized value to the parameter-held value.@param serializer Reference to ParameterSerializer visitor @return JSON-serialized Parameter
Sets the initialization flag to the chosen value.@param json_value JSON-serialized value to be set @return Returns a Warning with relevant information if setting not successful, nothing otherwise
Sets the validation flag to the provided value by the owning Component.@param initialized New value of the initialized flag of this Parameter.
Component owning this Parameter@param value New value for the validated flag.
-
bool m_limit_min_defined = {false}
Flag whether the minimum limit has been set, used in serialization.
-
bool m_limit_max_defined = {false}
Flag whether the maximum limit has been set, used in serialization.
-
inline Parameter(Component &parent, std::string_view name) noexcept