senf::ppi::module::AnnotationRouter< AnnotationType > Class Template Reference

Route packets to destination according to some annotation value More...

#include <senf/PPI/AnnotationRouter.hh>

Inheritance diagram for senf::ppi::module::AnnotationRouter< AnnotationType >:

Classes

struct  DuplicateKeyException
 

Public Member Functions

 AnnotationRouter ()
 
- Public Member Functions inherited from senf::ppi::module::Module
virtual ~Module ()
 

Public Attributes

connector::PassiveInput input
 
connector::ActiveOutput defaultOutput
 

Additional Inherited Members

- Public Types inherited from senf::ppi::module::MultiConnectorMixin< Self_, ConnectorType_, KeyType_, ContainerType_ >
typedef ConnectorType_ ConnectorType
 Type of MultiConnector connector. More...
 
- Protected Types inherited from senf::ppi::module::MultiConnectorMixin< Self_, ConnectorType_, KeyType_, ContainerType_ >
typedef ContainerType_ ContainerType
 Type of connector container. More...
 
- Protected Member Functions inherited from senf::ppi::module::Module
 Module ()
 
Route< connector::InputConnector, connector::OutputConnector > & route (connector::InputConnector &input, connector::OutputConnector &output)
 Define flow information. More...
 
Route< connector::InputConnector, EventDescriptor > & route (connector::InputConnector &input, EventDescriptor &output)
 Define flow information. More...
 
Route< EventDescriptor, connector::OutputConnector > & route (EventDescriptor &input, connector::OutputConnector &output)
 Define flow information. More...
 
void noroute (connector::Connector &connector)
 Define terminal connectors. More...
 
template<class Target >
void registerEvent (EventDescriptor &descriptor, Target target)
 Register an external event. More...
 
ClockService::clock_type const & time () const
 Time-stamp of the currently processing event. More...
 
ClockService::clock_type const & now () const
 Current time of the currently processing event. More...
 
virtual void v_init ()
 Called after module setup. More...
 
console::DirectoryNodesysConsoleDir () const
 
void destroy ()
 
- Protected Member Functions inherited from senf::ppi::module::MultiConnectorMixin< Self_, ConnectorType_, KeyType_, ContainerType_ >
ContainerType_ & connectors ()
 Get connector container. More...
 
ContainerType_ const & connectors () const
 Get connectors container (const) More...
 
void connectorDestroy (ConnectorType const &)
 

Detailed Description

template<class AnnotationType>
class senf::ppi::module::AnnotationRouter< AnnotationType >

Route packets to destination according to some annotation value

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:

  • Comparison with '<' (LessThanComparable concept)
  • Copy construction and copy assignment (Copyable and Assignable concepts) (e.g. via compiler synthesized copy constructor and assignment operator)
  • Output streaming to an ostream via '<<' (for error description purposes) (OutputStreamable concept)

The following annotation can be used to route the packets according to a mac address.

struct TargetInterface
{
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:
    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 \a defaultOutput are
    throttled.
Todo:
Call Module::v_init() on every connection change and remove disconnected connections from the container

Definition at line 88 of file AnnotationRouter.hh.

Constructor & Destructor Documentation

◆ AnnotationRouter()

template<class AnnotationType>
senf::ppi::module::AnnotationRouter< AnnotationType >::AnnotationRouter ( )

Member Data Documentation

◆ defaultOutput

template<class AnnotationType>
connector::ActiveOutput senf::ppi::module::AnnotationRouter< AnnotationType >::defaultOutput

Definition at line 97 of file AnnotationRouter.hh.

◆ input

template<class AnnotationType>
connector::PassiveInput senf::ppi::module::AnnotationRouter< AnnotationType >::input

Definition at line 94 of file AnnotationRouter.hh.


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