16 #ifndef _SCC_CCI_PARAM_RESTRICTED_H_
17 #define _SCC_CCI_PARAM_RESTRICTED_H_
19 #include <cci_cfg/cci_param_typed.h>
20 #include <unordered_set>
28 bool operator()(cci::cci_param_write_event<T>
const& ev)
const {
return ev.new_value >= min && ev.new_value <= max; }
38 bool operator()(cci::cci_param_write_event<T>
const& ev)
const {
return ev.new_value > min && ev.new_value < max; }
47 bool operator()(cci::cci_param_write_event<T>
const& ev)
const {
return ev.new_value >= min; }
55 bool operator()(cci::cci_param_write_event<T>
const& ev)
const {
return ev.new_value > min; }
63 bool operator()(cci::cci_param_write_event<T>
const& ev)
const {
return ev.new_value <= max; }
71 bool operator()(cci::cci_param_write_event<T>
const& ev)
const {
return ev.new_value < max; }
76 template <
typename COLLECTION_TYPE>
78 : values(std::begin(values), std::end(values)) {}
80 bool operator()(cci::cci_param_write_event<T>
const& ev)
const {
return values.count(ev.new_value) > 0; }
81 std::unordered_set<T>
const values;
180 template <
typename T, cci::cci_param_mutable_type TM = cci::CCI_MUTABLE_PARAM>
struct cci_param_restricted :
public cci::cci_param<T, TM> {
195 template <
typename RESTR>
196 cci_param_restricted(
const std::string& name,
const T& default_value, RESTR
const& restr,
const std::string& desc =
"",
197 cci::cci_name_type name_type = cci::CCI_RELATIVE_NAME,
198 const cci::cci_originator& originator = cci::cci_originator())
199 : cci::cci_param<T, TM>(name, default_value, desc, name_type, originator) {
200 this->
template register_pre_write_callback(restr);
201 this->
template reset();
216 template <
typename RESTR>
217 cci_param_restricted(
const std::string& name,
const T& default_value, RESTR
const& restr, cci::cci_broker_handle private_broker,
218 const std::string& desc =
"", cci::cci_name_type name_type = cci::CCI_RELATIVE_NAME,
219 const cci::cci_originator& originator = cci::cci_originator())
220 : cci::cci_param<T, TM>(name, default_value, desc, name_type, originator) {
221 this->
template register_pre_write_callback(restr);
222 this->
template reset();
_max_excl_restriction< T > max_excl_restriction(T max)
creates a maximum restriction excluding the maximum value
_max_restriction< T > max_restriction(T max)
creates a maximum restriction including the maximum value
_min_restriction< T > gte_restriction(T min)
alias for min_restriction(T min)
_min_max_restriction< T > min_max_restriction(T min, T max)
creates a min/max restriction with including the limits
_min_excl_restriction< T > gt_excl_restriction(T min)
alias for min_excl_restriction(T min)
_discrete_restriction< T > discrete_restriction(std::initializer_list< T > values)
creates a restriction for a discrete values set
_min_restriction< T > min_restriction(T min)
creates a minimum restriction including the minimum value
_min_excl_restriction< T > min_excl_restriction(T min)
creates a minimum restriction excluding the minimum value
_max_excl_restriction< T > lt_excl_restriction(T max)
alias for max_excl_restriction(T max)
_max_restriction< T > lte_restriction(T max)
alias for max_restriction(T max)
_min_max_excl_restriction< T > min_max_excl_restriction(T min, T max)
creates a min/max restriction with excluding the limits
extension of cci_param<T, TM> which automatically registeres a callback to restrict the valid values ...
cci_param_restricted(const std::string &name, const T &default_value, RESTR const &restr, const std::string &desc="", cci::cci_name_type name_type=cci::CCI_RELATIVE_NAME, const cci::cci_originator &originator=cci::cci_originator())
cci_param_restricted(const std::string &name, const T &default_value, RESTR const &restr, cci::cci_broker_handle private_broker, const std::string &desc="", cci::cci_name_type name_type=cci::CCI_RELATIVE_NAME, const cci::cci_originator &originator=cci::cci_originator())