senf::ppi::connector Namespace Reference

Connector classes. More...

Detailed Description

Connector classes.

A connector has three independent properties

  • it may be active or passive
  • it may be an input or an output
  • it has an (optional) packet type
Active connectors are activated from within the module, passive connectors are signaled by the external framework. Input connectors receive packets, output connectors send packets.

All passive connectors call some onRequest callback whenever I/O needs to be performed. All input connectors possess a packet queue.

We therefore have 4 connector types each of which is parameterized by the type of packet traversing the connector:

Connectors are declared as module data members and are then externally connected to other modules.

The connectors each take an optional template argument. If this argument is specified, it must be the type of packet expected or sent on this connector. If it is not specified, packets will be passed using the generic Packet handle.

class IpFilter : public senf::ppi::module::Module
{
    SENF_PPI_MODULE(SomeModule);

public:
    senf::ppi::connector::ActiveInput<senf::EthernetPacket> input;
    senf::ppi::connector::PassiveOutput<senf::IpPacket> output;

    IpFilter() {
        route(input, output);
        input.onRequest(&IpFilter::onRequest);
    }

private:
    void onRequest() {
        // 'input()' will return a senf::EthernetPacket packet handle
        try { output( input().find<senf::IpPacket>() ); }
        catch (senf::InvalidPacketChainException & ex) { ; }
    }
};

Jacks

A Jack is a packet type aware and possibly packet type converting reference to an arbitrary connector of the same type. Jacks are used in groups to indirectly declare the input's and output's
class MyGroup
{
private:
    senf::ppi::module::PassiveQueue queue;
    senf::ppi::module::RateAnalyzer analyzer;

public:
    senf::ppi::connector::ActiveInputJack<senf::EthernetPacket> input;
    senf::ppi::connector::ActiveOutputJack<senf::EthernetPacket> output;

    MyGroup()
        : queue (), analyzer (), input (queue.input), output (analyzer.output)
    {
        senf::ppi::connect(queue, analyzer);
    }
};

The jacks are initialized by passing an arbitrary compatible connector to the jack constructor. A connector is compatible, if

Jacks can be used wherever connectors may be used. Jacks may be defined anywhere, not only in modules. It is however important to ensure that the lifetime of the jack does not exceed the lifetime of the referenced connector.
See also:
senf::ppi::module::Module
senf::ppi::connect()
Connectors

Namespaces

namespace   detail

Classes

struct   IncompatibleConnectorsException
  Incompatible connectors connected. More...
class   Connector
  Connector base-class. More...
class   PassiveConnector
  Passive connector base-class. More...
class   ActiveConnector
  Active connector base-class. More...
class   InputConnector
  Input connector base-class. More...
class   OutputConnector
  Output connector base-class. More...
class   GenericPassiveInput
  Combination of PassiveConnector and InputConnector. More...
class   GenericPassiveOutput
  Combination of PassiveConnector and OutputConnector. More...
class   GenericActiveInput
  Combination of ActiveConnector and InputConnector. More...
class   GenericActiveOutput
  Combination of ActiveConnector and OutputConnector. More...
class   ActiveInput
  Connector actively reading packets. More...
class   PassiveInput
  Connector passively receiving packets. More...
class   ActiveOutput
  Connector actively sending packets. More...
class   PassiveOutput
  Connector passively providing packets. More...
class   Jack
  Connector Jack base class. More...
class   GenericActiveInputJack
  Jack referencing an ActiveInput. More...
class   GenericActiveOutputJack
  Jack referencing an ActiveOutput. More...
class   GenericPassiveInputJack
  Jack referencing a PassiveInput. More...
class   GenericPassiveOutputJack
  Jack referencing a PassiveOutput. More...
class   ActiveInputJack
  Jack with packet type referencing an ActiveInput. More...
class   ActiveOutputJack
  Jack with packet type referencing an ActiveOutput. More...
class   PassiveInputJack
  Jack with packet type referencing a PassiveInput. More...
class   PassiveOutputJack
  Jack with packet type referencing a PassiveOutput. More...

Functions

  SENF_CONSOLE_REGISTER_ENUM_MEMBER (Connector, TraceState,(NO_TRACING)(TRACE_IDS)(TRACE_CONTENTS))

Function Documentation

senf::ppi::connector::
SENF_CONSOLE_REGISTER_ENUM_MEMBER ( Connector  ,
TraceState  ,
(NO_TRACING)(TRACE_IDS)(TRACE_CONTENTS)  )