X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacketImpl.hh;h=32ae5a17a0b79eda12fde332d4fe72c231f22bed;hb=a1fdb7bb122f0b05be809a922d4b7ef5e125fa67;hp=92738a46277fe02446ebb17740e96c600867fb54;hpb=51b10105e78a9ffee631223f50e63aa28bb5d2b4;p=senf.git diff --git a/Packets/PacketImpl.hh b/Packets/PacketImpl.hh index 92738a4..32ae5a1 100644 --- a/Packets/PacketImpl.hh +++ b/Packets/PacketImpl.hh @@ -23,14 +23,17 @@ /** \file \brief PacketImpl public header */ -#ifndef HH_PacketImpl_ -#define HH_PacketImpl_ 1 +#ifndef HH_SENF_Packets_PacketImpl_ +#define HH_SENF_Packets_PacketImpl_ 1 // Custom includes #include #include #include #include +#include +#include +#include #include "../Utils/pool_alloc_mixin.hh" #include "PacketTypes.hh" #include "../Utils/singleton.hh" @@ -40,6 +43,22 @@ namespace senf { + /** \brief Marker base-class for complex annotations + + This class is used as a base class to mark an annotation type as complex. A complex + annotation will have it's constructor/destructor called. Non-complex annotations will not + have their constructor called, they will be zero initialized. The destructor of non-complex + annotations is never called. + + An annotation must be marked as complex if it is not POD. Simplified, an + annotation must be marked as ComplexAnnotation, if + + \li it has a (user defined) constructor or destructor + \li it has any data members which have (user defined) constructors or destructors + + \see \ref packet_usage_annotation + */ struct ComplexAnnotation {}; namespace detail { @@ -75,8 +94,18 @@ namespace detail { AnnotationIndexer(); unsigned index_; static unsigned index(); - static bool const Small = (sizeof(Annotation) <= sizeof(AnnotationEntry) - && ! boost::is_base_of::value); + static bool const Complex = boost::is_base_of::value; + static bool const Small = (sizeof(Annotation) <= sizeof(AnnotationEntry) && ! Complex); + +# if 0 // The test is difficult since it does not work with user-defined trivial constructors +# ifdef BOOST_HAS_TYPE_TRAITS_INTRINSICS + + BOOST_STATIC_ASSERT(( (boost::has_trivial_constructor::value + && boost::has_trivial_destructor::value) + || Complex )); + +# endif +# endif }; template ::Small> @@ -156,6 +185,9 @@ namespace detail { void erase(PacketData * self, iterator first, iterator last); void clear(PacketData * self); + void reserve(size_type n); + size_type capacity() const; + // Annotations template Annotation & annotation(); @@ -190,8 +222,8 @@ namespace detail { ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(HH_Packets__decls_) && !defined(HH_PacketImpl_i_) -#define HH_PacketImpl_i_ +#if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_PacketImpl_i_) +#define HH_SENF_Packets_PacketImpl_i_ #include "PacketImpl.cci" //#include "PacketImpl.ct" #include "PacketImpl.cti"