X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FPacketType.hh;h=2c6fd01b9524d468d2f5b9bb25c939fb3d70b5df;hb=a0b6f53e5c464c6b84fed30a67fcce32da81012d;hp=931ef4bf1452f0ff5824780a0524951acb765361;hpb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;p=senf.git diff --git a/senf/Packets/PacketType.hh b/senf/Packets/PacketType.hh index 931ef4b..2c6fd01 100644 --- a/senf/Packets/PacketType.hh +++ b/senf/Packets/PacketType.hh @@ -49,7 +49,7 @@ namespace senf { { typedef senf::ConcretePacket packet; typedef SomePacketParser parser; - + static size_type initSize() { // This value can in most cases be taken from the parser @@ -109,7 +109,7 @@ namespace senf { struct PacketTypeBase { typedef Packet packet; - + typedef senf::detail::packet::iterator iterator; typedef senf::detail::packet::const_iterator const_iterator; typedef senf::detail::packet::size_type size_type; @@ -127,7 +127,7 @@ namespace senf { typedef VoidPacketParser parser; ///< Parser to parser packet fields /**< This typedef has to be set to the parser of the packet - + The default is a VoidPacketParser which does not parse any field. */ @@ -142,8 +142,8 @@ namespace senf { /**< This function gives the index within a newly created, empty packet where a sub-packet is to be placed. - The default implementation returns initSize(). - + The default implementation returns initSize(). + \implementation Ok, it does not really return initSize(), it returns size_type(-1) which is interpreted to mean initSize(). It can't return @@ -160,14 +160,14 @@ namespace senf { The default implementation does nothing. */ - + static optional_range nextPacketRange(packet p); ///< Get next packet placement /**< nextPacketRange returns the iterator range where the next packet (header) is placed within the current packet. - + The default implementation always returns no_range(). @@ -184,7 +184,7 @@ namespace senf { ///< Get type of next packet /**< nextPacketType retrieves the type of the next packet returning a factory to create that packet. - + The default implementation always returns no_factory(). @@ -200,8 +200,8 @@ namespace senf { /**< finalize() will be called to complete a packet after it has been modified. This function must calculate any checksums, set size fields from the interpreter chain - etc. - + etc. + The default implementation does nothing. */ static void dump(packet p, std::ostream & os); @@ -217,25 +217,25 @@ namespace senf { /** \brief Mixin to provide standard implementations for nextPacketRange and nextPacketType This mixin class simplifies the definition of simple packets: - + \li The packets consist of three sections: The header, the payload and an optional trailer. \li If the packet has a trailer, both the header and the trailer must have a fixed size. This mixin provides the nextPacketRange() member as well as initSize() and init(). If you additionally provide the optional \a Registry argument, PacketTypeMixin provides a simple - implementation of nextPacketType(). + implementation of nextPacketType(). When using the PacketTypeMixin, the implementation of a packet is simplified to: \code // Here 'SomeRegistryTag' is optional - struct SimplePacketType + struct SimplePacketType : public senf::PacketTypeBase, public senf::PacketTypeMixin { typedef senf::PacketTypeMixin mixin; typedef senf::ConcretePacket packet; typedef SomePacketParser parser; - + using mixin::nextPacketRange; using mixin::nextPacketType; // Only if the optional 'Registry' argument is provided using mixin::initSize; @@ -251,7 +251,7 @@ namespace senf { static void finalize(packet p) { - // Set the type field by querying the type of the next packet. This is an + // Set the type field by querying the type of the next packet. This is an // optional assignment: If the key is not found, the value returned by 'key' // is an empty optional and the assignment will be skipped. p->typeField << key(p.next(senf::nothrow)); @@ -278,16 +278,16 @@ namespace senf { Most of the members are optional, which reduces the minimal implementation of a packet to: \code - struct SimplePacketType + struct SimplePacketType : public senf::PacketTypeBase, public senf::PacketTypeMixin { typedef senf::PacketTypeMixin mixin; typedef senf::ConcretePacket packet; typedef SomePacketParser parser; - + using mixin::nextPacketRange; - using mixin::nextPacketType; + using mixin::nextPacketType; using mixin::initSize; using mixin::init; @@ -319,8 +319,8 @@ namespace senf { next packet from information stored in the current packets header, the key() member will look up the type of packet \a p in the registry and return it's - key. - + key. + If either \a p is an in - valid() packet or the packet type is not found in the registry, the returned optional value will be empty. */ @@ -333,11 +333,11 @@ namespace senf { ///\name PacketType interface implementation ///@{ - static PacketInterpreterBase::optional_range nextPacketRange (Packet const & p); - static PacketInterpreterBase::factory_t nextPacketType (Packet const & p); + static PacketInterpreterBase::optional_range nextPacketRange (ConcretePacket const & p); + static PacketInterpreterBase::factory_t nextPacketType (ConcretePacket const & p); static PacketInterpreterBase::size_type initSize (); - static void init (Packet const & p); - + static void init (ConcretePacket const & p); + ///@} }; @@ -347,9 +347,9 @@ namespace senf { class PacketTypeMixin { public: - static PacketInterpreterBase::optional_range nextPacketRange (Packet const & p); + static PacketInterpreterBase::optional_range nextPacketRange (ConcretePacket const & p); static PacketInterpreterBase::size_type initSize (); - static void init (Packet const & p); + static void init (ConcretePacket const & p); }; # endif