//#include "PacketInterpreter.mpp"
#define prefix_
-///////////////////////////////cc.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
// senf::PacketInterpreterBase
// structors and default members
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;
}
{
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());
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)
{
- if (detail::AnnotationIndexerBase::maxAnnotations > 0) {
- os << "Annotations:\n";
- impl().dumpAnnotations(os);
+ try {
+ if (detail::AnnotationRegistry::instance().begin()
+ != detail::AnnotationRegistry::instance().end()) {
+ os << "Annotations:\n";
+ impl().dumpAnnotations(os);
+ }
+ v_dump(os);
+ for (ptr i (next()); i; i = i->next())
+ i->v_dump(os);
+ }
+ catch (senf::Exception & e) {
+ os << "[Exception: " << e.message() << "]\n";
}
- v_dump(os);
- for (ptr i (next()); i; i = i->next())
- i->v_dump(os);
}
prefix_ void senf::PacketInterpreterBase::finalizeThis()
finalizeThis();
}
-///////////////////////////////////////////////////////////////////////////
+// reference/memory management
+
+prefix_ void senf::PacketInterpreterBase::add_ref()
+{
+ if (impl_ && !refcount())
+ impl_->add_ref();
+ intrusive_refcount_t<PacketInterpreterBase>::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<PacketInterpreterBase>::release() && !impl_)
+ delete this;
+}
+
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
// senf::PacketInterpreterBase::Factory
prefix_ senf::PacketInterpreterBase::Factory::~Factory()
{}
-///////////////////////////////cc.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
#undef prefix_
//#include "PacketInterpreter.mpp"