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 $
=========================================================================*/
/* ---------------------------------------------------------------------
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() {}
//==================================================================
//==================================================================
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 $
=========================================================================*/
/* ---------------------------------------------------------------------
/// 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); \
{ 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("") {}
-
+
//============================================================================
//============================================================================
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("") {}
: 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, \
: PARENT(from,name,false) \
{ \
BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
- CLASS::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>()); \
+ /*CLASS::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>());*/ \
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() \
{ \
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(); \
} \
: PARENT(name,false) \
{ \
BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
- CLASS<T>::bbUserConstructor(); \
+ /*CLASS<T>::bbUserConstructor();*/ \
BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
} \
template <class T> \
: PARENT(from,name,false) \
{ \
BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
- CLASS<T>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>()); \
+ /*CLASS<T>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>());*/ \
BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
} \
template <class T> \
CLASS<T>::~CLASS() \
{ \
BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
- CLASS<T>::bbUserDestructor(); \
+ /*CLASS<T>::bbUserDestructor();*/ \
BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
} \
template <class T> \
: PARENT(name,false) \
{ \
BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
- CLASS<T1,T2>::bbUserConstructor(); \
+ /*CLASS<T1,T2>::bbUserConstructor();*/ \
BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
} \
template <class T1, class T2> \
: PARENT(from,name,false) \
{ \
BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
- CLASS<T1,T2>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>()); \
+ /*CLASS<T1,T2>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>());*/ \
BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
} \
template <class T1, class T2> \
CLASS<T1,T2>::~CLASS() \
{ \
BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
- CLASS<T1,T2>::bbUserDestructor(); \
+ /*CLASS<T1,T2>::bbUserDestructor();*/ \
BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
} \
template <class T1, class T2> \
//============================================================================
-/*
-//============================================================================
-/// Template AtomicBlackBox std implementation of ctor and dtor
-#define BBTK_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
- template <TYPE1 T1, TYPE2 T2> \
- CLASS<T1,T2>::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 <TYPE1 T1, TYPE2 T2> \
- CLASS<T1,T2>::CLASS(CLASS<T1,T2>& 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 <TYPE1 T1, TYPE2 T2> \
- CLASS<T1,T2>::~CLASS() \
- { \
- BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
- this->bbUserDestructor(); \
- BBTK_END_BLACK_BOX_DESTRUCTOR; \
- } \
- template <class T1, class T2> \
- void CLASS<T1,T2>::bbLockDescriptor() \
- { \
- bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
- }
-//============================================================================
-
-*/
-
-
-
-
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 $
=========================================================================*/
/* ---------------------------------------------------------------------
//=========================================================================
//=========================================================================
- void BlackBox::Deleter::Delete(Object* p)
+ int BlackBox::Deleter::Delete(Object* p)
{
BlackBox* b = dynamic_cast<BlackBox*>(p);
if (!b)
BlackBoxDescriptor::WeakPointer desc = b->bbGetDescriptor();
bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : deleting black box"<<std::endl);
- b->bbDelete();
+ int refs = b->bbDelete();
bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : releasing descriptor"<<std::endl);
bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : descriptor expired : nothing to do (was not held by a package or the box is a complex black box prototype)"<<std::endl);
}
bbtkDebugMessage("object",2,"<## BlackBox::Deleter(\""<<name<<"\")"<<std::endl);
+ return refs;
}
//=========================================================================
BlackBox::BlackBox(const std::string &name)
:
// bbmStatus(MODIFIED),
+ bbmConstructed(false),
bbmExecuting(false),
bbmName(name),
bbmBoxProcessMode("Pipeline"),
BlackBox::BlackBox(BlackBox& from, const std::string &name)
:
// bbmStatus(from.bbmStatus),
- bbmExecuting(false),
- bbmName(name),
- bbmBoxProcessMode(from.bbmBoxProcessMode),
- bbmParent()
-
+ bbmConstructed(false),
+ bbmExecuting(false),
+ bbmName(name),
+ bbmBoxProcessMode(from.bbmBoxProcessMode),
+ bbmParent()
+
{
bbtkDebugMessage("object",4,"==> BlackBox::BlackBox("
<<from.bbGetFullName()<<",\""
" -> already executing : abort"<<std::endl);
return;
}
+
+ // If not constructed do it
+ if (!bbmConstructed)
+ {
+ this->bbConstructor();
+ bbmConstructed = true;
+ }
+
bbSetExecuting(true);
bool wasExecuting = bbGlobalGetSomeBoxExecuting();
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 $
=========================================================================*/
/* ---------------------------------------------------------------------
-
+ //==================================================================
+ /// 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
/// 2) Releases the box descriptor
struct BBTK_EXPORT Deleter : public Object::Deleter
{
- Deleter();
- void Delete(Object* p);
+ Deleter();
+ int Delete(Object* p);
};
//==================================================================
//==================================================================
//==================================================================
- virtual void bbDelete() { delete this; }
+ virtual int bbDelete() { delete this; return 0; }
//==================================================================
//==================================================================
// ATTRIBUTES
+ /// Is the box "constructed" ? (initialized)
+ bool bbmConstructed;
/// Is the box executing ?
bool bbmExecuting;
/// The name of the black-box
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 $
=========================================================================*/
/* ---------------------------------------------------------------------
info.argmin = 1;
info.argmax = 1;
info.code = cKind;
- info.syntax = "kind <ADAPTOR|DEFAULT_ADAPTOR|WIDGET_ADAPTOR|DEFAULT_WIDGET_ADAPTOR>";
+ info.syntax = "kind <ADAPTOR|DEFAULT_ADAPTOR|GUI|DEFAULT_GUI>";
info.help = "Sets the kind of the currently defined complex black box";
mCommandDict[info.keyword] = info;
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 $
=========================================================================*/
/* ---------------------------------------------------------------------
//===========================================================================
#define BBTK_ITK_DELETE() \
- void bbDelete() { \
+ int bbDelete() { \
+ int refs = itkParent::GetReferenceCount()-1; \
itkParent::UnRegister(); \
+ return refs; \
}
//===========================================================================
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 $
=========================================================================*/
/* ---------------------------------------------------------------------
{
std::cout<<"* Note : "<<u
<<" object in list has 0 ref count, "
- <<"i.e. destroyed without removing itself from the living objects list ! (this is just an implementation error not a memory leak)"<<std::endl;
+ <<"i.e. are no more accessible by bbtk but did not properly destroyed because another ref counting system is holding them !"<<std::endl;
}
else if (u>1)
{
std::cout<<"* Note : "<<u
<<" objects in list have 0 ref count, "
- <<"i.e. destroyed without removing themselves from the living objects list ! (this is just an implementation error not a memory leak)"<<std::endl;
+ <<"i.e. are no more accessible by bbtk but did not properly destroyed because another ref counting system is holding them !"<<std::endl;
}
std::cout
<< "============ EO Living bbtk::Object pointers ========="<<std::endl;
bbtkDebugMessage("object",1,"##> Object::Deleter : deleting \""
<<name<<"\" ["<<adr<<"]"<<std::endl);
#endif
- Object::RemoveFromObjectList(mPointer);
- this->Delete(p);
- bbtkDebugMessage("object",2,"<## Object::Deleter : \""<<name<<"\" ["
- <<adr<<"] deleted"<<std::endl);
+ int remaining = this->Delete(p);
+ if (remaining == 0)
+ {
+ Object::RemoveFromObjectList(mPointer);
+ bbtkDebugMessage("object",2,"<## Object::Deleter : \""<<name<<"\" ["
+ <<adr<<"] deleted"<<std::endl);
+ }
+ else
+ {
+ bbtkWarning("##### Object::Deleter \""<<name<<"\" failed !!! "
+ << remaining << " reference(s) still around..."
+ <<std::endl);
+ }
}
//=======================================================================
Program: bbtk
Module: $RCSfile: bbtkObject.h,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:13 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2009/04/30 14:31:31 $
+ Version: $Revision: 1.8 $
=========================================================================*/
/* ---------------------------------------------------------------------
Deleter() : mPointer() {}
virtual ~Deleter() {}
virtual void operator() (Object* p);
- virtual void Delete(Object* p) { delete p; }
+ virtual int Delete(Object* p) { delete p; return 0; }
WeakPointer mPointer;
};
return p;
}
-
private:
typedef std::set<boost::weak_ptr<Object> > ObjectListType;
static ObjectListType mgObjectList;
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 $
=========================================================================*/
/* ---------------------------------------------------------------------
//===========================================================================
#define BBTK_VTK_DELETE() \
- void bbDelete() { \
+ int bbDelete() { \
for (int i=0; i<vtkParent::GetNumberOfInputPorts();++i) \
vtkParent::SetInput(i,0); \
bbGetOutputOut()->SetSource(NULL); \
- /*std::cout << "VTK : bbDelete() "<<std::endl;*/ \
- /*std::cout << "Use count = "<<GetUseCount()<<std::endl;*/ \
- /*std::cout << "VTK count = "<<GetReferenceCount()<<std::endl;*/ \
- /* vtkParent::SetReferenceCount(1); GetUseCount());*/ \
- /*delete this; */ \
+ int refs = GetReferenceCount()-1; \
vtkParent::Delete(); \
+ return refs; \
}
// bbmDescriptorPointer.reset();
Program: bbtk
Module: $RCSfile: bbvtkImagePlanes.cxx,v $
Language: C++
- Date: $Date: 2009/04/17 09:24:02 $
- Version: $Revision: 1.22 $
+ Date: $Date: 2009/04/30 14:31:33 $
+ Version: $Revision: 1.23 $
=========================================================================*/
/* ---------------------------------------------------------------------
};
//================================================================
- //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.22 $");
+ //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.23 $");
//================================================================
if (bbGetOutputPlaneX())
{
bbGetOutputPlaneX()->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();
}
}