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 PacketInterpreter inline non-template implementation */
27 #include <senf/Utils/senfassert.hh>
28 #include <boost/utility.hpp>
30 #define prefix_ inline
31 ///////////////////////////////cci.p///////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////////////
34 // senf::PacketInterpreterBase
36 // Structors and default members
38 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::no_factory()
43 // Interpreter chain access
45 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::next()
47 return ptr(impl().next(this));
50 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::prev()
52 return ptr(impl().prev(this));
55 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::first()
57 return ptr(impl().first());
60 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::last()
62 return ptr(impl().last());
65 prefix_ senf::PacketInterpreterBase::ptr
66 senf::PacketInterpreterBase::parseNextAs(factory_t factory)
68 return factory->parseNext(ptr(this));
73 prefix_ senf::PacketData & senf::PacketInterpreterBase::data()
78 // Access to the abstract interface
80 prefix_ senf::PacketInterpreterBase::optional_range
81 senf::PacketInterpreterBase::nextPacketRange()
83 return v_nextPacketRange();
86 prefix_ senf::TypeIdValue senf::PacketInterpreterBase::typeId()
91 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::factory()
96 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::nextPacketType()
98 return v_nextPacketType();
101 ////////////////////////////////////////
104 // protected structors
106 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
107 iterator b, iterator e, Append_t)
108 : PacketData(std::distance(impl->begin(),b),
109 std::distance(impl->begin(),e))
111 impl->appendInterpreter(this);
114 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
115 iterator b, iterator e, Prepend_t)
116 : PacketData(std::distance(impl->begin(),b),
117 std::distance(impl->begin(),e))
119 impl->prependInterpreter(this);
122 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
123 iterator b, iterator e, ptr before)
124 : PacketData(std::distance(impl->begin(),b),
125 std::distance(impl->begin(),e))
127 impl->prependInterpreter(this, before.get());
130 prefix_ senf::PacketInterpreterBase::ptr
131 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, iterator base,
134 return v_appendClone(impl,base,new_base);
137 prefix_ senf::PacketInterpreterBase::ptr
138 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, range r)
140 return v_appendClone(impl,r);
143 ////////////////////////////////////////
146 // reference/memory management
148 prefix_ void senf::PacketInterpreterBase::add_ref()
150 intrusive_refcount_t<PacketInterpreterBase>::add_ref();
155 prefix_ bool senf::PacketInterpreterBase::release()
158 // This call will set impl_ to 0 if we just removed the last reference ...
160 return intrusive_refcount_t<PacketInterpreterBase>::release() && !impl_;
163 // containment management. Only to be called by PacketImpl.
165 prefix_ void senf::PacketInterpreterBase::assignImpl(detail::PacketImpl * impl)
167 SENF_ASSERT(!impl_, "Internal failure: PacketInterpreter added to two Packets");
169 impl_->add_ref(refcount());
172 prefix_ void senf::PacketInterpreterBase::releaseImpl()
174 SENF_ASSERT(impl_, "Internal failure: release of lone PacketInterpreter");
175 refcount_t refc (refcount());
177 impl_->release(refc);
186 ///////////////////////////////cci.e///////////////////////////////////////
193 // c-file-style: "senf"
194 // indent-tabs-mode: nil
195 // ispell-local-dictionary: "american"
196 // compile-command: "scons -u test"
197 // comment-column: 40