From edd3ac38162ff897429cc7af71557dc54e7d5efe Mon Sep 17 00:00:00 2001 From: guigues Date: Thu, 30 Apr 2009 14:31:30 +0000 Subject: [PATCH] *** empty log message *** --- kernel/src/bbtkAtomicBlackBox.h | 13 +++- kernel/src/bbtkAtomicBlackBoxMacros.h | 88 ++++++++++----------------- kernel/src/bbtkBlackBox.cxx | 29 ++++++--- kernel/src/bbtkBlackBox.h | 22 +++++-- kernel/src/bbtkInterpreter.cxx | 6 +- kernel/src/bbtkItkBlackBoxMacros.h | 8 ++- kernel/src/bbtkObject.cxx | 25 +++++--- kernel/src/bbtkObject.h | 7 +-- kernel/src/bbtkVtkBlackBoxMacros.h | 13 ++-- packages/vtk/src/bbvtkImagePlanes.cxx | 14 ++--- 10 files changed, 119 insertions(+), 106 deletions(-) diff --git a/kernel/src/bbtkAtomicBlackBox.h b/kernel/src/bbtkAtomicBlackBox.h index 3be6751..8348ea4 100644 --- a/kernel/src/bbtkAtomicBlackBox.h +++ b/kernel/src/bbtkAtomicBlackBox.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkAtomicBlackBox.h,v $ Language: C++ - Date: $Date: 2008/12/11 09:50:34 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009/04/30 14:31:30 $ + Version: $Revision: 1.9 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -147,6 +147,15 @@ namespace bbtk virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer) {} /// User callback called in the box destructor virtual void bbUserDestructor() {} + //================================================================== + + //================================================================== + /// System callback which calls bbUserConstructor for all its ancestors + /// and the box itself + virtual void bbConstructor() {} + /// System callback which calls bbUserDestructor for all its ancestors + /// and the box itself + virtual void bbDestructor() {} //================================================================== //================================================================== diff --git a/kernel/src/bbtkAtomicBlackBoxMacros.h b/kernel/src/bbtkAtomicBlackBoxMacros.h index 8d8df46..9bc56ad 100644 --- a/kernel/src/bbtkAtomicBlackBoxMacros.h +++ b/kernel/src/bbtkAtomicBlackBoxMacros.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $ Language: C++ - Date: $Date: 2009/04/08 07:56:11 $ - Version: $Revision: 1.14 $ + Date: $Date: 2009/04/30 14:31:30 $ + Version: $Revision: 1.15 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -41,7 +41,7 @@ /// Declares the standard interface of a AtomicBlackBox /// (ctor, New, descriptor related methods) #define BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT) \ - BBTK_OBJECT_MINIMAL_INTERFACE; \ + BBTK_OBJECT_MINIMAL_INTERFACE; \ private: \ protected: \ CLASS(const std::string& name, bool allocate_connectors = true); \ @@ -53,10 +53,18 @@ { return std::string(#CLASS)+std::string(" '") \ +bbGetNameWithParent()+std::string("'"); } \ virtual void bbLockDescriptor(); \ + virtual void bbConstructor() { \ + PARENT::bbConstructor(); \ + CLASS::bbUserConstructor(); \ + } \ + virtual void bbDestructor() { \ + PARENT::bbDestructor(); \ + CLASS::bbUserDestructor(); \ + } \ private: \ CLASS() : PARENT("") {} \ CLASS(const CLASS&) : PARENT("") {} - + //============================================================================ //============================================================================ @@ -93,6 +101,14 @@ return p; \ } \ virtual void bbLockDescriptor(); \ + virtual void bbConstructor() { \ + PARENT::bbConstructor(); \ + CLASS::bbUserConstructor(); \ + } \ + virtual void bbDestructor() { \ + PARENT::bbDestructor(); \ + CLASS::bbUserDestructor(); \ + } \ private: \ CLASS() : PARENT("") {} \ CLASS(const CLASS&) : PARENT("") {} @@ -233,7 +249,7 @@ : PARENT(name,false) \ { \ BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \ - CLASS::bbUserConstructor(); \ + /*CLASS::bbUserConstructor(); */ \ BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \ } \ CLASS::CLASS(CLASS& from, \ @@ -241,13 +257,13 @@ : PARENT(from,name,false) \ { \ BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \ - CLASS::bbUserCopyConstructor(from.GetThisPointer()); \ + /*CLASS::bbUserCopyConstructor(from.GetThisPointer());*/ \ BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \ } \ CLASS::~CLASS() \ { \ BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \ - CLASS::bbUserDestructor(); \ + /*CLASS::bbUserDestructor();*/ \ BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \ } \ void CLASS::bbLockDescriptor() \ @@ -279,10 +295,10 @@ { \ return Instance(); \ } \ - static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \ + static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \ { \ - static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \ - bbtk::AtomicBlackBoxDescriptor::Pointer j; \ + static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \ + bbtk::AtomicBlackBoxDescriptor::Pointer j; \ if (!i.lock()) { j = Self::New(); i = j; } \ return i.lock(); \ } \ @@ -520,7 +536,7 @@ : PARENT(name,false) \ { \ BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \ - CLASS::bbUserConstructor(); \ + /*CLASS::bbUserConstructor();*/ \ BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \ } \ template \ @@ -529,14 +545,14 @@ : PARENT(from,name,false) \ { \ BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \ - CLASS::bbUserCopyConstructor(from.GetThisPointer()); \ + /*CLASS::bbUserCopyConstructor(from.GetThisPointer());*/ \ BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \ } \ template \ CLASS::~CLASS() \ { \ BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \ - CLASS::bbUserDestructor(); \ + /*CLASS::bbUserDestructor();*/ \ BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \ } \ template \ @@ -695,7 +711,7 @@ : PARENT(name,false) \ { \ BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \ - CLASS::bbUserConstructor(); \ + /*CLASS::bbUserConstructor();*/ \ BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \ } \ template \ @@ -704,14 +720,14 @@ : PARENT(from,name,false) \ { \ BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \ - CLASS::bbUserCopyConstructor(from.GetThisPointer()); \ + /*CLASS::bbUserCopyConstructor(from.GetThisPointer());*/ \ BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \ } \ template \ CLASS::~CLASS() \ { \ BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \ - CLASS::bbUserDestructor(); \ + /*CLASS::bbUserDestructor();*/ \ BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \ } \ template \ @@ -722,46 +738,6 @@ //============================================================================ -/* -//============================================================================ -/// Template AtomicBlackBox std implementation of ctor and dtor -#define BBTK_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \ - template \ - CLASS::CLASS(const std::string& name, bool alloc) \ - : PARENT(name,false) \ - { \ - BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \ - this->bbUserConstructor(); \ - BBTK_END_BLACK_BOX_CONSTRUCTOR; \ - } \ - template \ - CLASS::CLASS(CLASS& from, \ - const std::string& name, bool allocate_connectors) \ - : PARENT(from,name,false) \ - { \ - BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \ - this->bbUserCopyConstructor(); \ - BBTK_END_BLACK_BOX_CONSTRUCTOR; \ - } \ - template \ - CLASS::~CLASS() \ - { \ - BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \ - this->bbUserDestructor(); \ - BBTK_END_BLACK_BOX_DESTRUCTOR; \ - } \ - template \ - void CLASS::bbLockDescriptor() \ - { \ - bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \ - } -//============================================================================ - -*/ - - - - diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index 9eb65e2..4aa8d01 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBox.cxx,v $ Language: C++ - Date: $Date: 2009/04/08 07:56:11 $ - Version: $Revision: 1.42 $ + Date: $Date: 2009/04/30 14:31:31 $ + Version: $Revision: 1.43 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -62,7 +62,7 @@ namespace bbtk //========================================================================= //========================================================================= - void BlackBox::Deleter::Delete(Object* p) + int BlackBox::Deleter::Delete(Object* p) { BlackBox* b = dynamic_cast(p); if (!b) @@ -78,7 +78,7 @@ namespace bbtk BlackBoxDescriptor::WeakPointer desc = b->bbGetDescriptor(); bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<bbDelete(); + int refs = b->bbDelete(); bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""< BlackBox::Deleter(\""< BlackBox::BlackBox(" < already executing : abort"<bbConstructor(); + bbmConstructed = true; + } + bbSetExecuting(true); bool wasExecuting = bbGlobalGetSomeBoxExecuting(); diff --git a/kernel/src/bbtkBlackBox.h b/kernel/src/bbtkBlackBox.h index 6e44fde..d25fc88 100644 --- a/kernel/src/bbtkBlackBox.h +++ b/kernel/src/bbtkBlackBox.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBox.h,v $ Language: C++ - Date: $Date: 2009/04/08 07:56:11 $ - Version: $Revision: 1.23 $ + Date: $Date: 2009/04/30 14:31:31 $ + Version: $Revision: 1.24 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -118,7 +118,15 @@ namespace bbtk - + //================================================================== + /// System callback which calls bbUserConstructor for all its ancestors + /// and the box itself + virtual void bbConstructor() {} + /// System callback which calls bbUserDestructor for all its ancestors + /// and the box itself + virtual void bbDestructor() {} + //================================================================== + /// Returns true iff the BlackBox has an input of name label @@ -470,8 +478,8 @@ namespace bbtk /// 2) Releases the box descriptor struct BBTK_EXPORT Deleter : public Object::Deleter { - Deleter(); - void Delete(Object* p); + Deleter(); + int Delete(Object* p); }; //================================================================== @@ -484,7 +492,7 @@ namespace bbtk //================================================================== //================================================================== - virtual void bbDelete() { delete this; } + virtual int bbDelete() { delete this; return 0; } //================================================================== @@ -494,6 +502,8 @@ namespace bbtk //================================================================== // ATTRIBUTES + /// Is the box "constructed" ? (initialized) + bool bbmConstructed; /// Is the box executing ? bool bbmExecuting; /// The name of the black-box diff --git a/kernel/src/bbtkInterpreter.cxx b/kernel/src/bbtkInterpreter.cxx index ef8be1b..e71ff53 100644 --- a/kernel/src/bbtkInterpreter.cxx +++ b/kernel/src/bbtkInterpreter.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ Language: C++ - Date: $Date: 2009/04/08 07:56:11 $ - Version: $Revision: 1.83 $ + Date: $Date: 2009/04/30 14:31:31 $ + Version: $Revision: 1.84 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -219,7 +219,7 @@ namespace bbtk info.argmin = 1; info.argmax = 1; info.code = cKind; - info.syntax = "kind "; + info.syntax = "kind "; info.help = "Sets the kind of the currently defined complex black box"; mCommandDict[info.keyword] = info; diff --git a/kernel/src/bbtkItkBlackBoxMacros.h b/kernel/src/bbtkItkBlackBoxMacros.h index 7f10fef..ddcb7b9 100644 --- a/kernel/src/bbtkItkBlackBoxMacros.h +++ b/kernel/src/bbtkItkBlackBoxMacros.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkItkBlackBoxMacros.h,v $ Language: C++ - Date: $Date: 2008/10/17 08:18:13 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009/04/30 14:31:31 $ + Version: $Revision: 1.5 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -44,8 +44,10 @@ //=========================================================================== #define BBTK_ITK_DELETE() \ - void bbDelete() { \ + int bbDelete() { \ + int refs = itkParent::GetReferenceCount()-1; \ itkParent::UnRegister(); \ + return refs; \ } //=========================================================================== diff --git a/kernel/src/bbtkObject.cxx b/kernel/src/bbtkObject.cxx index 7f7bc2e..52fa180 100644 --- a/kernel/src/bbtkObject.cxx +++ b/kernel/src/bbtkObject.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkObject.cxx,v $ Language: C++ - Date: $Date: 2008/10/17 08:18:13 $ - Version: $Revision: 1.10 $ + Date: $Date: 2009/04/30 14:31:31 $ + Version: $Revision: 1.11 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -140,13 +140,13 @@ namespace bbtk { std::cout<<"* Note : "<1) { std::cout<<"* Note : "< Object::Deleter : deleting \"" <Delete(p); - bbtkDebugMessage("object",2,"<## Object::Deleter : \""<Delete(p); + if (remaining == 0) + { + Object::RemoveFromObjectList(mPointer); + bbtkDebugMessage("object",2,"<## Object::Deleter : \""< > ObjectListType; static ObjectListType mgObjectList; diff --git a/kernel/src/bbtkVtkBlackBoxMacros.h b/kernel/src/bbtkVtkBlackBoxMacros.h index ce87d7e..21816d3 100644 --- a/kernel/src/bbtkVtkBlackBoxMacros.h +++ b/kernel/src/bbtkVtkBlackBoxMacros.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkVtkBlackBoxMacros.h,v $ Language: C++ - Date: $Date: 2009/02/27 11:20:25 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009/04/30 14:31:31 $ + Version: $Revision: 1.9 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -80,16 +80,13 @@ //=========================================================================== #define BBTK_VTK_DELETE() \ - void bbDelete() { \ + int bbDelete() { \ for (int i=0; iSetSource(NULL); \ - /*std::cout << "VTK : bbDelete() "<SetInput(NULL); - bbGetOutputPlaneX()->RemoveObserver(mVtkCallback); + // if (mVtkCallback) bbGetOutputPlaneX()->RemoveObserver(mVtkCallback); bbGetOutputPlaneX()->Delete(); } if (bbGetOutputPlaneY()) { bbGetOutputPlaneY()->SetInput(NULL); - bbGetOutputPlaneY()->RemoveObserver(mVtkCallback); + // if (mVtkCallback) bbGetOutputPlaneY()->RemoveObserver(mVtkCallback); bbGetOutputPlaneY()->Delete(); } if (bbGetOutputPlaneZ()) { bbGetOutputPlaneZ()->SetInput(NULL); - bbGetOutputPlaneZ()->RemoveObserver(mVtkCallback); + // if (mVtkCallback) bbGetOutputPlaneZ()->RemoveObserver(mVtkCallback); bbGetOutputPlaneZ()->Delete(); } if (mVtkCallback) { - mVtkCallback->Delete(); + // mVtkCallback->Delete(); } } -- 2.45.1