X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FPacketInterpreter.cc;h=d0cff2040ab682ddbcafcf2e356d9346ebf8f107;hb=57daeae6f2e924ce3f16f9677c3474f531cba9e5;hp=9c7e3b29837a9be57dc3679327788f9421b122e3;hpb=35e271d6c345505475a8cd2654950edd9060e712;p=senf.git diff --git a/senf/Packets/PacketInterpreter.cc b/senf/Packets/PacketInterpreter.cc index 9c7e3b2..d0cff20 100644 --- a/senf/Packets/PacketInterpreter.cc +++ b/senf/Packets/PacketInterpreter.cc @@ -30,9 +30,9 @@ //#include "PacketInterpreter.mpp" #define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::PacketInterpreterBase // structors and default members @@ -46,6 +46,7 @@ prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::clone() ptr pi (appendClone(p.p,begin(),p.p->begin())); for (ptr i (next()); i; i = i->next()) i->appendClone(p.p,begin(),p.p->begin()); + pi->impl().assignAnnotations( impl()); return pi; } @@ -55,11 +56,11 @@ prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::append(ptr { if (next()) impl().truncateInterpreters(next().get()); - + optional_range r (nextPacketRange()); if (!r) throw InvalidPacketChainException(); - + ptr rv (packet->appendClone(&impl(), *r)); rv->data().resize(packet->data().size()); std::copy(packet->data().begin(), packet->data().end(), rv->data().begin()); @@ -70,12 +71,19 @@ prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::append(ptr return rv; } +prefix_ void senf::PacketInterpreterBase::reparse() +{ + if (next()) + impl().truncateInterpreters(next().get()); +} + // Access to the abstract interface prefix_ void senf::PacketInterpreterBase::dump(std::ostream & os) { try { - if (detail::AnnotationIndexerBase::maxAnnotations > 0) { + if (detail::AnnotationRegistry::instance().begin() + != detail::AnnotationRegistry::instance().end()) { os << "Annotations:\n"; impl().dumpAnnotations(os); } @@ -100,13 +108,31 @@ prefix_ void senf::PacketInterpreterBase::finalizeTo(ptr other) finalizeThis(); } -/////////////////////////////////////////////////////////////////////////// +// reference/memory management + +prefix_ void senf::PacketInterpreterBase::add_ref() +{ + if (impl_ && !refcount()) + impl_->add_ref(); + intrusive_refcount_t::add_ref(); +} + +prefix_ void senf::PacketInterpreterBase::release() +{ + if (impl_ && refcount()==1) + // This call will set impl_ to 0 if we just removed the last reference ... + impl_->release(); + if (intrusive_refcount_t::release() && !impl_) + delete this; +} + +//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::PacketInterpreterBase::Factory prefix_ senf::PacketInterpreterBase::Factory::~Factory() {} -///////////////////////////////cc.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ //#include "PacketInterpreter.mpp"