X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacketImpl.cti;h=e3ec1eaf16fd7995add8f6c1bab119b55bc5e0fd;hb=1e7062482bb6d99a0c36b641069c73a4a93da9cc;hp=a00a8e3aea2d2e0ce925060592f0df4ac74e0f56;hpb=a1a6c76a214ad1935032826713cabaf9ac57bf07;p=senf.git diff --git a/Packets/PacketImpl.cti b/Packets/PacketImpl.cti index a00a8e3..e3ec1ea 100644 --- a/Packets/PacketImpl.cti +++ b/Packets/PacketImpl.cti @@ -31,6 +31,69 @@ ///////////////////////////////cti.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// +// senf::detail::AnnotationIndexer + +template +prefix_ senf::detail::AnnotationIndexer::AnnotationIndexer() + : index_ (maxAnnotations++) +{ + small().push_back(Small); + registry().push_back(this); +} + +/////////////////////////////////////////////////////////////////////////// +// senf::detail::AnnotationIndexer + + +template +prefix_ void senf::detail::AnnotationIndexer::v_dump(PacketImpl * p, + std::ostream & os) +{ + + os << " " << senf::prettyName(typeid(Annotation)) << ": "; + p->dumpAnnotation(os); + os << "\n"; +} + +template +prefix_ unsigned senf::detail::AnnotationIndexer::index() +{ + return AnnotationIndexer::instance().index_; +} + +/////////////////////////////////////////////////////////////////////////// +// senf::detail::GetAnnotation + +template +prefix_ Annotation & senf::detail::GetAnnotation::get(AnnotationEntry & e) +{ + if (!e.p) + e.p = new TAnnotationP(); + return static_cast< TAnnotationP* >(e.p)->annotation; +} + +template +prefix_ void senf::detail::GetAnnotation::dump(AnnotationEntry & e, + std::ostream & os) +{ + if (!e.p) os << "no value"; + else os << get(e); +} + +template +prefix_ Annotation & senf::detail::GetAnnotation::get(AnnotationEntry & e) +{ + return * static_cast(static_cast(& e.i)); +} + +template +prefix_ void senf::detail::GetAnnotation::dump(AnnotationEntry & e, + std::ostream & os) +{ + os << get(e); +} + +/////////////////////////////////////////////////////////////////////////// // senf::detail::PacketImpl // Data container @@ -46,9 +109,25 @@ prefix_ void senf::detail::PacketImpl::insert(PacketData * self, iterator pos, F template prefix_ senf::detail::PacketImpl::PacketImpl(InputIterator first, InputIterator last) - : refcount_(0), data_(first,last) + : refcount_(0), data_(first,last), annotations_(AnnotationIndexerBase::maxAnnotations) {} +// Annotations + +template +prefix_ Annotation & senf::detail::PacketImpl::annotation() +{ + return GetAnnotation::get( + annotations_[AnnotationIndexer::index()]); +} + +template +prefix_ void senf::detail::PacketImpl::dumpAnnotation(std::ostream & os) +{ + GetAnnotation::dump( + annotations_[AnnotationIndexer::index()], os); +} + ///////////////////////////////cti.e/////////////////////////////////////// #undef prefix_