]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkBlackBoxDescriptor.cxx
=== MAJOR RELEASE ====
[bbtk.git] / kernel / src / bbtkBlackBoxDescriptor.cxx
index 68ba2439d61b71fd5303191ec0b751cb1ed490a8..e0156087f0b80dcf6622b09b72a16ea4ba2bfdcf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxDescriptor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 namespace bbtk
 {
-  
+
+  typedef Package::Pointer PackagePointer;
+
+
+
   //=========================================================================
   /// Default ctor
   BlackBoxDescriptor::BlackBoxDescriptor()  
@@ -38,11 +42,12 @@ namespace bbtk
       mAuthor(""),
       mCategory(""),
       mKind(STANDARD),
-      mPackage(NULL),
-      mRefCount(0)
+      mPackage()
   {
-    bbtkDebugMessage("Kernel",9,
-                    "BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
+    bbtkDebugMessage("object",4,
+                    "==> BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
+   bbtkDebugMessage("object",4,
+                    "<== BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
   }
   //=========================================================================
 
@@ -50,9 +55,9 @@ namespace bbtk
   /// Dtor
   BlackBoxDescriptor::~BlackBoxDescriptor()
   {
-    bbtkDebugMessageInc("Kernel",9,
-                       "BlackBoxDescriptor::~BlackBoxDescriptor() ["
-                       <<mTypeName<<"]"<<std::endl);
+    bbtkDebugMessage("object",4,
+                    "==> BlackBoxDescriptor::~BlackBoxDescriptor() ["
+                    <<mTypeName<<"]"<<std::endl);
 
     // deletes all I/O descriptors
     InputDescriptorMapType::iterator i;
@@ -60,10 +65,41 @@ namespace bbtk
     OutputDescriptorMapType::iterator o;
     for (o=mOutput.begin(); o!=mOutput.end(); ++o) delete o->second;
 
-    bbtkDebugDecTab("Kernel",9);
+    bbtkDebugMessage("object",4,
+                    "<== BlackBoxDescriptor::~BlackBoxDescriptor() ["
+                    <<mTypeName<<"]"<<std::endl);
   }
   //=========================================================================
 
+  /*
+  //=======================================================================
+  /// Release
+  void BlackBoxDescriptor::Release(BlackBoxDescriptor::WeakPointer desc)
+  {
+    bbtkMessage("object",2,"==> BlackBoxDescriptor::Release('"
+               <<desc.lock()->GetTypeName()<<"')"<<std::endl);
+    long c = desc.use_count();
+    bbtkMessage("object",3," - ref count = "<<c<<std::endl);
+    // If only one ref 
+    if ((c == 1) && (desc.lock()->mPackage))
+      {
+       bbtkMessage("object",2," --> No more instance alive = releasing from package"<<std::endl);
+       
+       Package::WeakPointer pack = desc.lock()->mPackage;
+       Package::ReleaseBlackBoxDescriptor(pack,desc);
+      }
+    else 
+      {
+       bbtkMessage("object",2," --> Still some instances alive = Keeping it alive"<<std::endl);
+      }    
+    bbtkMessage("object",2,"<== BlackBoxDescriptor::Release('"
+               <<desc.lock()->GetTypeName()<<"')"<<std::endl);
+  }
+  //=========================================================================
+  */
+
+  /*
   //=========================================================================
   /// Dtor
   void BlackBoxDescriptor::UnReference()
@@ -79,7 +115,7 @@ namespace bbtk
       }
   }
   //=========================================================================
-
+  */
   //=========================================================================
   /// Check
   void BlackBoxDescriptor::Check(bool) const
@@ -244,7 +280,7 @@ namespace bbtk
   /// Returns the full name of the **TYPE** of the black box (+package name)
   std::string BlackBoxDescriptor::GetFullTypeName() const
   {
-    if (mPackage!=0) return mPackage->GetName() + "::" + mTypeName;
+    if (GetPackage()!=0) return GetPackage()->GetName() + "::" + mTypeName;
     return "::" + mTypeName;
   }
   //=========================================================================