From: g0dil Date: Fri, 8 Feb 2008 09:38:57 +0000 (+0000) Subject: Howtos/NewPacket: Small fixes X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=6d612eda73e43f9304bd178aff02020a6e7be3fe Howtos/NewPacket: Small fixes PPI: Add missing unit-test for typed connectors and fix typed connectors implementation Socket: Remove left-over log message git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@672 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/HowTos/NewPacket/Mainpage.dox b/HowTos/NewPacket/Mainpage.dox index c6f5cce..8769831 100644 --- a/HowTos/NewPacket/Mainpage.dox +++ b/HowTos/NewPacket/Mainpage.dox @@ -76,7 +76,7 @@ \code #include - struct GREPacketParser : public senf::PacketParser + struct GREPacketParser : public senf::PacketParserBase { # include SENF_PARSER() @@ -86,10 +86,10 @@ }; \endcode - This is the standard skeleton of any parser class: We need to inherit senf::PacketParser and + This is the standard skeleton of any parser class: We need to inherit senf::PacketParserBase and start out by including either \ref SENF_PARSER() or \ref SENF_FIXED_PARSER(). Which, depends on - whether we define a fixed size or a dynamically sized parser. As \c GREPacketParser is dynamically - sized, we include \ref SENF_PARSER(). + whether we define a fixed size or a dynamically sized parser. As \c GREPacketParser is + dynamically sized, we include \ref SENF_PARSER(). After the fields are defined, we need to call the \ref SENF_PARSER_FINALIZE() macro to close of the parser definition. This call takes the name of the parser being defined as it's sole @@ -152,7 +152,7 @@ as an optional parser to the GRE header. \code - struct GREPacketParser_OptFields : public senf::PacketParser + struct GREPacketParser_OptFields : public senf::PacketParserBase { # include SENF_FIXED_PARSER() @@ -313,7 +313,7 @@ \code #include - struct GREPacketParser_OptFields : public senf::PacketParser + struct GREPacketParser_OptFields : public senf::PacketParserBase { # include SENF_FIXED_PARSER() @@ -323,7 +323,7 @@ SENF_PARSER_FINALIZE(GREPacketParser_OptFields); }; - struct GREPacketParser : public senf::PacketParser + struct GREPacketParser : public senf::PacketParserBase { # include SENF_PARSER() @@ -720,7 +720,7 @@ #include - struct GREPacketParser_OptFields : public senf::PacketParser + struct GREPacketParser_OptFields : public senf::PacketParserBase { # include SENF_FIXED_PARSER() @@ -730,7 +730,7 @@ SENF_PARSER_FINALIZE(GREPacketParser_OptFields); }; - struct GREPacketParser : public senf::PacketParser + struct GREPacketParser : public senf::PacketParserBase { # include SENF_PARSER() diff --git a/PPI/Connectors.cti b/PPI/Connectors.cti index c00d0c7..b8f5bf3 100644 --- a/PPI/Connectors.cti +++ b/PPI/Connectors.cti @@ -37,14 +37,15 @@ template prefix_ typename senf::ppi::connector::detail::TypedInputMixin::Type senf::ppi::connector::detail::TypedInputMixin::operator()() { - return static_cast(this)->InputConnector::operator()().template as(); + return read(); } template prefix_ typename senf::ppi::connector::detail::TypedInputMixin::Type senf::ppi::connector::detail::TypedInputMixin::read() { - return static_cast(this)->InputConnector::read().template as(); + Packet p (static_cast(this)->InputConnector::read()); + return p ? p.as() : Type(); } /////////////////////////////////////////////////////////////////////////// diff --git a/PPI/Connectors.hh b/PPI/Connectors.hh index d96a0d7..68a0ea4 100644 --- a/PPI/Connectors.hh +++ b/PPI/Connectors.hh @@ -460,6 +460,8 @@ namespace connector { public: \ using mixin::operator(); \ using mixin::TypedConnector_ ## dir ; \ + private: \ + friend class detail::Typed ## dir ## Mixin, PacketType>; \ }; \ template <> \ class type ## dir : public Generic ## type ## dir \ @@ -485,7 +487,7 @@ namespace connector { \see GenericActiveInput \n senf::ppi::connector */ - template + template class ActiveInput : public GenericActiveInput { public: @@ -526,12 +528,12 @@ namespace connector { \see GenericActiveOutput \n senf::ppi::connector */ - template + template class ActiveOutput : public GenericActiveOutput { public: - PacketType operator()(); - PacketType write(); + operator()(PacketType packet); ///< Send out a packet + write(PacketType packet); ///< Alias for operator() }; /** \brief Connector passively providing packets @@ -543,12 +545,12 @@ namespace connector { \see GenericPassiveOutput \n senf::ppi::connector */ - template + template class PassiveOutput : public GenericPassiveOutput { public: - PacketType operator()(); - PacketType write(); + operator()(PacketType packet); ///< Send out a packet + write(PacketType packet); ///< Alias for operator() }; #endif diff --git a/PPI/Connectors.test.cc b/PPI/Connectors.test.cc index 8202b3b..639f58b 100644 --- a/PPI/Connectors.test.cc +++ b/PPI/Connectors.test.cc @@ -284,6 +284,71 @@ BOOST_AUTO_UNIT_TEST(activeOutput) // connect() is tested indirectly via ppi::connect } +namespace { + + class TypedInputTest + : public ppi::module::Module + { + SENF_PPI_MODULE(TypedInputTest); + + public: + ppi::connector::PassiveInput input; + + TypedInputTest() { + noroute(input); + input.onRequest(&TypedInputTest::request); + } + + void request() { + (void) input(); + (void) input.read(); + } + }; + + class TypedOutputTest + : public ppi::module::Module + { + SENF_PPI_MODULE(TypedOutputTest); + + public: + ppi::connector::PassiveOutput output; + + TypedOutputTest() { + noroute(output); + output.onRequest(&TypedOutputTest::request); + } + + void request() { + senf::DataPacket pkg (senf::DataPacket::create()); + output(pkg); + output.write(pkg); + } + }; + +} + +BOOST_AUTO_UNIT_TEST(typedInput) +{ + debug::ActiveSource source; + TypedInputTest target; + + ppi::connect(source,target); + ppi::init(); + + senf::Packet p (senf::DataPacket::create()); + source.submit(p); +} + +BOOST_AUTO_UNIT_TEST(tyepdOutput) +{ + TypedOutputTest source; + debug::ActiveSink target; + + ppi::connect(source,target); + ppi::init(); + + (void) target.request(); +} ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ diff --git a/Socket/SocketProtocol.test.hh b/Socket/SocketProtocol.test.hh index c5073f3..68a6466 100644 --- a/Socket/SocketProtocol.test.hh +++ b/Socket/SocketProtocol.test.hh @@ -27,7 +27,6 @@ #include "SocketProtocol.hh" #include "SocketPolicy.test.hh" #include "ProtocolClientSocketHandle.hh" -#include "../Utils/Logger/SenfLog.hh" //#include "SocketProtocol.test.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -50,7 +49,6 @@ namespace test { { return false; } virtual void close() const { - SENF_LOG(( "Closing socket ..." )); closeCount(1); }