NEW FILE HEADER / COPYRIGHT FORMAT
[senf.git] / Packets / Packet.cci
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS) 
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY 
6 //     Stefan Bund <g0dil@berlios.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 Packet inline non-template implementation */
25
26 // Custom includes
27
28 #define prefix_ inline
29 ///////////////////////////////cci.p///////////////////////////////////////
30
31 ///////////////////////////////////////////////////////////////////////////
32 // senf::Packet
33
34 // public structors
35
36 prefix_ senf::Packet::Packet()
37 {}
38
39 prefix_ senf::Packet senf::Packet::clone()
40     const
41 {
42     return Packet(ptr()->clone());
43 }
44
45 // Interpreter chain access
46
47 prefix_ senf::Packet senf::Packet::next()
48     const
49 {
50     PacketInterpreterBase::ptr p (ptr()->next());
51     return !p && ptr()->nextPacketRange() ? checkNext() : Packet(p);
52 }
53
54 prefix_ senf::Packet senf::Packet::prev()
55     const
56 {
57     return Packet(ptr()->prev());
58 }
59
60 prefix_ senf::Packet senf::Packet::first()
61     const
62 {
63     return Packet(ptr()->first());
64 }
65
66 prefix_ senf::Packet senf::Packet::last()
67     const
68 {
69     Packet p (ptr()->last());
70     return p.next() ? checkLast() : p;
71 }
72
73 prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory)
74     const
75 {
76     return Packet(ptr()->parseNextAs(factory));
77 }
78
79 prefix_ senf::Packet senf::Packet::append(Packet packet)
80     const
81 {
82     return Packet(ptr()->append(packet.ptr()));
83 }
84
85 // Data access
86
87 prefix_ senf::PacketData & senf::Packet::data()
88     const
89 {
90     return ptr()->data();
91 }
92
93 prefix_ senf::Packet::size_type senf::Packet::size()
94     const
95 {
96     return data().size();
97 }
98
99
100 // Other methods
101
102 prefix_ bool senf::Packet::operator==(Packet other)
103     const
104 {
105     return ptr() == other.ptr();
106 }
107
108 prefix_ void senf::Packet::finalize()
109     const
110 {
111     last(); // Make sure the packet is complete
112     ptr()->finalize();
113 }
114
115 prefix_ void senf::Packet::dump(std::ostream & os)
116     const
117 {
118     last(); // Make sure the packet is complete
119     ptr()->dump(os);
120 }
121
122 prefix_ senf::TypeIdValue senf::Packet::typeId()
123     const
124 {
125     return ptr()->typeId();
126 }
127
128 prefix_ senf::Packet::factory_t senf::Packet::factory()
129     const
130 {
131     return ptr()->factory();
132 }
133
134 prefix_ bool senf::Packet::boolean_test()
135     const
136 {
137     return packet_ && packet_->valid();
138 }
139
140 // protected members
141
142 prefix_  senf::Packet::Packet(PacketInterpreterBase::ptr packet)
143     : packet_(packet)
144 {}
145
146 prefix_ senf::PacketInterpreterBase::ptr senf::Packet::ptr()
147     const
148 {
149     BOOST_ASSERT(packet_);
150     return packet_;
151 }
152
153 ///////////////////////////////cci.e///////////////////////////////////////
154 #undef prefix_
155
156 \f
157 // Local Variables:
158 // mode: c++
159 // fill-column: 100
160 // c-file-style: "senf"
161 // indent-tabs-mode: nil
162 // ispell-local-dictionary: "american"
163 // compile-command: "scons -u test"
164 // comment-column: 40
165 // End: