4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief Packet inline non-template implementation */
27 #include "../Utils/senfassert.hh"
29 #define prefix_ inline
30 ///////////////////////////////cci.p///////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////////////
37 prefix_ senf::Packet::Packet(PacketInterpreterBase::ptr packet)
41 prefix_ senf::PacketInterpreterBase::ptr senf::Packet::ptr()
50 prefix_ senf::Packet::Packet()
55 prefix_ senf::Packet senf::Packet::clone()
58 return Packet(ptr()->clone());
61 // Interpreter chain access
63 prefix_ senf::Packet senf::Packet::next(NoThrow_t)
66 PacketInterpreterBase::ptr p (ptr()->next());
67 return !p && ptr()->nextPacketRange() ? checkNext() : Packet(p);
70 prefix_ senf::Packet senf::Packet::next()
73 Packet p (next(nothrow));
74 if (!p) throw InvalidPacketChainException();
78 prefix_ senf::Packet senf::Packet::prev(NoThrow_t)
81 return Packet(ptr()->prev());
84 prefix_ senf::Packet senf::Packet::prev()
87 Packet p (prev(nothrow));
88 if (!p) throw InvalidPacketChainException();
92 prefix_ senf::Packet senf::Packet::first()
95 return Packet(ptr()->first());
98 prefix_ senf::Packet senf::Packet::last()
101 Packet p (ptr()->last());
102 return p.next(nothrow) ? checkLast() : p;
105 prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory)
108 return Packet(ptr()->parseNextAs(factory));
111 prefix_ senf::Packet senf::Packet::append(Packet const & packet)
114 return Packet(ptr()->append(packet.ptr()));
119 prefix_ senf::PacketData & senf::Packet::data()
122 return ptr()->data();
125 prefix_ senf::Packet::size_type senf::Packet::size()
128 return data().size();
134 prefix_ bool senf::Packet::operator==(Packet const & other)
137 return ptr() == other.ptr();
140 prefix_ void senf::Packet::finalizeThis()
142 ptr()->finalizeThis();
145 prefix_ void senf::Packet::finalizeTo(Packet const & other)
147 ptr()->finalizeTo(other.ptr());
150 prefix_ void senf::Packet::finalizeAll()
152 ptr()->finalizeTo(last().ptr());
155 prefix_ void senf::Packet::dump(std::ostream & os)
158 last(); // Make sure the packet is complete
162 prefix_ senf::TypeIdValue senf::Packet::typeId()
165 return ptr()->typeId();
168 prefix_ senf::Packet::factory_t senf::Packet::factory()
171 return ptr()->factory();
174 prefix_ bool senf::Packet::boolean_test()
177 return packet_ && packet_->valid();
180 prefix_ bool senf::Packet::valid()
186 template <class PacketType, class Parser>
187 prefix_ Parser senf::operator<<(Parser target, ConcretePacket<PacketType> const & packet)
189 target << packet.parser();
193 ///////////////////////////////cci.e///////////////////////////////////////
200 // c-file-style: "senf"
201 // indent-tabs-mode: nil
202 // ispell-local-dictionary: "american"
203 // compile-command: "scons -u test"
204 // comment-column: 40