]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkBlackBoxOutputConnector.cxx
=== MAJOR RELEASE ====
[bbtk.git] / kernel / src / bbtkBlackBoxOutputConnector.cxx
index d2ee80e74dec872efd777472318e9f46e7dcf3ae..af6bf5f21ed88febf007ea7e523d198dcf525aa7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -37,19 +37,21 @@ namespace bbtk
 
   BlackBoxOutputConnector::~BlackBoxOutputConnector() 
   {
-    bbtkDebugMessageInc("Kernel",9,
-                       "BlackBoxOutputConnector::~BlackBoxOutputConnector()"
-                       <<std::endl);
-    std::vector<Connection*>::iterator i;
-    for (i=mConnection.begin();i!=mConnection.end();++i) 
-      {
-       delete *i;
-      }
-    bbtkDebugDecTab("Kernel",9);
+    bbtkDebugMessage("Kernel",9,
+                    "==> BlackBoxOutputConnector::~BlackBoxOutputConnector()"
+                    <<std::endl);
+    ConnectionVector::iterator i;
+    for (i=mConnection.begin();
+        i!=mConnection.end();
+        ++i)
+      (*i) = Connection::WeakPointer();
+    bbtkDebugMessage("Kernel",9,
+                    "<== BlackBoxOutputConnector::~BlackBoxOutputConnector()"
+                    <<std::endl);
   }
 
   ///
-  void BlackBoxOutputConnector::SetConnection(Connection* c)
+  void BlackBoxOutputConnector::SetConnection(Connection::Pointer c)
   {
     bbtkDebugMessage("Kernel",9,"BlackBoxOutputConnector::SetConnection("
                     <<c<<")"<<std::endl);
@@ -59,14 +61,26 @@ namespace bbtk
 
 
   ///
-  void BlackBoxOutputConnector::UnsetConnection(Connection* c)
+  void BlackBoxOutputConnector::UnsetConnection(Connection::Pointer c)
   {
     bbtkDebugMessageInc("Kernel",9,"BlackBoxOutputConnector::UnsetConnection("
                     <<c<<")"<<std::endl);
 
-    c->Check();
-    std::vector<Connection*>::iterator i
-      = find(mConnection.begin(),mConnection.end(),c);
+    if (!c) 
+      {
+       bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : invalid connection");
+
+      }
+    //    c->Check();
+    //Connection::WeakPointer w(c);
+    ConnectionVector::iterator i;
+    //      = find(mConnection.begin(),mConnection.end(),c);
+    for (i=mConnection.begin();
+        i!=mConnection.end();
+        ++i)
+      {
+       if (i->lock()==c) break;
+      }
     if (i==mConnection.end())
       {
        bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : connection is absent from connections list");
@@ -83,10 +97,10 @@ namespace bbtk
     bbtkDebugMessageInc("Process",5,
                        "BlackBoxOutputConnector::SetModifiedStatus()"
                        <<std::endl);
-    std::vector<Connection*>::iterator i;
+    ConnectionVector::iterator i;
     for (i=mConnection.begin();i!=mConnection.end();++i) 
       {
-       (*i)->SetModifiedStatus();
+       (*i).lock()->SetModifiedStatus();
       }
     
     bbtkDebugDecTab("Process",5);