rsl  1.1.0
ROS Support Library
parameter_validators.hpp File Reference
#include <rsl/algorithm.hpp>
#include <rsl/export.hpp>
#include <rsl/static_string.hpp>
#include <rsl/static_vector.hpp>
#include <rcl_interfaces/msg/set_parameters_result.hpp>
#include <rclcpp/parameter.hpp>
#include <tl_expected/expected.hpp>
#include <fmt/ranges.h>

Go to the source code of this file.

Functions

template<typename T >
auto rsl::unique (rclcpp::Parameter const &parameter) -> tl::expected< void, std::string >
 Is every element of rclcpp::Parameter unique? More...
 
template<typename T >
auto rsl::subset_of (rclcpp::Parameter const &parameter, std::vector< T > const &valid_values) -> tl::expected< void, std::string >
 Are the values in parameter a subset of the valid values? More...
 
template<typename T >
auto rsl::fixed_size (rclcpp::Parameter const &parameter, size_t const size)
 Is the array size of parameter equal to passed in size? More...
 
template<typename T >
auto rsl::size_gt (rclcpp::Parameter const &parameter, size_t const size)
 Is the array size of parameter greater than passed in size? More...
 
template<typename T >
auto rsl::size_lt (rclcpp::Parameter const &parameter, size_t const size)
 Is the array size of parameter less than passed in size? More...
 
template<typename T >
auto rsl::not_empty (rclcpp::Parameter const &parameter) -> tl::expected< void, std::string >
 Is the size of the value passed in not zero? More...
 
template<typename T >
auto rsl::element_bounds (rclcpp::Parameter const &parameter, T const &lower, T const &upper) -> tl::expected< void, std::string >
 Are all elements of parameter within the bounds (inclusive)? More...
 
template<typename T >
auto rsl::lower_element_bounds (rclcpp::Parameter const &parameter, T const &lower) -> tl::expected< void, std::string >
 Are all elements of parameter greater than lower bound? More...
 
template<typename T >
auto rsl::upper_element_bounds (rclcpp::Parameter const &parameter, T const &upper) -> tl::expected< void, std::string >
 Are all elements of parameter less than some upper bound? More...
 
template<typename T >
auto rsl::bounds (rclcpp::Parameter const &parameter, T const &lower, T const &upper) -> tl::expected< void, std::string >
 Is parameter within bounds (inclusive)? More...
 
template<typename T >
auto rsl::lower_bounds (rclcpp::Parameter const &parameter, T const &value)
 Is parameter within some lower bound (same as gt_eq)? More...
 
template<typename T >
auto rsl::upper_bounds (rclcpp::Parameter const &parameter, T const &value)
 Is parameter within some upper bound (same as lt_eq)? More...
 
template<typename T >
auto rsl::lt (rclcpp::Parameter const &parameter, T const &value)
 Is parameter less than some value? More...
 
template<typename T >
auto rsl::gt (rclcpp::Parameter const &parameter, T const &value)
 Is parameter greater than some value? More...
 
template<typename T >
auto rsl::lt_eq (rclcpp::Parameter const &parameter, T const &value)
 Is parameter less than or equal to some value? More...
 
template<typename T >
auto rsl::gt_eq (rclcpp::Parameter const &parameter, T const &value)
 Is parameter greater than or equal to some value? More...
 
template<typename T >
auto rsl::one_of (rclcpp::Parameter const &parameter, std::vector< T > const &collection) -> tl::expected< void, std::string >
 Is the parameter value one of a set of values? More...
 
RSL_EXPORT auto rsl::to_parameter_result_msg (tl::expected< void, std::string > const &result) -> rcl_interfaces::msg::SetParametersResult
 Convert the result of a validator function into a SetParametersResult msg.
 

Function Documentation

◆ bounds()

template<typename T >
auto rsl::bounds ( rclcpp::Parameter const &  parameter,
T const &  lower,
T const &  upper 
) -> tl::expected<void, std::string>

Is parameter within bounds (inclusive)?

Precondition
rclcpp::Parameter must be a non-array type
Template Parameters
TInterior type of parameter; e.g. for parameter type int, T = int64_t
Returns
Help string if the parameter is invalid, otherwise void

◆ element_bounds()

template<typename T >
auto rsl::element_bounds ( rclcpp::Parameter const &  parameter,
T const &  lower,
T const &  upper 
) -> tl::expected<void, std::string>

Are all elements of parameter within the bounds (inclusive)?

Precondition
rclcpp::Parameter must be an array type
Template Parameters
TInterior type of array; e.g. for parameter type double_array, T = double
Returns
Help string if the parameter is invalid, otherwise void

◆ fixed_size()

template<typename T >
auto rsl::fixed_size ( rclcpp::Parameter const &  parameter,
size_t const  size 
)

Is the array size of parameter equal to passed in size?

Precondition
rclcpp::Parameter must be an array type
Template Parameters
TInterior type of array; e.g. for parameter type double_array, T = double
Returns
Help string if the parameter is invalid, otherwise void

◆ gt()

template<typename T >
auto rsl::gt ( rclcpp::Parameter const &  parameter,
T const &  value 
)

Is parameter greater than some value?

Precondition
rclcpp::Parameter must be a non-array type
Template Parameters
TInterior type of parameter; e.g. for parameter type int, T = int64_t
Returns
Help string if the parameter is invalid, otherwise void

◆ gt_eq()

template<typename T >
auto rsl::gt_eq ( rclcpp::Parameter const &  parameter,
T const &  value 
)

Is parameter greater than or equal to some value?

Precondition
rclcpp::Parameter must be a non-array type
Template Parameters
TInterior type of parameter; e.g. for parameter type int, T = int64_t
Returns
Help string if the parameter is invalid, otherwise void

◆ lower_bounds()

template<typename T >
auto rsl::lower_bounds ( rclcpp::Parameter const &  parameter,
T const &  value 
)

Is parameter within some lower bound (same as gt_eq)?

Precondition
rclcpp::Parameter must be a non-array type
Template Parameters
TInterior type of parameter; e.g. for parameter type int, T = int64_t
Returns
Help string if the parameter is invalid, otherwise void

◆ lower_element_bounds()

template<typename T >
auto rsl::lower_element_bounds ( rclcpp::Parameter const &  parameter,
T const &  lower 
) -> tl::expected<void, std::string>

Are all elements of parameter greater than lower bound?

Precondition
rclcpp::Parameter must be an array type
Template Parameters
TInterior type of array; e.g. for parameter type double_array, T = double
Returns
Help string if the parameter is invalid, otherwise void

◆ lt()

template<typename T >
auto rsl::lt ( rclcpp::Parameter const &  parameter,
T const &  value 
)

Is parameter less than some value?

Precondition
rclcpp::Parameter must be a non-array type
Template Parameters
TInterior type of parameter; e.g. for parameter type int, T = int64_t
Returns
Help string if the parameter is invalid, otherwise void

◆ lt_eq()

template<typename T >
auto rsl::lt_eq ( rclcpp::Parameter const &  parameter,
T const &  value 
)

Is parameter less than or equal to some value?

Precondition
rclcpp::Parameter must be a non-array type
Template Parameters
TInterior type of parameter; e.g. for parameter type int, T = int64_t
Returns
Help string if the parameter is invalid, otherwise void

◆ not_empty()

template<typename T >
auto rsl::not_empty ( rclcpp::Parameter const &  parameter) -> tl::expected<void, std::string>

Is the size of the value passed in not zero?

Precondition
rclcpp::Parameter must be an array type or a string
Template Parameters
TInterior type of array or std::string; e.g. for parameter type double_array, T = double
Returns
Help string if the parameter is invalid, otherwise void

◆ one_of()

template<typename T >
auto rsl::one_of ( rclcpp::Parameter const &  parameter,
std::vector< T > const &  collection 
) -> tl::expected<void, std::string>

Is the parameter value one of a set of values?

Precondition
rclcpp::Parameter must be a non-array type
Template Parameters
TInterior type of parameter; e.g. for parameter type int, T = int64_t
Returns
Help string if the parameter is invalid, otherwise void

◆ size_gt()

template<typename T >
auto rsl::size_gt ( rclcpp::Parameter const &  parameter,
size_t const  size 
)

Is the array size of parameter greater than passed in size?

Precondition
rclcpp::Parameter must be an array type
Template Parameters
TInterior type of array; e.g. for parameter type double_array, T = double
Returns
Help string if the parameter is invalid, otherwise void

◆ size_lt()

template<typename T >
auto rsl::size_lt ( rclcpp::Parameter const &  parameter,
size_t const  size 
)

Is the array size of parameter less than passed in size?

Precondition
rclcpp::Parameter must be an array type
Template Parameters
TInterior type of array; e.g. for parameter type double_array, T = double
Returns
Help string if the parameter is invalid, otherwise void

◆ subset_of()

template<typename T >
auto rsl::subset_of ( rclcpp::Parameter const &  parameter,
std::vector< T > const &  valid_values 
) -> tl::expected<void, std::string>

Are the values in parameter a subset of the valid values?

Precondition
rclcpp::Parameter must be an array type
Template Parameters
TInterior type of array; e.g. for parameter type double_array, T = double
Returns
Help string if the parameter is invalid, otherwise void

◆ unique()

template<typename T >
auto rsl::unique ( rclcpp::Parameter const &  parameter) -> tl::expected<void, std::string>

Is every element of rclcpp::Parameter unique?

Precondition
rclcpp::Parameter must be an array type
Template Parameters
TInterior type of array; e.g. for parameter type double_array, T = double
Returns
Help string if the parameter is invalid, otherwise void

◆ upper_bounds()

template<typename T >
auto rsl::upper_bounds ( rclcpp::Parameter const &  parameter,
T const &  value 
)

Is parameter within some upper bound (same as lt_eq)?

Precondition
rclcpp::Parameter must be a non-array type
Template Parameters
TInterior type of parameter; e.g. for parameter type int, T = int64_t
Returns
Help string if the parameter is invalid, otherwise void

◆ upper_element_bounds()

template<typename T >
auto rsl::upper_element_bounds ( rclcpp::Parameter const &  parameter,
T const &  upper 
) -> tl::expected<void, std::string>

Are all elements of parameter less than some upper bound?

Precondition
rclcpp::Parameter must be an array type
Template Parameters
TInterior type of array; e.g. for parameter type double_array, T = double
Returns
Help string if the parameter is invalid, otherwise void