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 PacketImpl public header */
26 #ifndef HH_PacketImpl_
27 #define HH_PacketImpl_ 1
31 #include <boost/utility.hpp>
32 #include "../Utils/pool_alloc_mixin.hh"
33 #include "PacketTypes.hh"
35 //#include "PacketImpl.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
41 /** \brief Internal: Packet data storage
45 This is the class holding the packet data and the interpreter chain. All manipulations of
46 the packet data are performed via the interface exported here. This is very important, since
47 PacketImpl will update the interpreters (that is the vector indices stored therein) whenever
52 public pool_alloc_mixin<PacketImpl>
55 typedef senf::detail::packet::byte byte;
56 typedef senf::detail::packet::raw_container raw_container;
57 typedef senf::detail::packet::size_type size_type;
58 typedef senf::detail::packet::difference_type difference_type;
59 typedef senf::detail::packet::interpreter_list interpreter_list;
60 typedef senf::detail::packet::iterator iterator;
61 typedef senf::detail::packet::const_iterator const_iterator;
62 typedef senf::detail::packet::refcount_t refcount_t;
67 PacketImpl(size_type size, byte initValue);
68 template <class InputIterator>
69 PacketImpl(InputIterator b, InputIterator e);
72 // rerference/memory management
74 void add_ref(refcount_t n=1);
75 void release(refcount_t n=1);
76 refcount_t refcount() const;
80 PacketInterpreterBase * first();
81 PacketInterpreterBase * last();
83 PacketInterpreterBase * next(PacketInterpreterBase * p);
84 PacketInterpreterBase * prev(PacketInterpreterBase * p);
86 void appendInterpreter (PacketInterpreterBase * p);
87 void prependInterpreter (PacketInterpreterBase * p);
88 void truncateInterpreters (PacketInterpreterBase * p);
89 void truncateInterpretersBackwards (PacketInterpreterBase * p);
97 void insert(PacketData * self, iterator pos, byte v);
98 void insert(PacketData * self, iterator pos, size_type n, byte v);
99 template <class ForwardIterator>
100 void insert(PacketData * self, iterator pos, ForwardIterator f, ForwardIterator l);
102 void erase(PacketData * self, iterator pos);
103 void erase(PacketData * self, iterator first, iterator last);
104 void clear(PacketData * self);
106 /** \brief Internal: Keep PacketImpl instance alive
110 The Guard will keep the PacketImpl instance alive during a members execution time
111 It the refcount should drop to 0, PacketImpl will be deleted after the member
112 has completed executing.
115 Guard(PacketImpl * impl);
121 refcount_t refcount_;
123 interpreter_list interpreters_;
125 void eraseInterpreters(interpreter_list::iterator b, interpreter_list::iterator e);
126 void updateIterators(PacketData * self, difference_type pos, difference_type n);
131 ///////////////////////////////hh.e////////////////////////////////////////
133 #if !defined(HH_Packets__decls_) && !defined(HH_PacketImpl_i_)
134 #define HH_PacketImpl_i_
135 #include "PacketImpl.cci"
136 //#include "PacketImpl.ct"
137 #include "PacketImpl.cti"
144 // c-file-style: "senf"
145 // indent-tabs-mode: nil
146 // ispell-local-dictionary: "american"
147 // compile-command: "scons -u test"
148 // comment-column: 40