]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkBlackBoxOutputConnector.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkBlackBoxOutputConnector.cxx
index 6631657a3c3a76f374545f3061b77aa1c566cc13..e6ba06c5c9780ba86018a56923b4f6537e8f4b60 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:05 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2009/06/08 14:50:03 $
+  Version:   $Revision: 1.13 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 namespace bbtk
 {
 
+  //========================================================================
+  /// The Pimpl
+  class BlackBoxOutputConnector::Pimpl
+  {
+  public:
+    Pimpl() : mStatus(OUTOFDATE) {}
+    Pimpl(const Pimpl&) {}
+   /// 
+    BlackBoxWeakPointer mBox;
+    /// The vector of output connections
+    ConnectionVector mConnection;
+    /// The status of the output 
+    IOStatus mStatus;
+    /// The output changed signal 
+    BlackBox::OutputChangeSignalType mChangeSignal;
+
+
+  };
+  //========================================================================
+
+  //========================================================================
+  BBTK_IMPL_PIMPL(BlackBoxOutputConnector)
+  //========================================================================
+
+
   //======================================================================
   BlackBoxOutputConnector::BlackBoxOutputConnector(BlackBox::Pointer b) 
-    : mBox(b),
-      mStatus(OUTOFDATE)
   {
     bbtkDebugMessage("kernel",9,
                     "["<<b->bbGetName()
                     <<"] BlackBoxOutputConnector()"<<std::endl);
+    PimplConstruct();
+    p->mBox = b;
   }
   //======================================================================
 
@@ -58,8 +83,7 @@ namespace bbtk
   BlackBoxOutputConnector::~BlackBoxOutputConnector() 
   {
     bbtkDebugMessage("kernel",9,
-                    "[NULL"//<<mBox.lock()->bbGetName()
-                    <<"] ==> ~BlackBoxOutputConnector()"
+                    "[DEAD BOX] ==> ~BlackBoxOutputConnector()"
                     <<std::endl);
     /*
     ConnectionVector::iterator i;
@@ -68,10 +92,11 @@ namespace bbtk
         ++i)
       (*i) = Connection::WeakPointer();
     */
-    mConnection.clear();
+    p->mConnection.clear();
+    PimplDestruct();
+  
     bbtkDebugMessage("kernel",9,
-                    "[NULL"//<<mBox.lock()->bbGetName()
-                    <<"] <== ~BlackBoxOutputConnector()"
+                    "[DEAD BOX] <== ~BlackBoxOutputConnector()"
                     <<std::endl);
   }
   //======================================================================
@@ -81,10 +106,10 @@ namespace bbtk
   void BlackBoxOutputConnector::SetConnection(Connection* c)
   {
     bbtkDebugMessage("kernel",9,
-                    "["<<mBox.lock()->bbGetName()
+                    "["<<p->mBox.lock()->bbGetName()
                     <<"] BlackBoxOutputConnector::SetConnection("
                     <<c<<")"<<std::endl);
-    mConnection.push_back(c);
+    p->mConnection.push_back(c);
     //    AddChangeObserver(boost::bind(&Connection::SignalChange,c));
   }
   //======================================================================
@@ -93,13 +118,13 @@ namespace bbtk
   //======================================================================
   void BlackBoxOutputConnector::UnsetConnection(Connection* c)
   {
-    bbtkDebugMessage("kernel",9,"["<<mBox.lock()->bbGetName()
+    bbtkDebugMessage("kernel",9,"["<<p->mBox.lock()->bbGetName()
                     <<"] BlackBoxOutputConnector::UnsetConnection("
                     <<c<<")"<<std::endl);
 
     if (!c) 
       {
-       bbtkInternalError(mBox.lock()->bbGetFullName()
+       bbtkInternalError(p->mBox.lock()->bbGetFullName()
                          <<": BlackBoxOutputConnector::UnsetConnection("
                          <<c<<") : invalid connection");
 
@@ -108,28 +133,51 @@ namespace bbtk
     //Connection::WeakPointer w(c);
     ConnectionVector::iterator i;
     //  = find(mConnection.begin(),mConnection.end(),c);
-    for (i=mConnection.begin();
-        i!=mConnection.end();
+    for (i=p->mConnection.begin();
+        i!=p->mConnection.end();
         ++i)
       {
        if (*i==c) break;
       }
-    if (i==mConnection.end())
+    if (i==p->mConnection.end())
       {
-       bbtkInternalError(mBox.lock()->bbGetFullName()
+       bbtkInternalError(p->mBox.lock()->bbGetFullName()
                          <<": BlackBoxOutputConnector::UnsetConnection("
                          <<c
                          <<") : connection is absent from connections list");
       }
-    mConnection.erase(i);
+    p->mConnection.erase(i);
     //    RemoveChangeObserver(boost::bind(&Connection::SignalChange,c));
 
 
   }
   //======================================================================
+  
+  //======================================================================
+  const BlackBoxOutputConnector::ConnectionVector& 
+  BlackBoxOutputConnector::GetConnectionVector() const
+  { 
+    return p->mConnection; 
+  }
+  //======================================================================
+  
+  //======================================================================
+  /// Returns the status of the input 
+  IOStatus BlackBoxOutputConnector::GetStatus() const 
+  { 
+    return p->mStatus; 
+  }
+  //======================================================================
 
+  //======================================================================
+  /// Sets the status of the input 
+  void BlackBoxOutputConnector::SetStatus( IOStatus s ) 
+  {
+    p->mStatus = s; 
+  }
+  //======================================================================
   
-   //======================================================================
+  //======================================================================
   void BlackBoxOutputConnector::SignalChange( BlackBox::Pointer box,
                                              const std::string& output )
   {
@@ -146,7 +194,7 @@ namespace bbtk
     //    std::cout<<"BlackBoxOutputConnector::SignalChange("
     //      <<box->bbGetName()<<",'"
     //      <<output<<"')"<<std::endl;
-    mChangeSignal(box,output,s);
+    p->mChangeSignal(box,output,s);
     
     bbtkDebugMessage("change",2,
                     "["<<box->bbGetName()
@@ -156,66 +204,12 @@ namespace bbtk
                     <<std::endl);
   }
   //======================================================================
- /*
-  void BlackBoxOutputConnector::SetModifiedStatus()
-  {
-    bbtkDebugMessage("modified",2,
-                    "==> BlackBoxOutputConnector::SetModifiedStatus() ["
-                    <<this<<"]"
-                    <<std::endl);
-    ConnectionVector::iterator i;
-    for (i=mConnection.begin();i!=mConnection.end();++i) 
-      {
-       (*i)->SetModifiedStatus();
-      }
-    
-    
-   }
-  */
-  /*
-  //======================================================================
-  void BlackBoxOutputConnector::SetChangeTime(const ChangeTime& t)
-  {
-    bbtkDebugMessage("change",2,
-                    "==> BlackBoxOutputConnector::SetChangeTime("<<t<<") ["
-                    <<this<<"]"
-                    <<std::endl);
-    if (mChangeTime.Set(t))
-      {
-       mChangeSignal(this);
-      }
-    bbtkDebugMessage("change",2,
-                    "<== BlackBoxOutputConnector::SetChangeTime("<<t<<") ["
-                    <<this<<"]"
-                    <<std::endl);
-  }
-  //======================================================================
-  */
-  /*
- //======================================================================
-  void BlackBoxOutputConnector::SetChangeTimeToCurrentTime()
-  {
-    bbtkDebugMessage("change",2,
-                    "==> BlackBoxOutputConnector::SetChangeTimetoCurrentTime() ["
-                    <<this<<"]"
-                    <<std::endl);
-    mChangeTime.Set(ChangeTime::GetCurrentTime());
-    mChangeSignal(this);
-    
-    bbtkDebugMessage("change",2,
-                    "<==> BlackBoxOutputConnector::SetChangeTimetoCurrentTime() ["
-                    <<this<<"]"
-                    <<std::endl);
-  }
-  //======================================================================
-  */
-
 
   //======================================================================
   void BlackBoxOutputConnector::AddChangeObserver(OutputChangeCallbackType f)
   { 
     //    std::cout << "BlackBoxOutputConnector::AddChangeObserver" << std::endl;
-    mChangeSignal.connect(f); 
+    p->mChangeSignal.connect(f); 
   }
   //======================================================================