X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacketImpl.cti;h=e3ec1eaf16fd7995add8f6c1bab119b55bc5e0fd;hb=1a29b75bf774444ec182dfff8480a0c53597bf85;hp=9c431f59e3351f17e86616d9c9963ce1b46b9c79;hpb=6116cb96ea7bdcb42b7d12165a05fcbe0687226d;p=senf.git diff --git a/Packets/PacketImpl.cti b/Packets/PacketImpl.cti index 9c431f5..e3ec1ea 100644 --- a/Packets/PacketImpl.cti +++ b/Packets/PacketImpl.cti @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -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_