4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief PacketInterpreter inline non-template implementation */
32 #include <senf/Utils/senfassert.hh>
33 #include <boost/utility.hpp>
35 #define prefix_ inline
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // senf::PacketInterpreterBase
41 // Structors and default members
43 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::no_factory()
48 // Interpreter chain access
50 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::next()
52 return ptr(impl().next(this));
55 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::prev()
57 return ptr(impl().prev(this));
60 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::first()
62 return ptr(impl().first());
65 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::last()
67 return ptr(impl().last());
70 prefix_ senf::PacketInterpreterBase::ptr
71 senf::PacketInterpreterBase::parseNextAs(factory_t factory)
73 return factory->parseNext(ptr(this));
78 prefix_ senf::PacketData & senf::PacketInterpreterBase::data()
83 // Access to the abstract interface
85 prefix_ senf::PacketInterpreterBase::optional_range
86 senf::PacketInterpreterBase::nextPacketRange()
88 return v_nextPacketRange();
91 prefix_ senf::TypeIdValue senf::PacketInterpreterBase::typeId()
96 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::factory()
101 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::nextPacketType()
103 return v_nextPacketType();
106 prefix_ void senf::PacketInterpreterBase::clearAnnotations()
108 return impl().clearAnnotations();
111 //-/////////////////////////////////////////////////////////////////////////////////////////////////
114 // protected structors
116 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
117 iterator b, iterator e, Append_t)
118 : PacketData(std::distance(impl->begin(),b),
119 std::distance(impl->begin(),e))
121 impl->appendInterpreter(this);
124 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
125 iterator b, iterator e, Prepend_t)
126 : PacketData(std::distance(impl->begin(),b),
127 std::distance(impl->begin(),e))
129 impl->prependInterpreter(this);
132 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
133 iterator b, iterator e, ptr before)
134 : PacketData(std::distance(impl->begin(),b),
135 std::distance(impl->begin(),e))
137 impl->prependInterpreter(this, before.get());
140 prefix_ senf::PacketInterpreterBase::ptr
141 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, iterator base,
144 return v_appendClone(impl,base,new_base);
147 prefix_ senf::PacketInterpreterBase::ptr
148 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, range r)
150 return v_appendClone(impl,r);
153 //-/////////////////////////////////////////////////////////////////////////////////////////////////
156 // containment management. Only to be called by PacketImpl.
158 prefix_ void senf::PacketInterpreterBase::assignImpl(detail::PacketImpl * impl)
160 SENF_ASSERT(!impl_, "Internal failure: PacketInterpreter added to two Packets");
166 prefix_ void senf::PacketInterpreterBase::releaseImpl()
168 SENF_ASSERT(impl_, "Internal failure: release of lone PacketInterpreter");
170 detail::PacketImpl * i (impl_);
172 // This call might delete this ...
180 prefix_ void senf::intrusive_ptr_add_ref(PacketInterpreterBase const * p)
183 const_cast<PacketInterpreterBase *>(p)->add_ref();
185 const_cast<PacketInterpreterBase *>(p)->intrusive_refcount_base::add_ref();
188 prefix_ void senf::intrusive_ptr_release(PacketInterpreterBase const * p)
190 if (p->refcount() <= 1)
191 const_cast<PacketInterpreterBase *>(p)->release();
193 const_cast<PacketInterpreterBase *>(p)->intrusive_refcount_base::release();
196 //-/////////////////////////////////////////////////////////////////////////////////////////////////
203 // c-file-style: "senf"
204 // indent-tabs-mode: nil
205 // ispell-local-dictionary: "american"
206 // compile-command: "scons -u test"
207 // comment-column: 40