PPI: Checkin of first compiling (yet not working) version
[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     last(); // Make sure the packet is complete
110     ptr()->finalize();
111 }
112
113 prefix_ void senf::Packet::dump(std::ostream & os)
114     const
115 {
116     last(); // Make sure the packet is complete
117     ptr()->dump(os);
118 }
119
120 prefix_ senf::TypeIdValue senf::Packet::typeId()
121     const
122 {
123     return ptr()->typeId();
124 }
125
126 prefix_ senf::Packet::factory_t senf::Packet::factory()
127     const
128 {
129     return ptr()->factory();
130 }
131
132 prefix_ bool senf::Packet::boolean_test()
133     const
134 {
135     return packet_ && packet_->valid();
136 }
137
138 // protected members
139
140 prefix_  senf::Packet::Packet(PacketInterpreterBase::ptr packet)
141     : packet_(packet)
142 {}
143
144 prefix_ senf::PacketInterpreterBase::ptr senf::Packet::ptr()
145     const
146 {
147     BOOST_ASSERT(packet_);
148     return packet_;
149 }
150
151 ///////////////////////////////cci.e///////////////////////////////////////
152 #undef prefix_
153
154 \f
155 // Local Variables:
156 // mode: c++
157 // fill-column: 100
158 // c-file-style: "senf"
159 // indent-tabs-mode: nil
160 // ispell-local-dictionary: "american"
161 // compile-command: "scons -u test"
162 // comment-column: 40
163 // End: