A connector has three independent properties
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:
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) { ; } } };
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
senf::ppi::connector:: | ||||
SENF_CONSOLE_REGISTER_ENUM_MEMBER | ( | Connector | , | |
TraceState | , | |||
(NO_TRACING)(TRACE_IDS)(TRACE_CONTENTS) | ) | |||