#include <senf/PPI/AnnotationRouter.hh>
This router takes packet on a single input and directs them to one of it outputs depending on a packet annotation. Each output connected will be associated with a single annotation value. Incoming packets for which no matching output is found are directed to a default output. If this output is left unconnected, those packets will be dropped.
The AnnotationType template parameter defines the routing key. This annotation must support the following operations:
LessThanComparable
concept)Copyable
and Assignable
concepts) (e.g. via compiler synthesized copy constructor and assignment operator)<<'
(for error description purposes) (OutputStreamable
concept)struct TargetInterface { senf::MACAddress mac; bool operator< (TargetInterface const & other) { return mac < other.mac; } TargetInterface(senf::MACAddress const & m) : mac (m) {} }; std::ostream & operator<<(std::ostream & os, TargetInterface const & v) { os << v.mac; return os; }
The additional senf::MACAddress constructor allows to construct an instance directly from a mac address and allows to pass a senf::MACAddress value as routing key directly:
senf::ppi::module::AnnotationRouter<TargetInterface> router; senf::ppi::connect(router, target1, senf::MACAddress::from_string("00:1a:2b:04:06:08"));
The special senf::ppi::connect() overload takes a third argument, the routing key. This must be an AnnotationType value or must be (explicitly) convertible to AnnotationType.
The input will be throttled whenever any of the outputs except defaultOutput are throttled.
Definition at line 97 of file AnnotationRouter.hh.
Classes |
|
struct | DuplicateKeyException |
Public Member Functions |
|
AnnotationRouter () | |
Public Attributes |
|
connector::PassiveInput | input |
connector::ActiveOutput | defaultOutput |
senf::ppi::module::AnnotationRouter< AnnotationType >:: | ||||
AnnotationRouter | () | |||
Definition at line 34 of file AnnotationRouter.ct.
connector::ActiveOutput senf::ppi::module::AnnotationRouter< AnnotationType >:: | ||||
defaultOutput | ||||
Definition at line 106 of file AnnotationRouter.hh.
connector::PassiveInput senf::ppi::module::AnnotationRouter< AnnotationType >:: | ||||
input | ||||
Definition at line 103 of file AnnotationRouter.hh.