X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FConnectors.hh;h=e6b8c07af00c67d44e45ce232f4841876907d891;hb=d5a72d0b3f6fee56dba6de1c54cafb448ebe3457;hp=0874551b5f12566712eb363d5d524fa5680fd169;hpb=28e21cc5680c097e7daed8c412ee32cf26a75a60;p=senf.git diff --git a/PPI/Connectors.hh b/PPI/Connectors.hh index 0874551..e6b8c07 100644 --- a/PPI/Connectors.hh +++ b/PPI/Connectors.hh @@ -23,8 +23,8 @@ /** \file \brief Connectors public header */ -#ifndef HH_Connectors_ -#define HH_Connectors_ 1 +#ifndef HH_SENF_PPI_Connectors_ +#define HH_SENF_PPI_Connectors_ 1 // Custom includes #include @@ -36,6 +36,7 @@ #include "predecl.hh" #include "detail/Callback.hh" #include "Queueing.hh" +#include "ModuleManager.hh" //#include "Connectors.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -96,6 +97,42 @@ namespace connector { }; \endcode + + \section ppi_jacks 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 + + \code + class MyGroup + { + private: + senf::ppi::module::PassiveQueue queue; + senf::ppi::module::RateAnalyzer analyzer; + + public: + senf::ppi::connector::ActiveInputJack input; + senf::ppi::connector::ActiveOutputJack output; + + MyGroup() + : queue (), analyzer (), input (queue.input), output (analyzer.output) + { + senf::ppi::connect(queue, analyzer); + } + }; + \endcode + + The jacks are initialized by passing an arbitrary compatible connector to the jack + constructor. A connector is compatible, if + \li It has the same input/output active/passive specification + \li Either the Jack or the Connector are generic (senf::Packet) or Jack and Connector have + the same packet type + + 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 senf::ppi::module::Module \n senf::ppi::connect() \n @@ -122,30 +159,42 @@ namespace connector { to the containing module) */ class Connector - : boost::noncopyable + : ModuleManager::Initializable, boost::noncopyable { + SENF_LOG_CLASS_AREA(); + SENF_LOG_DEFAULT_LEVEL(senf::log::NOTICE); public: Connector & peer() const; ///< Get peer connected to this connector module::Module & module() const; ///< Get this connectors containing module bool connected() const; ///< \c true, if connector connected, \c false otherwise + void disconnect(); ///< Disconnect connector from peer + + enum TraceState { NO_TRACING, TRACE_IDS, TRACE_CONTENTS }; + + static void tracing(TraceState state); + static TraceState tracing(); + protected: Connector(); virtual ~Connector(); void connect(Connector & target); + + void trace(Packet const & p, char const * label); + void throttleTrace(char const * label, char const * type); private: virtual std::type_info const & packetTypeID(); void setModule(module::Module & module); - void init(); - virtual void v_init() = 0; Connector * peer_; module::Module * module_; + static TraceState traceState_; + friend class module::Module; }; @@ -199,11 +248,11 @@ namespace connector { private: virtual void v_init(); - // Called by the routing to change the remote throttling state + // Called by the routing to change the throttling state from forwarding routes void notifyThrottle(); ///< Forward a throttle notification to this connector void notifyUnthrottle(); ///< Forward an unthrottle notification to this connector - // Internal members to emit throttling notifications + // Internal members to emit throttling notifications to the connected peer void emitThrottle(); void emitUnthrottle(); @@ -349,7 +398,7 @@ namespace connector { InputConnector(); private: - void enqueue(Packet p); + void enqueue(Packet const & p); virtual void v_requestEvent(); virtual void v_enqueueEvent(); @@ -370,9 +419,9 @@ namespace connector { : public virtual Connector { public: - void operator()(Packet p); ///< Send out a packet + void operator()(Packet const & p); ///< Send out a packet - void write(Packet p); ///< Alias for operator()(Packet p) + void write(Packet const & p); ///< Alias for operator()(Packet p) InputConnector & peer() const; @@ -525,7 +574,7 @@ namespace connector { { public: PacketType operator()(); ///< Read packet - /**< \throws std::bad_cast, if the %connector receives a + /**< \throws std::bad_cast if the %connector receives a Packet which is not of type \a PacketType. \returns newly read packet reference. */ PacketType read(); ///< Alias for operator() @@ -548,7 +597,7 @@ namespace connector { { public: PacketType operator()(); ///< Read packet - /**< \throws std::bad_cast, if the %connector receives a + /**< \throws std::bad_cast if the %connector receives a Packet which is not of type \a PacketType. \returns newly read packet reference. */ PacketType read(); ///< Alias for operator()