]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkBlackBoxDescriptor.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkBlackBoxDescriptor.cxx
index 68ba2439d61b71fd5303191ec0b751cb1ed490a8..f1fb6a003a7981f7e8c99d37e6586f31b485c53f 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/05/14 10:26:29 $
+  Version:   $Revision: 1.18 $
                                                                                 
   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,21 +42,27 @@ 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);
   }
   //=========================================================================
 
+  //=========================================================================
+  /// Default ctor
+  BlackBoxDescriptor::BlackBoxDescriptor(const BlackBoxDescriptor&)  
+  {
+  }
   //=========================================================================
   /// 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 +70,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 +120,7 @@ namespace bbtk
       }
   }
   //=========================================================================
-
+  */
   //=========================================================================
   /// Check
   void BlackBoxDescriptor::Check(bool) const
@@ -244,7 +285,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;
   }
   //=========================================================================
@@ -272,7 +313,7 @@ namespace bbtk
 
 
     std::string descr = GetDescription();
-    Utilities::html_format(descr);
+    //Utilities::html_format(descr);
     std::string author = GetAuthor();
     Utilities::html_format(author);
 
@@ -352,7 +393,7 @@ namespace bbtk
       Utilities::html_format(type);
       
       std::string descr(in->second->GetDescription());
-      Utilities::html_format(descr);
+      //Utilities::html_format(descr);
       
       std::string out = 
        "<TR><TD style='vertical-align: top;' bgcolor=\"" + col
@@ -415,7 +456,7 @@ namespace bbtk
        Utilities::html_format(type);
        
        std::string descr(o->second->GetDescription());
-       Utilities::html_format(descr);
+       //Utilities::html_format(descr);
        
        std::string out = 
          "<TR><TD style='vertical-align: top;' bgcolor=\"" + col