2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
22 \brief PacketInterpreter inline non-template implementation */
25 #include <boost/utility.hpp>
27 #define prefix_ inline
28 ///////////////////////////////cci.p///////////////////////////////////////
30 ///////////////////////////////////////////////////////////////////////////
31 // senf::PacketInterpreterBase
33 // Structors and default members
35 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::no_factory()
40 // Interpreter chain access
42 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::next()
44 return ptr(impl().next(this));
47 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::prev()
49 return ptr(impl().prev(this));
52 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::first()
54 return ptr(impl().first());
57 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::last()
59 return ptr(impl().last());
62 prefix_ senf::PacketInterpreterBase::ptr
63 senf::PacketInterpreterBase::parseNextAs(factory_t factory)
65 return factory->parseNext(ptr(this));
70 prefix_ senf::PacketData & senf::PacketInterpreterBase::data()
75 // Access to the abstract interface
77 prefix_ senf::PacketInterpreterBase::optional_range
78 senf::PacketInterpreterBase::nextPacketRange()
80 return v_nextPacketRange();
83 prefix_ senf::TypeIdValue senf::PacketInterpreterBase::typeId()
88 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::factory()
93 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::nextPacketType()
95 return v_nextPacketType();
98 ////////////////////////////////////////
101 // protected structors
103 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
104 iterator b, iterator e, Append_t)
105 : PacketData(std::distance(impl->begin(),b),
106 std::distance(impl->begin(),e))
108 impl->appendInterpreter(this);
111 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
112 iterator b, iterator e, Prepend_t)
113 : PacketData(std::distance(impl->begin(),b),
114 std::distance(impl->begin(),e))
116 impl->prependInterpreter(this);
119 prefix_ senf::PacketInterpreterBase::ptr
120 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, iterator base,
123 return v_appendClone(impl,base,new_base);
126 prefix_ senf::PacketInterpreterBase::ptr
127 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, range r)
129 return v_appendClone(impl,r);
132 ////////////////////////////////////////
135 // reference/memory management
137 prefix_ void senf::PacketInterpreterBase::add_ref()
139 intrusive_refcount_t<PacketInterpreterBase>::add_ref();
144 prefix_ bool senf::PacketInterpreterBase::release()
147 // This call will set impl_ to 0 if we just removed the last reference ...
149 return intrusive_refcount_t<PacketInterpreterBase>::release() && !impl_;
152 // containment management. Only to be called by PacketImpl.
154 prefix_ void senf::PacketInterpreterBase::assignImpl(detail::PacketImpl * impl)
156 BOOST_ASSERT(!impl_);
158 impl_->add_ref(refcount());
161 prefix_ void senf::PacketInterpreterBase::releaseImpl()
164 refcount_t refc (refcount());
166 impl_->release(refc);
175 ///////////////////////////////cci.e///////////////////////////////////////
182 // c-file-style: "senf"
183 // indent-tabs-mode: nil
184 // ispell-local-dictionary: "american"
185 // compile-command: "scons -u test"
186 // comment-column: 40