X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FPacketImpl.cti;h=863c42aa92148647ab25776e203f40580346b08b;hb=e3179a2123ad51d0d9eb63834a581145c4f77c92;hp=308e7b392ac538d0998264de9be64781981631b6;hpb=943a6b0973f66bc699c6e7b404da256145e93acf;p=senf.git diff --git a/senf/Packets/PacketImpl.cti b/senf/Packets/PacketImpl.cti index 308e7b3..863c42a 100644 --- a/senf/Packets/PacketImpl.cti +++ b/senf/Packets/PacketImpl.cti @@ -28,55 +28,44 @@ // Custom includes #define prefix_ inline -///////////////////////////////cti.p/////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::detail::AnnotationRegistry template -prefix_ key_t senf::detail::AnnotationRegistry::registerAnnotation() +prefix_ senf::detail::AnnotationRegistry::key_type +senf::detail::AnnotationRegistry::registerAnnotation() { - key_t key (simpleAnnotationCount_ >= SENF_PACKET_ANNOTATION_SLOTS + key_type key (simpleAnnotationCount_ >= SENF_PACKET_ANNOTATION_SLOTS || IsComplexAnnotation::value ? - ++complexAnnotationCount_ : simpleAnnotationCount_ ++); - registry_.insert(key, new Registration()); - std::cerr << ">> allocated key " << key - << " for " << prettyName(typeid(Annotation)) - << "(complex: " << IsComplexAnnotation::value - << ", convertible: " << boost::is_convertible::value - << ", size: " << sizeof(Annotation) - << ", max: " << SENF_PACKET_ANNOTATION_SLOTSIZE << ")" << std::endl; + std::pair reg ( + registry_.insert(key, new Registration())); + SENF_ASSERT(reg.second, "internal error: duplicate annotation key"); + index_.insert(std::make_pair(reg.first->second->v_name(), key)); return key; } template -prefix_ key_t senf::detail::AnnotationRegistry::lookup() +prefix_ senf::detail::AnnotationRegistry::key_type senf::detail::AnnotationRegistry::lookup() { - SENF_ASSERT( instance().keyBegin() <= AnnotationRegistry::Entry::key() - && AnnotationRegistry::Entry::key() < instance().keyEnd(), - "internal error: annotation key not registered" ); - SENF_ASSERT( AnnotationRegistry::Entry::key() < 0 - || ! IsComplexAnnotation::value, - "internal error: complex annotation registered with invalid key" ); - SENF_ASSERT( AnnotationRegistry::Entry::key() < SENF_PACKET_ANNOTATION_SLOTS, - "internal error: annotation key out of valid range" ); + SENF_ASSERT( + -instance().complexAnnotationCount_ <= AnnotationRegistry::Entry::key() + && AnnotationRegistry::Entry::key() < instance().simpleAnnotationCount_, + "internal error: annotation key not registered" ); + SENF_ASSERT( + AnnotationRegistry::Entry::key() < 0 + || ! IsComplexAnnotation::value, + "internal error: complex annotation registered with invalid key" ); + SENF_ASSERT( + AnnotationRegistry::Entry::key() < SENF_PACKET_ANNOTATION_SLOTS, + "internal error: annotation key out of valid range" ); return AnnotationRegistry::Entry::key(); } -prefix_ key_t senf::detail::AnnotationRegistry::keyBegin() - const -{ - return -complexAnnotationCount_; -} - -prefix_ key_t senf::detail::AnnotationRegistry::keyEnd() - const -{ - return simpleAnnotationCount_; -} - -/////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::detail::PacketImpl // Data container @@ -102,13 +91,13 @@ prefix_ senf::detail::PacketImpl::PacketImpl(InputIterator first, InputIterator template prefix_ Annotation & senf::detail::PacketImpl::annotation() { - AnnotationRegistry::key_t key (AnnotationRegistry::lookup()); + AnnotationRegistry::key_type key (AnnotationRegistry::lookup()); void * antn (key >= 0 ? & simpleAnnotations_[key] : complexAnnotation()); SENF_ASSERT( antn, "internal error: null annotation pointer" ); return * static_cast(antn); } -///////////////////////////////cti.e/////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_