From 694d9c7a18d6a4fde28b407dba0edb0f7a14915d Mon Sep 17 00:00:00 2001 From: marian Date: Fri, 31 Oct 2008 12:05:50 +0000 Subject: [PATCH] Added static template method to engine used to remove a component from its engine and destroy it. git-svn-id: http://voip.null.ro/svn/yate@2296 acf43c95-373e-0410-b603-e72c3f656dc1 --- libs/ysig/yatesig.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libs/ysig/yatesig.h b/libs/ysig/yatesig.h index f99c2843..eb201ab5 100644 --- a/libs/ysig/yatesig.h +++ b/libs/ysig/yatesig.h @@ -685,6 +685,19 @@ public: */ Thread* thread() const; + /** + * Helper template used to remove a component descendant from its engine, + * destroy it and set the received pointer to 0 + * @param obj Reference to pointer (lvalue) to the object to remove and destroy + */ + template static inline void destruct(Obj*& obj) { + if (!obj) + return; + if (obj->engine()) + obj->engine()->remove(obj); + TelEngine::destruct(obj); + } + protected: /** * Method called periodically by the worker thread to keep everything alive