maliput
RuleRegistry Class Reference

Detailed Description

A registry for Rule types.

A Rule type is distinguished by its Rule::TypeId, which must be unique among all Rules (including both RangeValueRules and DiscreteValueRules). This class provides a registry of the various rule types, and enables semantic validation when building rule instances.

#include <include/maliput/api/rules/rule_registry.h>

Classes

struct  QueryResult
 Holds a rule type information for a query. More...
 

Public Member Functions

 MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN (RuleRegistry)
 
 RuleRegistry ()=default
 
virtual ~RuleRegistry ()=default
 
void RegisterRangeValueRule (const Rule::TypeId &type_id, const std::vector< RangeValueRule::Range > &all_possible_ranges)
 Registers a RangeValueRule type. More...
 
void RegisterDiscreteValueRule (const Rule::TypeId &type_id, const std::vector< DiscreteValueRule::DiscreteValue > &all_possible_values)
 Registers a DiscreteValueRule type. More...
 
const std::map< Rule::TypeId, std::vector< RangeValueRule::Range > > & RangeValueRuleTypes () const
 
const std::map< Rule::TypeId, std::vector< DiscreteValueRule::DiscreteValue > > & DiscreteValueRuleTypes () const
 
std::optional< QueryResultGetPossibleStatesOfRuleType (const Rule::TypeId &type_id) const
 Finds the possible states of a rule type by type_id. More...
 
RangeValueRule BuildRangeValueRule (const Rule::Id &id, const Rule::TypeId &type_id, const LaneSRoute &zone, const std::vector< RangeValueRule::Range > &ranges) const
 Builds a RangeValueRule. More...
 
DiscreteValueRule BuildDiscreteValueRule (const Rule::Id &id, const Rule::TypeId &type_id, const LaneSRoute &zone, const std::vector< DiscreteValueRule::DiscreteValue > &values) const
 Builds a DiscreteValueRule. More...
 

Constructor & Destructor Documentation

◆ RuleRegistry()

RuleRegistry ( )
default

◆ ~RuleRegistry()

virtual ~RuleRegistry ( )
virtualdefault

Member Function Documentation

◆ BuildDiscreteValueRule()

DiscreteValueRule BuildDiscreteValueRule ( const Rule::Id id,
const Rule::TypeId type_id,
const LaneSRoute zone,
const std::vector< DiscreteValueRule::DiscreteValue > &  values 
) const

Builds a DiscreteValueRule.

See also
DiscreteValueRule constructor for parameter documentation.
Exceptions
maliput::common::assertion_errorWhen type_id is not a registered DiscreteValueRule type.
maliput::common::assertion_errorWhen an element in values is not a possible value of a DiscreteValueRule of type type_id.

◆ BuildRangeValueRule()

RangeValueRule BuildRangeValueRule ( const Rule::Id id,
const Rule::TypeId type_id,
const LaneSRoute zone,
const std::vector< RangeValueRule::Range > &  ranges 
) const

Builds a RangeValueRule.

See also
RangeValueRule constructor for parameter documentation.
Exceptions
maliput::common::assertion_errorWhen type_id is not a registered RangeValueRule type.
maliput::common::assertion_errorWhen an element in ranges is not a possible range of a RangeValueRule of type type_id.

◆ DiscreteValueRuleTypes()

const std::map< Rule::TypeId, RuleRegistry::QueryResult::DiscreteValues > & DiscreteValueRuleTypes ( ) const
Returns
All of the registered DiscreteValueRule types and their possible values.

◆ GetPossibleStatesOfRuleType()

std::optional< RuleRegistry::QueryResult > GetPossibleStatesOfRuleType ( const Rule::TypeId type_id) const

Finds the possible states of a rule type by type_id.

Parameters
type_idRule type ID.
Returns
The possible states of a specified rule type, or nullopt if no such rule type exists.

◆ MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN()

MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN ( RuleRegistry  )

◆ RangeValueRuleTypes()

const std::map< Rule::TypeId, RuleRegistry::QueryResult::Ranges > & RangeValueRuleTypes ( ) const
Returns
All of the registered RangeValueRule types and their possible ranges.

◆ RegisterDiscreteValueRule()

void RegisterDiscreteValueRule ( const Rule::TypeId type_id,
const std::vector< DiscreteValueRule::DiscreteValue > &  all_possible_values 
)

Registers a DiscreteValueRule type.

Parameters
type_idThe Rule type.
all_possible_valuesAll possible discrete values that a rule of this type could be in. It must have at least one value; each value must be unique.
See also
DiscreteValueRule.
Exceptions
maliput::common::assertion_errorWhen type_id is already registered.
maliput::common::assertion_errorWhen all_possible_values is empty.
maliput::common::assertion_errorWhen there are duplicated items in all_possible_values.

◆ RegisterRangeValueRule()

void RegisterRangeValueRule ( const Rule::TypeId type_id,
const std::vector< RangeValueRule::Range > &  all_possible_ranges 
)

Registers a RangeValueRule type.

Parameters
type_idThe Rule type.
all_possible_rangesAll possible ranges that a rule of this type could be in. It must have at least one value; each value must be unique.
See also
RangeValueRule
Exceptions
maliput::common::assertion_errorWhen type_id is already registered.
maliput::common::assertion_errorWhen all_possible_ranges is empty.
maliput::common::assertion_errorWhen there are duplicated items in all_possible_ranges.

The documentation for this class was generated from the following files: