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////////////////////////////////////////
41 public pool_alloc_mixin<PacketImpl>
44 typedef senf::detail::packet::byte byte;
45 typedef senf::detail::packet::raw_container raw_container;
46 typedef senf::detail::packet::size_type size_type;
47 typedef senf::detail::packet::difference_type difference_type;
48 typedef senf::detail::packet::interpreter_list interpreter_list;
49 typedef senf::detail::packet::iterator iterator;
50 typedef senf::detail::packet::const_iterator const_iterator;
51 typedef senf::detail::packet::refcount_t refcount_t;
56 PacketImpl(size_type size, byte initValue);
57 template <class InputIterator>
58 PacketImpl(InputIterator b, InputIterator e);
61 // rerference/memory management
63 void add_ref(refcount_t n=1);
64 void release(refcount_t n=1);
65 refcount_t refcount() const;
69 PacketInterpreterBase * first();
70 PacketInterpreterBase * last();
72 PacketInterpreterBase * next(PacketInterpreterBase * p);
73 PacketInterpreterBase * prev(PacketInterpreterBase * p);
75 void appendInterpreter (PacketInterpreterBase * p);
76 void prependInterpreter (PacketInterpreterBase * p);
77 void truncateInterpreters (PacketInterpreterBase * p);
78 void truncateInterpretersBackwards (PacketInterpreterBase * p);
86 void insert(PacketData * self, iterator pos, byte v);
87 void insert(PacketData * self, iterator pos, size_type n, byte v);
88 template <class ForwardIterator>
89 void insert(PacketData * self, iterator pos, ForwardIterator f, ForwardIterator l);
91 void erase(PacketData * self, iterator pos);
92 void erase(PacketData * self, iterator first, iterator last);
93 void clear(PacketData * self);
95 // The Guard will keep the PacketImpl instance alive during a members execution time
96 // It the refcount should drop to 0, PacketImpl will be deleted after the member
97 // has completed executing.
99 Guard(PacketImpl * impl);
105 refcount_t refcount_;
107 interpreter_list interpreters_;
109 void eraseInterpreters(interpreter_list::iterator b, interpreter_list::iterator e);
110 void updateIterators(PacketData * self, iterator pos, difference_type n);
116 ///////////////////////////////hh.e////////////////////////////////////////
118 #if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketImpl_i_)
119 #define HH_PacketImpl_i_
120 #include "PacketImpl.cci"
121 //#include "PacketImpl.ct"
122 #include "PacketImpl.cti"
129 // c-file-style: "senf"
130 // indent-tabs-mode: nil
131 // ispell-local-dictionary: "american"
132 // compile-command: "scons -u test"
133 // comment-column: 40