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>
34 #define prefix_ inline
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38 // senf::PacketInterpreterBase
40 // Structors and default members
42 prefix_ senf::PacketInterpreterBase::~PacketInterpreterBase()
45 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::no_factory()
50 // Interpreter chain access
52 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::next()
54 return ptr(impl().next(this));
57 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::prev()
59 return ptr(impl().prev(this));
62 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::first()
64 return ptr(impl().first());
67 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::last()
69 return ptr(impl().last());
72 prefix_ senf::PacketInterpreterBase::ptr
73 senf::PacketInterpreterBase::parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range)
75 return factory->parseNext(ptr(this), range);
80 prefix_ senf::PacketData & senf::PacketInterpreterBase::data()
85 // Access to the abstract interface
87 prefix_ senf::PacketInterpreterBase::optional_range
88 senf::PacketInterpreterBase::nextPacketRange()
90 return v_nextPacketRange();
93 prefix_ senf::TypeIdValue senf::PacketInterpreterBase::typeId()
98 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::factory()
103 prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::nextPacketType()
105 return v_nextPacketType();
108 prefix_ void senf::PacketInterpreterBase::clearAnnotations()
110 return impl().clearAnnotations();
113 //-/////////////////////////////////////////////////////////////////////////////////////////////////
116 // protected structors
118 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
119 iterator b, iterator e, Append_t)
120 : PacketData(std::distance(impl->begin(),b),
121 std::distance(impl->begin(),e))
123 impl->appendInterpreter(this);
126 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
127 iterator b, iterator e, Prepend_t)
128 : PacketData(std::distance(impl->begin(),b),
129 std::distance(impl->begin(),e))
131 impl->prependInterpreter(this);
134 prefix_ senf::PacketInterpreterBase::PacketInterpreterBase(detail::PacketImpl * impl,
135 iterator b, iterator e, ptr before)
136 : PacketData(std::distance(impl->begin(),b),
137 std::distance(impl->begin(),e))
139 impl->prependInterpreter(this, before.get());
142 prefix_ senf::PacketInterpreterBase::ptr
143 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, iterator base,
146 return v_appendClone(impl,base,new_base);
149 prefix_ senf::PacketInterpreterBase::ptr
150 senf::PacketInterpreterBase::appendClone(detail::PacketImpl * impl, range r)
152 return v_appendClone(impl,r);
155 //-/////////////////////////////////////////////////////////////////////////////////////////////////
158 // containment management. Only to be called by PacketImpl.
160 prefix_ void senf::PacketInterpreterBase::assignImpl(detail::PacketImpl * impl)
162 SENF_ASSERT(!impl_, "Internal failure: PacketInterpreter added to two Packets");
168 prefix_ void senf::PacketInterpreterBase::releaseImpl()
170 SENF_ASSERT(impl_, "Internal failure: release of lone PacketInterpreter");
172 detail::PacketImpl * i (impl_);
174 // This call might delete this ...
182 prefix_ void senf::intrusive_ptr_add_ref(PacketInterpreterBase const * p)
185 const_cast<PacketInterpreterBase *>(p)->add_ref();
187 const_cast<PacketInterpreterBase *>(p)->intrusive_refcount_base::add_ref();
190 prefix_ void senf::intrusive_ptr_release(PacketInterpreterBase const * p)
192 if (p->refcount() <= 1)
193 const_cast<PacketInterpreterBase *>(p)->release();
195 const_cast<PacketInterpreterBase *>(p)->intrusive_refcount_base::release();
198 //-/////////////////////////////////////////////////////////////////////////////////////////////////
205 // c-file-style: "senf"
206 // indent-tabs-mode: nil
207 // ispell-local-dictionary: "american"
208 // compile-command: "scons -u test"
209 // comment-column: 40