00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_Packets_PacketImpl_
00027 #define HH_SENF_Packets_PacketImpl_ 1
00028
00029
00030 #include <memory>
00031 #include <vector>
00032 #include <boost/utility.hpp>
00033 #include <boost/static_assert.hpp>
00034 #include <boost/ptr_container/ptr_vector.hpp>
00035 #include <senf/Utils/pool_alloc_mixin.hh>
00036 #include <senf/Utils/singleton.hh>
00037
00038
00039 #include "PacketImpl.ih"
00040
00041
00042 namespace senf {
00043
00060 struct ComplexAnnotation {};
00061
00097 void dumpPacketAnnotationRegistry(std::ostream & os);
00098
00099 namespace detail {
00100
00110 class PacketImpl
00111 : boost::noncopyable,
00112 public pool_alloc_mixin<PacketImpl>
00113 {
00114 public:
00115 typedef senf::detail::packet::byte byte;
00116 typedef senf::detail::packet::raw_container raw_container;
00117 typedef senf::detail::packet::size_type size_type;
00118 typedef senf::detail::packet::difference_type difference_type;
00119 typedef senf::detail::packet::interpreter_list interpreter_list;
00120 typedef senf::detail::packet::iterator iterator;
00121 typedef senf::detail::packet::const_iterator const_iterator;
00122 typedef senf::detail::packet::refcount_t refcount_t;
00123
00124
00125
00126 PacketImpl();
00127 PacketImpl(size_type size, byte initValue);
00128 template <class InputIterator>
00129 PacketImpl(InputIterator b, InputIterator e);
00130 ~PacketImpl();
00131
00132
00133
00134 void add_ref();
00135 void release();
00136 refcount_t refcount() const;
00137
00138
00139
00140 PacketInterpreterBase * first();
00141 PacketInterpreterBase * last();
00142
00143 PacketInterpreterBase * next(PacketInterpreterBase * p);
00144 PacketInterpreterBase * prev(PacketInterpreterBase * p);
00145
00146 void appendInterpreter (PacketInterpreterBase * p);
00147 void prependInterpreter (PacketInterpreterBase * p);
00148 void prependInterpreter (PacketInterpreterBase * p, PacketInterpreterBase * before);
00149 void truncateInterpreters (PacketInterpreterBase * p);
00150 void truncateInterpretersBackwards (PacketInterpreterBase * p);
00151
00152
00153
00154 iterator begin();
00155 iterator end();
00156 size_type size();
00157
00158 void insert(PacketData * self, iterator pos, byte v);
00159 void insert(PacketData * self, iterator pos, size_type n, byte v);
00160 template <class ForwardIterator>
00161 void insert(PacketData * self, iterator pos, ForwardIterator f, ForwardIterator l);
00162
00163 void erase(PacketData * self, iterator pos);
00164 void erase(PacketData * self, iterator first, iterator last);
00165 void clear(PacketData * self);
00166
00167 void reserve(size_type n);
00168 size_type capacity() const;
00169
00170
00171 template <class Annotation>
00172 Annotation & annotation();
00173
00174 void clearAnnotations();
00175 void assignAnnotations(PacketImpl const & other);
00176 void dumpAnnotations(std::ostream & os);
00177
00186 struct Guard {
00187 Guard(PacketImpl * impl);
00188 ~Guard();
00189 PacketImpl * p;
00190 };
00191
00192 private:
00193 void eraseInterpreters(interpreter_list::iterator b, interpreter_list::iterator e);
00194 void updateIterators(PacketData * self, difference_type pos, difference_type n);
00195
00196 void * annotation(AnnotationRegistry::key_type key);
00197 void * complexAnnotation(AnnotationRegistry::key_type key);
00198 template <class Annotation>
00199 void * complexAnnotation();
00200
00201 refcount_t refcount_;
00202 raw_container data_;
00203 interpreter_list interpreters_;
00204
00205 union SimpleAnnotationSlot
00206 {
00207 unsigned char _ [SENF_PACKET_ANNOTATION_SLOTSIZE];
00208 };
00209
00210 typedef boost::ptr_vector< boost::nullable<AnnotationRegistry::EntryBase> >
00211 ComplexAnnotations;
00212 ComplexAnnotations complexAnnotations_;
00213
00214 SimpleAnnotationSlot simpleAnnotations_[SENF_PACKET_ANNOTATION_SLOTS];
00215 };
00216
00217 }}
00218
00219
00220 #endif
00221 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_PacketImpl_i_)
00222 #define HH_SENF_Packets_PacketImpl_i_
00223 #include "PacketImpl.cci"
00224 #include "PacketImpl.ct"
00225 #include "PacketImpl.cti"
00226 #endif
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237