-// Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
///////////////////////////////cti.p///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
+// senf::detail::AnnotationIndexer<Annotation>
+
+template <class Annotation>
+prefix_ senf::detail::AnnotationIndexer<Annotation>::AnnotationIndexer()
+ : index_ (maxAnnotations++)
+{
+ small().push_back(Small);
+}
+
+template <class Annotation>
+prefix_ unsigned senf::detail::AnnotationIndexer<Annotation>::index()
+{
+ return AnnotationIndexer::instance().index_;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::detail::GetAnnotation<Annotation,Small>
+
+template <class Annotation, bool Small>
+prefix_ Annotation & senf::detail::GetAnnotation<Annotation,Small>::get(AnnotationEntry & e)
+{
+ if (!e.p)
+ e.p = new TAnnotationP<Annotation>();
+ return static_cast< TAnnotationP<Annotation>* >(e.p)->annotation;
+}
+
+template <class Annotation>
+prefix_ Annotation & senf::detail::GetAnnotation<Annotation, true>::get(AnnotationEntry & e)
+{
+ return * static_cast<Annotation*>(static_cast<void*>(& e.i));
+}
+
+///////////////////////////////////////////////////////////////////////////
// senf::detail::PacketImpl
// Data container
template <class InputIterator>
prefix_ senf::detail::PacketImpl::PacketImpl(InputIterator first, InputIterator last)
- : refcount_(0), data_(first,last)
+ : refcount_(0), data_(first,last), annotations_(AnnotationIndexerBase::maxAnnotations)
{}
+// Annotations
+
+template <class Annotation>
+prefix_ Annotation & senf::detail::PacketImpl::annotation()
+{
+ return GetAnnotation<Annotation>::get(
+ annotations_[AnnotationIndexer<Annotation>::index()]);
+}
+
///////////////////////////////cti.e///////////////////////////////////////
#undef prefix_