2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 \brief PacketImpl non-inline non-template implementation */
24 //#include "PacketImpl.ih"
30 //#include "PacketImpl.mpp"
32 ///////////////////////////////cc.p////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////////
35 // senf::detail::PacketImpl
39 prefix_ void senf::detail::PacketImpl::appendInterpreter(PacketInterpreterBase * p)
41 interpreters_.push_back(*p);
45 prefix_ void senf::detail::PacketImpl::prependInterpreter(PacketInterpreterBase * p)
47 interpreters_.push_front(*p);
53 prefix_ void senf::detail::PacketImpl::clear(PacketData * self)
55 PacketInterpreterBase * n (next(static_cast<PacketInterpreterBase*>(self)));
57 truncateInterpreters(n);
58 iterator first (boost::next(begin(),self->begin_));
59 data_.erase(first, boost::next(begin(),self->end_));
60 updateIterators(self,first,-self->size());
65 prefix_ void senf::detail::PacketImpl::eraseInterpreters(interpreter_list::iterator b,
66 interpreter_list::iterator e)
69 interpreter_list::iterator i (b++);
70 PacketInterpreterBase * p (&(*i));
71 interpreters_.erase(i);
72 p->releaseImpl(); // might call PacketImpl::release and might delete p
76 prefix_ void senf::detail::PacketImpl::updateIterators(PacketData * self, iterator pos,
79 // I hate to change the PacketData representation from here, I would have preferred to let
80 // PacketData have authority over this but trying that just get's to convoluted so I choose the
81 // simple solution and made PacketImpl a friend of PacketData.
83 interpreter_list::iterator i (interpreters_.begin());
85 // There are three types of packets
86 // a) Those which come before 'self' in the interpreter chain
88 // c) Those that come afterwards
89 // For a), the change must be inside the packet since 'self' must be within those packets
90 // For b), the change must also be within since that's the packet we are changeing
91 // For c), the change must be outside the packet (we don't allow an upper packet to mess with
92 // the the data owned by a packet further down the chain). It can be before or after the
96 for (; &(*i) != static_cast<PacketInterpreterBase*>(self); ++i) i->end_ += n;
102 interpreter_list::iterator const i_end (interpreters_.end());
104 if (std::distance(begin(), pos) < difference_type(i->begin_))
105 // pos is before the packet, it must then be before all futher packets ...
106 for (; i != i_end; ++i) {
110 // else pos is after the packet and we don't need to change anything ...
113 ///////////////////////////////cc.e////////////////////////////////////////
115 //#include "PacketImpl.mpp"
121 // c-file-style: "senf"
122 // indent-tabs-mode: nil
123 // ispell-local-dictionary: "american"
124 // compile-command: "scons -u test"
125 // comment-column: 40