X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FAnnotationRouter.hh;h=e438755ba452dd5c0c0e1406ce58ad852282ce7c;hb=164fe477094d42463722584e527a02379ab5d985;hp=19b8332eb27cd1b5612c41d3300c4c139f7ee0b1;hpb=d724177f910255b7e4953b48f29717673e260686;p=senf.git diff --git a/PPI/AnnotationRouter.hh b/PPI/AnnotationRouter.hh index 19b8332..e438755 100644 --- a/PPI/AnnotationRouter.hh +++ b/PPI/AnnotationRouter.hh @@ -28,8 +28,10 @@ // Custom includes #include +#include "../Utils/String.hh" #include "Module.hh" #include "Connectors.hh" +#include "MultiConnectorMixin.hh" //#include "AnnotationRouter.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -38,7 +40,7 @@ namespace senf { namespace ppi { namespace module { - /** \brief Route packets to destination according to some annotation value + /** \brief %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 \ref packet_usage_annotation "packet annotation". Each output connected @@ -48,7 +50,7 @@ namespace module { The \a AnnotationType template parameter defines the routing key. This annotation must support the following operations: - \li Comparison with '<' (\c LessThanCompatable concept) + \li Comparison with '<' (\c LessThanComparable concept) \li Copy construction and copy assignment (\c Copyable und \c Assignable concepts) (e.g. via compiler synthesized copy constructor and assignment operator) \li Output streaming to an ostream via '\c <<' (for error description purposes) (\c @@ -75,7 +77,7 @@ namespace module { mac address and allows to pass a senf::MACAddress value as routing key directly: \code - senf::ppi::module::AnnotationRouter router; + senf::ppi::module::AnnotationRouter router; senf::ppi::connect(router, target1, senf::MACAddress::from_string("00:1a:2b:04:06:08")); \endcode @@ -92,7 +94,11 @@ namespace module { from the container */ template - class AnnotationRouter : public Module + class AnnotationRouter + : public Module, + public MultiConnectorMixin< AnnotationRouter, + connector::ActiveOutput<>, + AnnotationType > { SENF_PPI_MODULE(AnnotationRouter); public: @@ -104,42 +110,23 @@ namespace module { struct DuplicateKeyException : public senf::Exception { DuplicateKeyException(AnnotationType const & key) : senf::Exception("Duplicate senf::ppi::module::AnnotationRouter routing key ") - { append(boost::lexical_cast(key)); } }; - - private: - connector::ActiveOutput<> & newOutput(AnnotationType const & key); - -#ifndef DOXYGEN - // I didn't get template friend functions to work ... - public: -#endif - template - connector::GenericActiveOutput & connect(Target & target, AnnotationType const & key); + { append( senf::str(key)); } }; private: + AnnotationType connectorSetup(connector::ActiveOutput<> & conn, AnnotationType const & key); void request(); - - typedef boost::ptr_map > Outputs; - Outputs outputs_; - }; - -} - -#ifndef DOXYGEN - template - connector::GenericActiveOutput & connect( - module::AnnotationRouter & source, Target & target, - ArgType const & key); - -#endif + friend class MultiConnectorMixin< AnnotationRouter, + connector::ActiveOutput<>, + AnnotationType >; + }; -}} +}}} ///////////////////////////////hh.e//////////////////////////////////////// //#include "AnnotationRouter.cci" #include "AnnotationRouter.ct" -#include "AnnotationRouter.cti" +//#include "AnnotationRouter.cti" #endif