4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
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 PacketInterpreter inline non-template implementation */
27 #include <boost/utility.hpp>
29 #define prefix_ inline
30 ///////////////////////////////cci.p///////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////////////
33 // senf::PacketInterpreterBase
35 // Structors and default members
37 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::no_factory()
42 // Interpreter chain access
44 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::next()
46 return ptr(impl().next(this));
49 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::prev()
51 return ptr(impl().prev(this));
54 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::first()
56 return ptr(impl().first());
59 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::last()
61 return ptr(impl().last());
64 prefix_ senf::PacketInterpreterBase::ptr
65 senf::PacketInterpreterBase::parseNextAs(factory_t factory)
67 return factory->parseNext(ptr(this));
72 prefix_ senf::PacketData & senf::PacketInterpreterBase::data()
77 // Access to the abstract interface
79 prefix_ senf::PacketInterpreterBase::optional_range
80 senf::PacketInterpreterBase::nextPacketRange()
82 return v_nextPacketRange();
85 prefix_ senf::TypeIdValue senf::PacketInterpreterBase::typeId()
90 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::factory()
95 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::nextPacketType()
97 return v_nextPacketType();
100 ////////////////////////////////////////
103 // protected structors
105 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
106 iterator b, iterator e, Append_t)
107 : PacketData(std::distance(impl->begin(),b),
108 std::distance(impl->begin(),e))
110 impl->appendInterpreter(this);
113 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
114 iterator b, iterator e, Prepend_t)
115 : PacketData(std::distance(impl->begin(),b),
116 std::distance(impl->begin(),e))
118 impl->prependInterpreter(this);
121 prefix_ senf::PacketInterpreterBase::ptr
122 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, iterator base,
125 return v_appendClone(impl,base,new_base);
128 prefix_ senf::PacketInterpreterBase::ptr
129 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, range r)
131 return v_appendClone(impl,r);
134 ////////////////////////////////////////
137 // reference/memory management
139 prefix_ void senf::PacketInterpreterBase::add_ref()
141 intrusive_refcount_t<PacketInterpreterBase>::add_ref();
146 prefix_ bool senf::PacketInterpreterBase::release()
149 // This call will set impl_ to 0 if we just removed the last reference ...
151 return intrusive_refcount_t<PacketInterpreterBase>::release() && !impl_;
154 // containment management. Only to be called by PacketImpl.
156 prefix_ void senf::PacketInterpreterBase::assignImpl(detail::PacketImpl * impl)
158 BOOST_ASSERT(!impl_);
160 impl_->add_ref(refcount());
163 prefix_ void senf::PacketInterpreterBase::releaseImpl()
166 refcount_t refc (refcount());
168 impl_->release(refc);
177 ///////////////////////////////cci.e///////////////////////////////////////
184 // c-file-style: "senf"
185 // indent-tabs-mode: nil
186 // ispell-local-dictionary: "american"
187 // compile-command: "scons -u test"
188 // comment-column: 40