X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FPacketImpl.cti;fp=senf%2FPackets%2FPacketImpl.cti;h=062775666ea57ef77dfe2ade8aa5d3c1e151b4fd;hb=20c3dbf64b3beed10655dceaee5791680fb25383;hp=308e7b392ac538d0998264de9be64781981631b6;hpb=5c330db423b5bbfa1b376d55a83e44bbc299bdd8;p=senf.git diff --git a/senf/Packets/PacketImpl.cti b/senf/Packets/PacketImpl.cti index 308e7b3..0627756 100644 --- a/senf/Packets/PacketImpl.cti +++ b/senf/Packets/PacketImpl.cti @@ -34,48 +34,37 @@ // 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 @@ -102,7 +91,7 @@ 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);