Utils/Console: Add SENF_CONSOLE_REGISTER_ENUM 'key()' support
[senf.git] / senf / Packets / PacketInterpreter.cc
index 6fd279a..cb94b8d 100644 (file)
@@ -75,8 +75,8 @@ prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::append(ptr
 prefix_ void senf::PacketInterpreterBase::dump(std::ostream & os)
 {
     try {
-        if (detail::AnnotationRegistry::instance().keyBegin()
-            != detail::AnnotationRegistry::instance().keyEnd()) {
+        if (detail::AnnotationRegistry::instance().begin()
+            != detail::AnnotationRegistry::instance().end()) {
             os << "Annotations:\n";
             impl().dumpAnnotations(os);
         }
@@ -101,6 +101,24 @@ 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<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