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 public header */
24 #ifndef HH_PacketImpl_
25 #define HH_PacketImpl_ 1
29 #include <boost/utility.hpp>
30 #include "Utils/pool_alloc_mixin.hh"
31 #include "PacketTypes.hh"
33 //#include "PacketImpl.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
39 /** \brief Internal: Packet data storage
43 This is the class holding the packet data and the interpreter chain. All manipulations of
44 the packet data are performed via the interface exported here. This is very important, since
45 PacketImpl will update the interpreters (that is the vector indices stored therein) whenever
50 public pool_alloc_mixin<PacketImpl>
53 typedef senf::detail::packet::byte byte;
54 typedef senf::detail::packet::raw_container raw_container;
55 typedef senf::detail::packet::size_type size_type;
56 typedef senf::detail::packet::difference_type difference_type;
57 typedef senf::detail::packet::interpreter_list interpreter_list;
58 typedef senf::detail::packet::iterator iterator;
59 typedef senf::detail::packet::const_iterator const_iterator;
60 typedef senf::detail::packet::refcount_t refcount_t;
65 PacketImpl(size_type size, byte initValue);
66 template <class InputIterator>
67 PacketImpl(InputIterator b, InputIterator e);
70 // rerference/memory management
72 void add_ref(refcount_t n=1);
73 void release(refcount_t n=1);
74 refcount_t refcount() const;
78 PacketInterpreterBase * first();
79 PacketInterpreterBase * last();
81 PacketInterpreterBase * next(PacketInterpreterBase * p);
82 PacketInterpreterBase * prev(PacketInterpreterBase * p);
84 void appendInterpreter (PacketInterpreterBase * p);
85 void prependInterpreter (PacketInterpreterBase * p);
86 void truncateInterpreters (PacketInterpreterBase * p);
87 void truncateInterpretersBackwards (PacketInterpreterBase * p);
95 void insert(PacketData * self, iterator pos, byte v);
96 void insert(PacketData * self, iterator pos, size_type n, byte v);
97 template <class ForwardIterator>
98 void insert(PacketData * self, iterator pos, ForwardIterator f, ForwardIterator l);
100 void erase(PacketData * self, iterator pos);
101 void erase(PacketData * self, iterator first, iterator last);
102 void clear(PacketData * self);
104 /** \brief Internal: Keep PacketImpl instance alive
108 The Guard will keep the PacketImpl instance alive during a members execution time
109 It the refcount should drop to 0, PacketImpl will be deleted after the member
110 has completed executing.
113 Guard(PacketImpl * impl);
119 refcount_t refcount_;
121 interpreter_list interpreters_;
123 void eraseInterpreters(interpreter_list::iterator b, interpreter_list::iterator e);
124 void updateIterators(PacketData * self, iterator pos, difference_type n);
129 ///////////////////////////////hh.e////////////////////////////////////////
131 #if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketImpl_i_)
132 #define HH_PacketImpl_i_
133 #include "PacketImpl.cci"
134 //#include "PacketImpl.ct"
135 #include "PacketImpl.cti"
142 // c-file-style: "senf"
143 // indent-tabs-mode: nil
144 // ispell-local-dictionary: "american"
145 // compile-command: "scons -u test"
146 // comment-column: 40