Merged revisions 262,264-265,267-282,284-298,300-311 via svnmerge from
[senf.git] / Packets / Packet.cci
1 // Copyright (C) 2007 
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 //     Stefan Bund <g0dil@berlios.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
21 /** \file
22     \brief Packet inline non-template implementation */
23
24 // Custom includes
25
26 #define prefix_ inline
27 ///////////////////////////////cci.p///////////////////////////////////////
28
29 ///////////////////////////////////////////////////////////////////////////
30 // senf::Packet
31
32 // public structors
33
34 prefix_ senf::Packet::Packet()
35 {}
36
37 prefix_ senf::Packet senf::Packet::clone()
38     const
39 {
40     return Packet(ptr()->clone());
41 }
42
43 // Interpreter chain access
44
45 prefix_ senf::Packet senf::Packet::next()
46     const
47 {
48     PacketInterpreterBase::ptr p (ptr()->next());
49     return !p && ptr()->nextPacketRange() ? checkNext() : Packet(p);
50 }
51
52 prefix_ senf::Packet senf::Packet::prev()
53     const
54 {
55     return Packet(ptr()->prev());
56 }
57
58 prefix_ senf::Packet senf::Packet::first()
59     const
60 {
61     return Packet(ptr()->first());
62 }
63
64 prefix_ senf::Packet senf::Packet::last()
65     const
66 {
67     Packet p (ptr()->last());
68     return p.next() ? checkLast() : p;
69 }
70
71 prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory)
72     const
73 {
74     return Packet(ptr()->parseNextAs(factory));
75 }
76
77 prefix_ senf::Packet senf::Packet::append(Packet packet)
78     const
79 {
80     return Packet(ptr()->append(packet.ptr()));
81 }
82
83 // Data access
84
85 prefix_ senf::PacketData & senf::Packet::data()
86     const
87 {
88     return ptr()->data();
89 }
90
91 prefix_ senf::Packet::size_type senf::Packet::size()
92     const
93 {
94     return data().size();
95 }
96
97
98 // Other methods
99
100 prefix_ bool senf::Packet::operator==(Packet other)
101     const
102 {
103     return ptr() == other.ptr();
104 }
105
106 prefix_ void senf::Packet::finalize()
107     const
108 {
109     ptr()->finalize();
110 }
111
112 prefix_ void senf::Packet::dump(std::ostream & os)
113     const
114 {
115     last(); // Make sure the packet is complete
116     ptr()->dump(os);
117 }
118
119 prefix_ senf::TypeIdValue senf::Packet::typeId()
120     const
121 {
122     return ptr()->typeId();
123 }
124
125 prefix_ senf::Packet::factory_t senf::Packet::factory()
126     const
127 {
128     return ptr()->factory();
129 }
130
131 prefix_ bool senf::Packet::boolean_test()
132     const
133 {
134     return packet_ && packet_->valid();
135 }
136
137 // protected members
138
139 prefix_  senf::Packet::Packet(PacketInterpreterBase::ptr packet)
140     : packet_(packet)
141 {}
142
143 prefix_ senf::PacketInterpreterBase::ptr senf::Packet::ptr()
144     const
145 {
146     BOOST_ASSERT(packet_);
147     return packet_;
148 }
149
150 ///////////////////////////////cci.e///////////////////////////////////////
151 #undef prefix_
152
153 \f
154 // Local Variables:
155 // mode: c++
156 // fill-column: 100
157 // c-file-style: "senf"
158 // indent-tabs-mode: nil
159 // ispell-local-dictionary: "american"
160 // compile-command: "scons -u test"
161 // End: