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 //-/////////////////////////////////////////////////////////////////////////////////////////////////
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 prefix_ void senf::PacketInterpreterBase::clearAnnotations()
103 return impl().clearAnnotations();
106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
109 // protected structors
111 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
112 iterator b, iterator e, Append_t)
113 : PacketData(std::distance(impl->begin(),b),
114 std::distance(impl->begin(),e))
116 impl->appendInterpreter(this);
119 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
120 iterator b, iterator e, Prepend_t)
121 : PacketData(std::distance(impl->begin(),b),
122 std::distance(impl->begin(),e))
124 impl->prependInterpreter(this);
127 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
128 iterator b, iterator e, ptr before)
129 : PacketData(std::distance(impl->begin(),b),
130 std::distance(impl->begin(),e))
132 impl->prependInterpreter(this, before.get());
135 prefix_ senf::PacketInterpreterBase::ptr
136 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, iterator base,
139 return v_appendClone(impl,base,new_base);
142 prefix_ senf::PacketInterpreterBase::ptr
143 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, range r)
145 return v_appendClone(impl,r);
148 //-/////////////////////////////////////////////////////////////////////////////////////////////////
151 // containment management. Only to be called by PacketImpl.
153 prefix_ void senf::PacketInterpreterBase::assignImpl(detail::PacketImpl * impl)
155 SENF_ASSERT(!impl_, "Internal failure: PacketInterpreter added to two Packets");
161 prefix_ void senf::PacketInterpreterBase::releaseImpl()
163 SENF_ASSERT(impl_, "Internal failure: release of lone PacketInterpreter");
165 detail::PacketImpl * i (impl_);
167 // This call might delete this ...
175 prefix_ void senf::intrusive_ptr_add_ref(PacketInterpreterBase const * p)
178 const_cast<PacketInterpreterBase *>(p)->add_ref();
180 const_cast<PacketInterpreterBase *>(p)->intrusive_refcount_base::add_ref();
183 prefix_ void senf::intrusive_ptr_release(PacketInterpreterBase const * p)
185 if (p->refcount() <= 1)
186 const_cast<PacketInterpreterBase *>(p)->release();
188 const_cast<PacketInterpreterBase *>(p)->intrusive_refcount_base::release();
191 //-/////////////////////////////////////////////////////////////////////////////////////////////////
198 // c-file-style: "senf"
199 // indent-tabs-mode: nil
200 // ispell-local-dictionary: "american"
201 // compile-command: "scons -u test"
202 // comment-column: 40