Packets: Complete reimplementation of parse helper macros
[senf.git] / Packets / MPEGDVBBundle / DSMCCSection.hh
1 // $Id:DSMCCSection.hh 327 2007-07-20 10:03:44Z tho $
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Thorsten Horstmann <thorsten.horstmann@fokus.fraunhofer.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief DSMCCSection public header */
25
26 #ifndef HH_DSMCCSection_
27 #define HH_DSMCCSection_ 1
28
29 // Custom includes
30 #include <algorithm>
31 #include "../../Packets/Packets.hh"
32
33 //#include "DSMCCSection.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
35
36 namespace senf {
37
38     /** \brief Parse a DSMCC Section
39     
40         Parser implementing the header of a DSMCC Section
41         
42         \see DSMCCSectionType
43      */
44     struct Parse_DSMCCSection : public PacketParserBase
45     {
46 #       include SENF_FIXED_PARSER()
47
48         SENF_PARSE_FIELD( table_id, Parse_UInt8 );
49         
50         SENF_PARSE_BITFIELD( ssi,                  1, bool     );
51         SENF_PARSE_BITFIELD( private_indicator,    1, bool     );
52         SENF_PARSE_BITFIELD( reserved_1,           2, unsigned );
53         SENF_PARSE_BITFIELD( sec_length,          12, unsigned );
54
55         SENF_PARSE_FIELD( table_id_extension, Parse_UInt16 );
56
57         SENF_PARSE_BITFIELD( reserved_2,           2, unsigned );
58         SENF_PARSE_BITFIELD( version_num,          5, unsigned );
59         SENF_PARSE_BITFIELD( curr_next_indicator,  1, bool     );
60
61         SENF_PARSE_FIELD( sec_num,            Parse_UInt8  );
62         SENF_PARSE_FIELD( last_sec_num,       Parse_UInt8  );
63         
64         SENF_PARSER_FINALIZE(Parse_DSMCCSection);
65
66         Parse_UInt32 crc() const { return parse<Parse_UInt32>( data().size()-4 ); }
67     };
68     
69     /** \brief DSMCC Section
70         
71         \par Packet type (typedef):
72             \ref DSMCCSection
73
74         \par Fields:
75             \ref Parse_DSMCCSection
76
77         \ingroup protocolbundle_mpegdvb
78      */
79     struct DSMCCSectionType
80         : public PacketTypeBase,
81           public PacketTypeMixin<DSMCCSectionType>
82     {
83         typedef PacketTypeMixin<DSMCCSectionType> mixin;
84         typedef ConcretePacket<DSMCCSectionType> packet;
85         typedef Parse_DSMCCSection parser;
86
87         using mixin::nextPacketRange;
88 //          using mixin::nextPacketType;
89         using mixin::init;
90         
91         static void dump(packet p, std::ostream & os);
92         
93         static PacketParserBase::size_type initSize();
94         static PacketParserBase::size_type initHeadSize();
95     };
96         
97     typedef DSMCCSectionType::packet DSMCCSection;
98 }
99
100
101 ///////////////////////////////hh.e////////////////////////////////////////
102 //#include "DSMCCSection.cci"
103 //#include "DSMCCSection.ct"
104 //#include "DSMCCSection.cti"
105 #endif
106
107 \f
108 // Local Variables:
109 // mode: c++
110 // fill-column: 100
111 // c-file-style: "senf"
112 // indent-tabs-mode: nil
113 // ispell-local-dictionary: "american"
114 // compile-command: "scons -u test"
115 // comment-column: 40
116 // End: