X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FMPEGDVBBundle%2FTLVPacket.hh;h=e0ff4e059956f574e7576ac62eca0fc30eddaf56;hb=759f89cf0952cbc42207e5c4cf059d3906a37e59;hp=449f148867b11eec55580542eb60938fc2367cd6;hpb=a1de53d00eb1cbe7a1dbb8918192773bc0db46a0;p=senf.git diff --git a/Packets/MPEGDVBBundle/TLVPacket.hh b/Packets/MPEGDVBBundle/TLVPacket.hh index 449f148..e0ff4e0 100644 --- a/Packets/MPEGDVBBundle/TLVPacket.hh +++ b/Packets/MPEGDVBBundle/TLVPacket.hh @@ -1,4 +1,4 @@ -// $Id: SNDUPacket.hh 423 2007-08-31 22:05:37Z g0dil $ +// $Id$ // // Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) @@ -21,7 +21,7 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief SNDUPacket public header */ + \brief TLVPacket public header */ #ifndef HH_TLVPacket_ #define HH_TLVPacket_ 1 @@ -37,7 +37,6 @@ namespace senf { - struct UnsuportedTLVPacketException : public std::exception { virtual char const * what() const throw() { @@ -45,55 +44,44 @@ namespace senf { } }; - struct Parse_TLVPacketLength + class Parse_TLVPacketLength : public detail::packet::ParseIntOps, public PacketParserBase { + public: # ifndef DOXYGEN SENF_PACKET_PARSER_NO_INIT(Parse_TLVPacketLength); - typedef Parse_Flag < 0 > Parse_extended_length_flag; - typedef Parse_UIntField < 1, 8 > Parse_fixed_length; - - SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS( - ((OverlayField)( extended_length_flag, Parse_extended_length_flag )) - ((Field )( fixed_length_field, Parse_fixed_length )) - ); - # endif - + typedef boost::uint32_t value_type; + + value_type value() const; + + void value(value_type const & v); - value_type value() const { - switch( bytes() ) { - case 1: - return fixed_length_field().value(); - case 2: - return parse( 1 ).value(); - case 3: - return parse( 1 ).value(); - case 4: - return parse( 1 ).value(); - case 5: - return parse( 1 ).value(); - default: - throw(UnsuportedTLVPacketException()); - }; - } - - size_type bytes() const { - if ( extended_length_flag() ) - return 1 + fixed_length_field(); - else - return 1; + Parse_TLVPacketLength const & operator= (value_type other); + + static const size_type init_bytes = 1; + + size_type bytes() const; + + void init() const; + + private: + typedef Parse_Flag < 0 > Parse_extended_length_flag; + typedef Parse_UIntField < 1, 8 > Parse_fixed_length; + + Parse_extended_length_flag extended_length_flag() const { + return parse( 0 ); } - - void init() const { - defaultInit(); - extended_length_flag() = 0; + + Parse_fixed_length fixed_length_field() const { + return parse( 0 ); } + void resize(size_type size); }; /** \brief parse TLVPacket Packet @@ -108,25 +96,12 @@ namespace senf { SENF_PACKET_PARSER_INIT(Parse_TLVPacket); - SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS( + SENF_PACKET_PARSER_DEFINE_FIELDS( ((Field)( type, Parse_UInt32 )) ((Field)( length, Parse_TLVPacketLength )) ); # endif - -// Parse_UInt32 type() const { -// return parse( 0 ); -// } - -// Parse_TLVPacketLength length() const { -// return parse( 4 ); -// } - - PacketParserBase::size_type bytes() const; - - static const size_type init_bytes = 4+1; // 4 bytes type + 1 byte length - }; /** \brief TLV Packet @@ -140,21 +115,16 @@ namespace senf { \ingroup protocolbundle_mpegdvb */ struct TLVPacketType - : public PacketTypeBase, - public PacketTypeMixin + : public PacketTypeBase { - typedef PacketTypeMixin mixin; typedef ConcretePacket packet; typedef Parse_TLVPacket parser; - using mixin::nextPacketRange; - using mixin::init; - using mixin::initSize; - + static optional_range nextPacketRange(packet p); + static void init(packet p); + static size_type initSize(); + static void finalize(packet p); static void dump(packet p, std::ostream & os); - -// static PacketParserBase::size_type initSize(); -// static PacketParserBase::size_type initHeadSize(); }; typedef TLVPacketType::packet TLVPacket;