]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Thu, 11 Dec 2008 09:50:32 +0000 (09:50 +0000)
committerguigues <guigues>
Thu, 11 Dec 2008 09:50:32 +0000 (09:50 +0000)
17 files changed:
kernel/doc/bbtkDevelopersGuide/bbtkDevelopersGuide.tex
kernel/src/bbtkAtomicBlackBox.cxx
kernel/src/bbtkAtomicBlackBox.h
kernel/src/bbtkBlackBox.cxx
kernel/src/bbtkBlackBox.h
kernel/src/bbtkBlackBoxInputConnector.cxx
kernel/src/bbtkBlackBoxInputConnector.h
kernel/src/bbtkComplexBlackBox.cxx
kernel/src/bbtkComplexBlackBox.h
kernel/src/bbtkConnection.cxx
kernel/src/bbtkConnection.h
kernel/src/bbtkKWBlackBox.cxx
kernel/src/bbtkKWBlackBox.h
kernel/src/bbtkWxBlackBox.cxx
kernel/src/bbtkWxBlackBox.h
packages/wxvtk/src/bbwxvtkViewer2D.cxx
packages/wxvtk/src/bbwxvtkViewer2D.h

index 2c97a8dfb813544659a234695021f4c55e7750f5..facad1d23bfcb1d7b30fd941964ecfffb925edd3 100644 (file)
@@ -11,7 +11,7 @@
 
 
 % ==========================================
-\tableofcontents
+%\tableofcontents
 % ==========================================
 
 % ==========================================
 \section{Introduction}
 % ==========================================
 
+% ==========================================
+\section{The library architecture}
+% ==========================================
+
+% ==========================================
+\subsection{BlackBox and related classes}
+% ==========================================
+
+% ==========================================
+\subsection{Factory and Package}
+% ==========================================
+
+% ==========================================
+\subsection{Interpreter, VirtualExec, Executer and Transcriptor}
+% ==========================================
+
+% ==========================================
+\subsection{WxGUI elements}
+% ==========================================
+
+% ==========================================
+\subsection{Utilities}
+% ==========================================
+
 % ==========================================
 \section{Pipeline processing algorithm}
 % ==========================================
@@ -48,37 +72,37 @@ of type IOStatus but which can only take the two values:
 The status of an output is stored by the class BlackBoxOutputConnector.
 
 If a box output 'O' is connected to another box input 'I' then there are some consistency constraints on their I/O statuses:
-\begin{itemize}
-\item If 'I' is UPTODATE then 'O' is necesseraly UPTODATE
-\item If 'I' is MODIFIED then 'O' is necesseraly UPTODATE
-\item If 'I' is OUTOFDATE then 'O' can be in any Status (The case 'O' is UPTODATE occurs for example when the amont box was created and executed - hence setting its outputs UPTODATE - *BEFORE* being connected to the aval box)
-\item If 'O' is UPTODATE then 'I' can be in any Status
-\item If 'O' is OUTOFDATE then 'I' is necessarly OUTOFDATE
-\end{itemize}
+
+\begin{tabular}{|l|p{10cm}|}
+\hline
+If & then \\ \hline
+'I' is UPTODATE & 'O' is necesseraly UPTODATE\\
+'I' is MODIFIED & 'O' is necesseraly UPTODATE\\
+'I' is OUTOFDATE & 'O' can be in any Status (The case 'O' is UPTODATE occurs for example when the amont box was created and executed - hence setting its outputs UPTODATE - *BEFORE* being connected to the aval box)\\ \hline
+'O' is UPTODATE & 'I' can be in any Status\\
+'O' is OUTOFDATE & 'I' is necessarly OUTOFDATE\\ \hline
+\end{tabular}
 
 The status of an input can be modified:
 \begin{itemize}
 \item By BlackBox::bbSetStatusAndPropagate which is called by:
 \begin{itemize}
-\item BlackBox::bbSetInput : it is set to MODIFIED
-\item BlackBox::bbSignalOutputModification 
-\item BlackBox::bbConnectInput which is called when a Connection is connected to the input : it is set to OUTOFDATE 
-\item Connection::OnOutputChange
+\item BlackBox::bbSetInput when a new value of an input is set.
+\item BlackBox::bbSignalOutputModification when the output which is connected to it is signaled as modified.
+\item BlackBox::bbConnectInput which is called when a Connection is connected to the input.
+\item Connection::OnOutputChange 
 \end{itemize}
-\item By BlackBox::bbComputePostProcessStatus which is called after bbProcess in AtomicBlackBox::bbBackwardUpdate : if the input status is MODIFIED then it is changed to UPTODATE.
-\item By Connection::BackwardUpdate which is responsible for updating its amont box, transfering the output value to the input and updating the input status. If, after processing the amont box, the output status is UPTODATE then the new input status is MODIFIED, else if the output status is OUTOFDATE then the new input status is OUTOFDATE.
+\item By BlackBox::bbComputePostProcessStatus which is called after bbProcess in BlackBox::bbRecursiveExecute.
+\item By Connection::RecursiveExecute which is responsible for updating its amont box, transfering the output value to the input and updating the input status.
 \end{itemize}
 
-The status of an output is modifed in:
+The status of an output can be modifed in:
 \begin{itemize}
 \item By BlackBox::bbSetStatusAndPropagate, when propagating the new input status to the outputs. 
-\item By BlackBox::bbComputePostProcessStatus, which is called after bbProcess in AtomicBlackBox::bbBackwardUpdate. The new output status is :
-\begin{itemize}
-\item UPTODATE if all the box inputs are UPTODATE and the BoxProcessMode is *NOT* 'Always'
-\item OUTOFDATE in other cases
-\end{itemize}
+\item By BlackBox::bbComputePostProcessStatus, which is called after bbProcess in BlackBox::bbRecursiveExecute.
 \end{itemize}
 
+
 % ==========================================
 \subsection{Pipeline execution}
 % ==========================================
@@ -86,33 +110,43 @@ The main execution method of a black box is bbExecute.
 bbExecute checks werther the box is not already executing (bbGetExecuting()) 
 to prevent reentrance and 
 checks werther the execution is not frozen (bbGlobalGetFreezeExecution()).
-If it is not the case then it calls bbBackwardUpdate which is 
-the main recursive pipeline processing method of a box, giving it a 
-NULL Connection::Pointer.
-
-bbBackwardUpdate is defined in AtomicBlackBox:
-
+If it is not the case then it calls bbRecursiveExecute which is 
+the main recursive pipeline processing method of a box.
+
+bbRecursiveExecute does:
+\begin{enumerate}
+\item Update the inputs of the box calling bbUpdateInputs
+\item If at least one input is MODIFIED or OUTOFDATE or the 
+BoxProcessMode is 'Always' then it:
+\begin{enumerate}
+\item Calls the virtual method bbProcess 
+which is responsible for the actual box processing. 
+bbProcess is overloaded in AtomicBlackBox to call a user defined method 
+and in widget box descendents (WxBlackBox, KWBlackBox) to handle 
+the widget creation.
+\item Compute the post-process statuses of inputs and outputs calling 
+bbComputePostProcessStatus.
+\end{enumerate}
+\end{enumerate}
 \bigskip\hrule\begin{verbatim}
-void AtomicBlackBox::bbBackwardUpdate ( Connection::Pointer caller )
+void BlackBox::bbRecursiveExecute ( Connection::Pointer caller )
 {
   // Updates the box inputs. Returns the max input IOStatus after update
   IOStatus s = bbUpdateInputs();
   // If at least one input is modified or BoxProcessMode=='Always'
   if ( (s != UPTODATE) || bbBoxProcessModeIsAlways() )
     {
-      // User process
+      // User process (virtual)
       bbProcess();
-      // Displays the window (overloaded in widget Blackboxes, WxBlackBox, KWBlackBox, etc.)
-      bbShowWindow(caller);
       // Compute the final status of inputs and outputs
       bbComputePostProcessStatus();
     }
 }
 \end{verbatim}\hrule\bigskip
 
-bbUpdateInputs iterates over the InputConnector of the box and 
-calls BackwardUpdate on each one. It returns the max of the final 
-status of the input connectors:
+bbUpdateInputs iterates the InputConnectorMap of the box and 
+calls RecursiveExecute on each BlackBoxInputConnector. 
+It returns the max of the final status of the input connectors:
 \bigskip\hrule\begin{verbatim}
 IOStatus BlackBox::bbUpdateInputs()
 {
@@ -121,33 +155,100 @@ IOStatus BlackBox::bbUpdateInputs()
   for ( i = bbGetInputConnectorMap().begin(); 
         i!= bbGetInputConnectorMap().end(); ++i) 
     {
-      i->second->BackwardUpdate();
+      i->second->RecursiveExecute();
       IOStatus t = i->second->GetStatus();
       if (t > s) s = t;
     }
   return s;    
+}
+\end{verbatim}\hrule\bigskip
+
+bbComputPostProcessStatus computes the new status of inputs and outputs 
+after box processing.
+
+The input status update rules are simple:
  
+\begin{tabular}{|lll|}
+\hline
+UPTODATE & remains & UPTODATE\\ \hline
+MODIFIED & becomes & UPTODATE\\ \hline
+OUTOFDATE & remains & OUTOFDATE\\ \hline
+\end{tabular}
+
+The new output status is:
+
+\begin{tabular}{|ll|}
+\hline
+OUTOFDATE & if any input is OUTOFDATE\\ 
+& or bbBoxProcessModeIsAlways() is true\\ \hline
+UPTODATE & in any other case\\ \hline
+\end{tabular}
+
+\bigskip\hrule\begin{verbatim}
+void BlackBox::bbComputePostProcessStatus()
+{
+  // A priori, the new output status is UPTODATE 
+  // except if the BoxProcessMode is always
+  IOStatus new_output_status = UPTODATE;
+  if (bbBoxProcessModeIsAlways()) new_output_status = OUTOFDATE;
+
+  // Update the input statuses
+  InputConnectorMapType::iterator i;
+  for ( i = bbGetInputConnectorMap().begin(); 
+        i!= bbGetInputConnectorMap().end(); ++i) 
+  {
+    IOStatus t = i->second->GetStatus();
+    // If any input is OUTOFDATE then the outputs also are
+    if (t == OUTOFDATE) new_output_status = OUTOFDATE;
+    // A previously MODIFIED status turns to UPTODATE
+    if (t==MODIFIED) i->second->SetStatus(UPTODATE);
+  }
+
+  // Update the output statuses
+  OutputConnectorMapType::iterator o;
+  for ( o = bbGetOutputConnectorMap().begin(); 
+        o!= bbGetOutputConnectorMap().end(); ++o) 
+  {
+    o->second->SetStatus(new_output_status);
+  }
 }
 \end{verbatim}\hrule\bigskip
 
+
+BlackBox::bbUpdateInputs may calls BlackBoxInputConnector::RecursiveExecute
+which is responsible for recursive update of the input value.
+If it is connected and its status is OUTOFDATE then it calls 
+RecursiveExecute on the Connection which is plugged into:
 \bigskip\hrule\begin{verbatim}
-void BlackBoxInputConnector::BackwardUpdate()
+void BlackBoxInputConnector::RecursiveExecute()
 {
   // If connected and OUTOFDATE : recursive update
   // Post-update status is updated by the connection 
   // (either MODIFIED or OUTOFDATE)
    if ( mConnection && (mStatus == OUTOFDATE) ) 
     {
-      mConnection->BackwardUpdate();
+      mConnection->RecursiveExecute();
     }
 }
 \end{verbatim}\hrule\bigskip
 
+Connection::RecursiveExecute does:
+\begin{enumerate}
+\item Call bbRecursiveExecute on the initial box of the connection 
+\item Transfer the data from the initial box output to the final box input, adpating it if needed (add crossref).
+\item Update the final box input status. It sets it to:
+
+\begin{tabular}{lll}
+MODIFIED  & If the initial box output is & UPTODATE \\
+OUTOFDATE & If the initial box output is & OUTOFDATE 
+\end{tabular}
+\end{enumerate}
+
 \bigskip\hrule\begin{verbatim}
-void Connection::BackwardUpdate()
+void Connection::RecursiveExecute()
 {
-  // Calls bbBackwardUpdate on the initial box
-  mFrom->bbBackwardUpdate(GetThisPointer<Connection>());
+  // Calls bbRecursiveExecute on the initial box
+  mFrom->bbRecursiveExecute(GetThisPointer<Connection>());
   // Transfers the data from the initial box output to the 
   // final box input adapting it if necessary
   TransferData();
@@ -159,6 +260,13 @@ void Connection::BackwardUpdate()
 }
 \end{verbatim}\hrule\bigskip
 
+% ==========================================
+\subsection{The main processing method (bbProcess) overloads}
+% ==========================================
+
+BlackBox::bbProcess 
+
+
 
 
 % ==========================================
index d42185163bdf9dd230273a65edeadd0bb414e272..bf354ab3e909da3bdeb9d43e37a8a52e2b7029d8 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkAtomicBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 12:53:35 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2008/12/11 09:50:34 $
+  Version:   $Revision: 1.12 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -84,61 +84,7 @@ namespace bbtk
   
 
 
-  //=========================================================================
-  /// Main processing method of the box.
-  void AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
-  {
-    bbtkDebugMessageInc("process",3,
-                       "=> AtomicBlackBox::bbBackwardUpdate("
-                       <<(caller?caller->GetFullName():"0")<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-
-    // If already executing : return
-    if (bbGetExecuting()) 
-      {
-       bbtkDebugMessage("process",3,
-                        " -> already executing : returning"<<std::endl);
-       return; 
-      }
-
-    bbSetExecuting(true);
-    bool wasExecuting = bbGlobalGetSomeBoxExecuting();
-    bbGlobalSetSomeBoxExecuting(true);
-
-    // Updates its inputs
-    IOStatus s = bbUpdateInputs();
-    
-    if ( (s != UPTODATE) ||
-        bbBoxProcessModeIsAlways() )
-      {
-       // User process
-       bbProcess();
-       
-       // Displays the window (WxBlackbox)
-       bbShowWindow(caller);
-       
-       // Update the I/O statuses
-       bbComputePostProcessStatus();
-      }
-    else 
-      {
-        bbtkDebugMessage("process",5," -> Up-to-date : nothing to do"
-                        <<std::endl);
-      }
-
-    bbtkDebugMessage("process",3,
-            "<= AtomicBlackBox::bbBackwardUpdate() ["
-            <<bbGetFullName()<<"]"<<std::endl);
-
-    bbSetExecuting(false);
-    bbGlobalSetSomeBoxExecuting(wasExecuting);
-
-    return; // bbGetStatus();
-
-  }
-  //=========================================================================
   
-    
   //=========================================================================
   Data AtomicBlackBox::bbGetOutput( const std::string &name )
   {
index 9a00b95c555e4e2e6eab1b4662712eb961d22b52..3be67510c8afd8f5a0b24e96c4cae4c913b44a45 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkAtomicBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 12:53:39 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2008/12/11 09:50:34 $
+  Version:   $Revision: 1.8 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -55,7 +55,7 @@
 
 /**
  *  \file 
- *  \brief class bbtk::AtomicBlackBox : ancestor of all user defined (concrete) black boxes which are atomic (vs. complex boxes which are made up of other (atomic or complex) boxes).
+ *  \brief class bbtk::AtomicBlackBox : ancestor of all user defined (concrete) black boxes which are atomic (vs. ComplexBlackBox objects which are made up of other (atomic or complex) boxes).
  */
 
 /**
@@ -83,6 +83,8 @@ namespace bbtk
     {
       return bbmDescriptorPointer;
     }
+    //==================================================================
+
     //==================================================================
     /// Gets the output Data of a given label
     Data bbGetOutput( const std::string &label );
@@ -113,33 +115,13 @@ namespace bbtk
     /// Constructor from an existing box (copy) with a new instance name 
     AtomicBlackBox(AtomicBlackBox& from, const std::string &name, 
                 bool alloc = true);
-    //==================================================================
-    //==================================================================
     ///  Destructor
     virtual ~AtomicBlackBox();
-    //==================================================================
-
-    //==================================================================
-  protected:
+    /// 
     virtual void bbLockDescriptor() = 0;
-    //  private:
-    //    virtual void bbReleaseDescriptor();
-    //==================================================================
-
-  public:
-    //==================================================================   
-    /// Recursive pipeline processing in backward direction 
-    /// (recursion is in backward direction however execution always goes forward).
-    /// - updates its inputs by calling bbUpdateInputs (which recursively calls bbBackwardUpdate on amont boxes if needed)
-    /// - if the return value of bbUpdateInputs is not UPTODATE 
-    ///    - calls bbProcess
-    ///    - calls bbComputePostProcessStatus
-    virtual void bbBackwardUpdate(Connection::Pointer caller);
     //==================================================================
 
     //==================================================================
-  protected:
-    //==================================================================
     /// Calls the user defined processing method.
     /// Overloaded in WxBlackBox to handle widget creation and show
     virtual void bbProcess() { this->bbUserProcess(); }
@@ -147,8 +129,8 @@ namespace bbtk
 
     //==================================================================
     /// User callback which computes the outputs as a function of the inputs. 
-    /// It is assumed to be deterministic and thus is only called is the inputs have changed 
-    /// (i.e. if the black box is marked as modified)
+    /// It is assumed to be deterministic and thus is only called 
+    /// if the inputs have changed 
     virtual void bbUserProcess() 
     {
       bbtkWarning("AtomicBlackBox::bbUserProcess() not overloaded for box '"
@@ -183,8 +165,7 @@ namespace bbtk
 
   };
   // Class AtomicBlackBox
-  //===========================================================================
-
+  //====================================================================
 
 
 }
index 2e5716e3f9ba87e897ae7f3a69d7b10568af3743..914bf145ea291edd1b8f1518cbfdec773018da0b 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/10 09:33:18 $
-  Version:   $Revision: 1.36 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.37 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -153,42 +153,6 @@ namespace bbtk
   //=========================================================================
 
 
-  //=========================================================================
-  /// Main processing method of the box.
-  void BlackBox::bbExecute(bool force)
-  {
-    bbtkDebugMessageInc("process",2,
-                       "=> BlackBox::bbExecute("<<(int)force<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-    // If already executing : return
-    if (bbGetExecuting()) 
-      {
-       bbtkDebugMessage("process",2,
-                        " -> already executing : bailing out"<<std::endl);
-       return;
-      }
-
-    // If execution frozen : return
-    if (bbGlobalGetFreezeExecution()) 
-      {
-       bbtkDebugMessage("process",2,
-                        " -> FreezeExecution global flag is 'true' : abort execution"<<std::endl);
-      }
-
-    BBTK_BUSY_CURSOR;
-
-    // If force is true then update is triggered even if the box is UPTODATE
-    //    if (force) bbSetModifiedStatus();
-
-    // Calls the main recursive update method 
-    bbBackwardUpdate(Connection::Pointer());
-
-    bbtkDebugMessageDec("process",2,
-                       "<= BlackBox::bbExecute() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-  }
-  //=========================================================================
 
   //=========================================================================
   std::string BlackBox::bbGetFullName() const
@@ -723,9 +687,128 @@ namespace bbtk
   }  
   //=========================================================================   
 
+
+
+
+
+
+
+  //=========================================================================
+  /// Main processing method of the box.
+  void BlackBox::bbExecute(bool force)
+  {
+    bbtkDebugMessageInc("process",2,
+                       "=> BlackBox::bbExecute("<<(int)force<<") ["
+                       <<bbGetFullName()<<"]"<<std::endl);
+    // If already executing : return
+    /*
+    if (bbGetExecuting()) 
+      {
+       bbtkDebugMessage("process",2,
+                        " -> already executing : abort"<<std::endl);
+       return;
+      }
+    */
+
+    // If execution frozen : return
+    if (bbGlobalGetFreezeExecution()) 
+      {
+       bbtkDebugMessage("process",2,
+                        " -> FreezeExecution global flag is 'true' : abort execution"<<std::endl);
+      }
+
+    BBTK_BUSY_CURSOR;
+
+    // If force is true then update is triggered even if the box is UPTODATE
+    //    if (force) bbSetModifiedStatus();
+
+    // Calls the main recursive execution method 
+    bbRecursiveExecute(Connection::Pointer());
+
+    bbtkDebugMessageDec("process",2,
+                       "<= BlackBox::bbExecute() ["
+                       <<bbGetFullName()<<"]"<<std::endl);
+  }
+  //=========================================================================
+
+
+  //=========================================================================
+  /// Main recursive processing method of the box.
+  void BlackBox::bbRecursiveExecute( Connection::Pointer caller )
+  {
+    bbtkDebugMessageInc("process",3,
+                       "=> BlackBox::bbRecursiveExecute("
+                       <<(caller?caller->GetFullName():"0")<<") ["
+                       <<bbGetFullName()<<"]"<<std::endl);
+
+    // If already executing : return
+    if (bbGetExecuting()) 
+      {
+       bbtkDebugMessage("process",3,
+                        " -> already executing : abort"<<std::endl);
+       return; 
+      }
+
+    bbSetExecuting(true);
+    bool wasExecuting = bbGlobalGetSomeBoxExecuting();
+    bbGlobalSetSomeBoxExecuting(true);
+
+    // Updates its inputs
+    IOStatus s = bbUpdateInputs();
+    
+    if ( (s != UPTODATE) ||
+        bbBoxProcessModeIsAlways() )
+      {
+       // Displays the window (WxBlackbox)
+       //      bbShowWindow(caller);
+
+       // Actual processing (virtual)
+       this->bbProcess();
+       
+       
+       // Update the I/O statuses
+       bbComputePostProcessStatus();
+      }
+    else 
+      {
+       // Test output status...
+       OutputConnectorMapType::iterator o;
+       for ( o = bbGetOutputConnectorMap().begin(); 
+             o!= bbGetOutputConnectorMap().end(); ++o) 
+         {
+           if (o->second->GetStatus() != UPTODATE)
+             {
+               bbtkWarning("BlackBox::bbRecursiveExecute ["
+                           <<bbGetFullName()
+                           <<"] : all inputs are Up-to-date but output '"
+                           <<o->first<<"' is Out-of-date ???");
+             }
+         }
+       
+        bbtkDebugMessage("process",3," -> Up-to-date : nothing to do"
+                        <<std::endl);
+      }
+
+    bbtkDebugMessage("process",3,
+            "<= BlackBox::bbRecursiveExecute() ["
+            <<bbGetFullName()<<"]"<<std::endl);
+
+    bbSetExecuting(false);
+    bbGlobalSetSomeBoxExecuting(wasExecuting);
+
+    return; 
+
+  }
+  //=========================================================================
+  
+   
+
+
+
   //=========================================================================
   /// Updates the BlackBox inputs
-  /// Calls BackwardUpdate on all BlackBoxInputConnector
+  /// Calls RecursiveExecute on all BlackBoxInputConnector
   /// \returns The maximum of final IOStatus after each input update
   IOStatus BlackBox::bbUpdateInputs()
   {
@@ -751,7 +834,7 @@ namespace bbtk
                            <<" status before update = '"
                            <<GetIOStatusString(i->second->GetStatus())
                            <<"'"<<std::endl);
-       i->second->BackwardUpdate();
+       i->second->RecursiveExecute();
        IOStatus t = i->second->GetStatus();
        if (t > s) s = t;
        bbtkDebugMessageDec("change",2,
index 53e286dfb4dce69f924e733c48e37e019cfc208c..a8299e4ea918d5b232b9ec766da5b2d1574d954e 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/10 09:33:18 $
-  Version:   $Revision: 1.20 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.21 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -64,8 +64,6 @@ namespace bbtk
   class BlackBoxOutputConnector;
  
 
-#define BBTK_MAKE_OUTPUT_OBSERVER(OBJECT,METHOD) \
-    boost::bind( METHOD, OBJECT, _1, _2, _3)
 
   class BBTK_EXPORT BlackBox : public Object
   {
@@ -119,61 +117,8 @@ namespace bbtk
     virtual void bbExecute(bool force = false);
 
 
-    /// The type of callback function when an output changes
-    //   typedef BlackBoxOutputConnector::ChangeCallbackType OutputChangeCallbackType;
-
-    /// Adds the function f to the list of functions to call when 
-    /// the output changes.
-    /// f is of type ChangeCallbackType which is basically:
-    /// void (*ChangeCallbackType)(bbtk::BlackBox::Pointer, 
-    ///                            const std::string&,
-    ///                            bbtk::IOStatus)
-    /// To pass a member function 'f' of an instance 'c' of a class 'C' 
-    /// as callback you have to 'bind' it, i.e. call:
-    /// bbAddOutputObserver ( "Out", boost::bind( &C::f , c, _1, _2, _3 ) );
-    /// The convenience macro BBTK_BIND_OUTPUT_OBSERVER ( c, C::f ) does it for you 
-    void bbAddOutputObserver(const std::string& output_name, 
-                            OutputChangeCallbackType f); 
-
-    /// Removes the function f from the list of functions to call when 
-    /// the output changes (TO WRITE)
-    void bbRemoveOutputObserver(const std::string& output_name, 
-                               OutputChangeCallbackType f); 
-    
-
-    /// Signals that the BlackBox outputs have been modified 
-    /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !).
-    /// This method should be used by widgets in response 
-    /// to user interaction when **ALL** outputs have been modified
-    /// (after the outputs has been updated !).
-    /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
-    /// ** USER INTENDED **
-    virtual void bbSignalOutputModification(bool reaction = true);
-    /// Signals that the BlackBox output "output_name" has been modified 
-    /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !). 
-    /// This method should be used by widgets in response to user interaction 
-    /// only when **ONE** output has been modified
-    /// (after the output has been updated !)
-    /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
-    /// ** USER INTENDED **
-    virtual void bbSignalOutputModification( const std::string& output_name,
-                                            bool reaction = true);
-    /// Signals that the BlackBox vector of outputs "output_name" 
-    /// have been modified.
-    /// Should be used when more than ONE output is modified but not ALL 
-    /// (optimization issue).
-    /// (without marking the box as MODIFIED because its output state is ok). 
-    /// This method should be used by widgets in response to user interaction 
-    /// When more than one output has been changed but not all
-    /// (after the outputs have been updated of course!)
-    /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
-    /// ** USER INTENDED **
-    virtual void bbSignalOutputModification( const std::vector<std::string>& 
-                                            output_name,
-                                            bool reaction = true);
-
-    /// Gets the status of the box
-    //    virtual const IOStatus& bbGetStatus() const { return bbmStatus; }
+  
 
 
     /// Returns true iff the BlackBox has an input of name label
@@ -238,16 +183,61 @@ namespace bbtk
     /// Prints the Help on the BlackBox type 
     virtual void bbGetHelp(bool full=true) const;
 
+    //==================================================================
+    /// Adds the function f to the list of functions to call when 
+    /// the output changes.
+    /// f is of type ChangeCallbackType which is basically:
+    /// void (*ChangeCallbackType)(bbtk::BlackBox::Pointer, 
+    ///                            const std::string&,
+    ///                            bbtk::IOStatus)
+    /// To pass a member function 'f' of an instance 'c' of a class 'C' 
+    /// as callback you have to 'bind' it, i.e. call:
+    /// bbAddOutputObserver ( "Out", boost::bind( &C::f , c, _1, _2, _3 ) );
+    /// The convenience macro BBTK_BIND_OUTPUT_OBSERVER ( c, C::f ) does it for you 
+    void bbAddOutputObserver(const std::string& output_name, 
+                            OutputChangeCallbackType f); 
+
+    /// Removes the function f from the list of functions to call when 
+    /// the output changes (TO WRITE)
+    void bbRemoveOutputObserver(const std::string& output_name, 
+                               OutputChangeCallbackType f); 
+   //==================================================================
+    
+
+    //==================================================================
+    /// Signals that the BlackBox outputs have been modified 
+    /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !).
+    /// This method should be used by widgets in response 
+    /// to user interaction when **ALL** outputs have been modified
+    /// (after the outputs has been updated !).
+    /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+    /// ** USER INTENDED **
+    virtual void bbSignalOutputModification(bool reaction = true);
+    /// Signals that the BlackBox output "output_name" has been modified 
+    /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !). 
+    /// This method should be used by widgets in response to user interaction 
+    /// only when **ONE** output has been modified
+    /// (after the output has been updated !)
+    /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+    /// ** USER INTENDED **
+    virtual void bbSignalOutputModification( const std::string& output_name,
+                                            bool reaction = true);
+    /// Signals that the BlackBox vector of outputs "output_name" 
+    /// have been modified.
+    /// Should be used when more than ONE output is modified but not ALL 
+    /// (optimization issue).
+    /// (without marking the box as MODIFIED because its output state is ok). 
+    /// This method should be used by widgets in response to user interaction 
+    /// When more than one output has been changed but not all
+    /// (after the outputs have been updated of course!)
+    /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+    /// ** USER INTENDED **
+    virtual void bbSignalOutputModification( const std::vector<std::string>& 
+                                            output_name,
+                                            bool reaction = true);
+   //==================================================================
+
 
-    // Returns true iff the box is up-to-date 
-    // (ChangeTime of inputs are all lower strictly to ChangeTime of outputs -
-    //  i.e. max(inputs)<=min(outputs) )
-    //   bool bbIsUpToDate() { return mMaxInputChangeTime < mMinOutputChangeTime; }
-    // Returns true iff the box is out-of-date 
-    // (At least one ChangeTime of an input is greater than one ChangeTime 
-    //  of an output - i.e. max(inputs)>min(outputs))
-    // == !IsUpToDate()
-    //    bool bbIsOutOfDate() { return mMaxInputChangeTime >= mMinOutputChangeTime; }
 
    //==================================================================
     // Common inputs / outputs to all boxes
@@ -371,29 +361,33 @@ namespace bbtk
   protected: 
     /// @name Pipeline processing methods
     ///  Methods which participate to pipeline processing.
-    ///  Some are pure virtual and prepare particular update mechanism which are implemented by descendents 
-    /// The main method is bbBackwardUpdate which is called by bbExecute and implemented in UserBlackBox and ComplexBlackBox.
-    /// 
     //@{
 
     
     //==================================================================   
-    /// Recursive pipeline processing in backward direction 
-    /// (recursion is in backward direction however execution always 
-    /// goes forward).
-    /// Pure virtual; defined in AtomicBlackBox and ComplexBlackBox
+    /// Recursive execution method
     /// 
     /// \param caller : The connection which invoked the method; null if called by bbExecute
-    virtual void bbBackwardUpdate(Connection::Pointer caller) = 0;
+    virtual void bbRecursiveExecute(Connection::Pointer caller);
     //==================================================================
     
     //==================================================================
     /// Updates the BlackBox inputs
-    /// Calls BackwardUpdate on all BlackBoxInputConnector
+    /// Calls RecursiveExecute on all BlackBoxInputConnector
     /// \returns The maximum of final IOStatus after each input update
     IOStatus bbUpdateInputs();
     //==================================================================
 
+   //==================================================================
+    /// Actual processing method (vitual)
+    /// Overloaded in AtomicBlacBox and descendants 
+    virtual void bbProcess() 
+    {
+      bbtkError("BlackBox::bbProcess called : how can this happen ?");
+//      this->bbUserProcess(); 
+    }
+    //==================================================================
+
     //==================================================================
     /// Computes the final IOStatus of inputs and outputs after processing
     void bbComputePostProcessStatus();
@@ -408,11 +402,10 @@ namespace bbtk
     /// Shows the window associated to the box 
     /// (called after bbProcess during bbExecute)
     /// Does nothing here but overloaded in WxBlackBox and WxContainerBlackBox
-    virtual void bbShowWindow(Connection::Pointer caller) { }
-
-    virtual void bbHideWindow() {}
-    virtual void bbCloseWindow() { }
-   //==================================================================
+    //    virtual void bbShowWindow(Connection::Pointer caller) { }
+    //    virtual void bbHideWindow() {}
+    //    virtual void bbCloseWindow() { }
+    //==================================================================
 
     //@}
   public: 
@@ -481,8 +474,6 @@ namespace bbtk
  
     //==================================================================
     // ATTRIBUTES
-    /// The status of the box
-    //    IOStatus bbmStatus;
     /// Is the box executing ?
     bool bbmExecuting;
     /// The name of the black-box
@@ -507,37 +498,15 @@ namespace bbtk
     InputConnectorMapType mInputConnectorMap;
     //==================================================================
 
-    /// The maximum ChangeTime of the inputs
-    //    ChangeTime mMaxInputChangeTime;
-    /// The minimum ChangeTime of the outputs
-    //    ChangeTime mMinOutputChangeTime;
-
-
-  protected:
-    //=========================================================================
-    ///  Sets the ChangeTime of input 
-    /*
-    void bbSetInputChangeTime(BlackBoxInputConnector* c, 
-                             const ChangeTime& t);
-    ///  Sets the ChangeTime of output 
-    void bbSetOutputChangeTime(BlackBoxOutputConnector* c, 
-                              const ChangeTime& t);
-    */
-    //   void bbUpdateMaxInputChangeTime(const ChangeTime& t);
-    //    void bbUpdateMinOutputChangeTime(const ChangeTime& t);
-
-    ///  Set the change time of the input 
-    //    void bbSetInputChangeTime(const std::string& n, ChangeTime);
-    ///  Set the change time of the output 
-    //    void bbSetOutputChangeTime(const std::string& n, ChangeTime);
-
-
 
  };
   // Class BlackBox
 
 
 
+  /// Convenient macro to create output observer callbacks (freehand functions) from object and method pointer (see samples/SampleOutputObserver)
+#define BBTK_MAKE_OUTPUT_OBSERVER(OBJECT,METHOD) \
+    boost::bind( METHOD, OBJECT, _1, _2, _3)
 
 
 
index dcfcb332a80120f4da3b14c2c1d1b77133370da5..0acb2460b36cac9750bc9f288940753d5cd0fccb 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxInputConnector.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/09 11:48:31 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.9 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -73,38 +73,23 @@ namespace bbtk
   //========================================================================
   
   //========================================================================
-  void BlackBoxInputConnector::BackwardUpdate()
+  void BlackBoxInputConnector::RecursiveExecute()
   {
-
-    // If UPTODATE or MODIFIED : nothing to do
-    //  if (mStatus != OUTOFDATE) return;
-
     // If connected and OUTOFDATE : recursive update
     // Post-update status is updated by the connection 
     // (either MODIFIED or OUTOFDATE)
     if ( mConnection && (mStatus == OUTOFDATE) )
       {
-       bbtkDebugMessage("process",9,
-                        "==> BlackBoxInputConnector::BackwardUpdate() : "
-                        <<"calling connection BackwardUpdate"
-                        <<std::endl);
-       mConnection->BackwardUpdate();
+       mConnection->RecursiveExecute();
       }
     else
       {
-       bbtkDebugMessage("process",9,
-                        "==> BlackBoxInputConnector::BackwardUpdate() : "
-                        <<"input Up-to-date or Modified : nothing to do"
+       bbtkDebugMessage("process",5,
+                        "--> BlackBoxInputConnector::RecursiveExecute() : "
+                        <<"No connection or input not Out-of-date : nothing to do"
                         <<std::endl);
 
       }
-    // If not connected : it was set to OUTOFDATE on creation
-    // Becomes MODIFIED
-    // LGTODO : Initialize to MODIFIED and set to OUTOFDATE on connection ?
-    //   else 
-    //      {
-    // mStatus = MODIFIED;
-    //    }
   }
   //========================================================================
 
index 4a886b6b455dcca8bdd379a8291b6b23e40dc031..ff25f5138fd558179fe223ad42193f67bf70f71e 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxInputConnector.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 13:05:59 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.7 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -64,14 +64,8 @@ namespace bbtk
     /// The parameter is USELESS today but would be useful if we allow multiple connections on inputs
     void UnsetConnection(Connection* c);
   
-    //    IOStatus 
-    void BackwardUpdate();
-
-    /// Returns the ChangeTime of the output (const)
-    // const ChangeTime& GetChangeTime() const { return mChangeTime; }
-    /// Returns the ChangeTime of the output 
-    // ChangeTime& GetChangeTime() { return mChangeTime; }
-    //   bool SetChangeTime(const ChangeTime& t) { return mChangeTime.Set(t); }
+    // Recursive execution
+    void RecursiveExecute();
 
     /// Returns the connection plugged into this input (const)
     Connection* GetConnection() const { return mConnection; }
@@ -96,19 +90,6 @@ namespace bbtk
     /// The status of the input (UPTODATE | MODIFIED | OUTOFDATE)
     IOStatus mStatus;
  
-   // The change time
-    //   ChangeTime mChangeTime;
-
-    /*
-    /// Returns the TimeStamp
-    const TimeStamp& GetTimeStamp() const { return mTimeStamp;}
-    TimeStamp& GetTimeStamp() { return mTimeStamp;}
-    /// Set the connector to MODIFIED status and increments the time stamp
-    void SetModified() 
-    { mStatus = MODIFIED; mTimeStamp.Modified(); }
-    /// The TimeStamp
-    TimeStamp mTimeStamp;
-    */
   };
   
 }
index de9bb69e41cb1e154bb38c60899a1677c2a895fd..c8fa3df167b8a4b16fcde8833ea096eb54f88d0c 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkComplexBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 12:54:09 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.23 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -279,100 +279,17 @@ namespace bbtk
   }
   //==================================================================
 
-  /*
-  //==================================================================
-  void ComplexBlackBox::bbSetModifiedStatus(BlackBoxInputConnector* c)
-  {
-    bbtkDebugMessage("modified",1,
-                       "==> ComplexBlackBox::bbSetModifiedStatus("
-                    <<c<<") ["<<bbGetFullName()<<"]"<<std::endl);
-
-    c->GetBlackBox()->bbSetModifiedStatus(c);
-
-  }
-  //==================================================================
-*/
-
   //==================================================================
   void ComplexBlackBox::bbAddToExecutionList( const std::string& name )
   {
-        bbtkDebugMessageInc("Kernel",9,
+    bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::bbAddToExecutionList(\""
                        <<name<<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);
-
-       mExecutionList.push_back( name );
-
-     bbtkDebugDecTab("Kernel",9);   
-
-  }
-  //==================================================================
-
-  //==================================================================
-  void ComplexBlackBox::bbBackwardUpdate(Connection::Pointer caller)
-  {
-    bbtkDebugMessageInc("process",3,
-                       "==> ComplexBlackBox::bbBackwardUpdate("
-                       <<(caller?caller->GetFullName():"0")<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-    //    bbtkInternalError("ComplexBlackBox::bbBackwardUpdate should never be called !");
     
-    if (caller==0)
-      {
-       bbtkInternalError("ComplexBlackBox::bbBackwardUpdate called with caller=0");
-      }
-
-    /*
-    std::cout << "CBB BUP : "<<caller->GetBlackBoxFrom()->bbGetFullName()
-             <<"."<<caller->GetBlackBoxFromOutput()<<"----"
-             <<caller->GetOriginalBlackBoxFrom()->bbGetFullName()
-             <<"."<<caller->GetOriginalBlackBoxFromOutput()<<std::endl;
-    */
-      
-
-
-    //    IOStatus s = UPTODATE;
-    const BlackBoxDescriptor::OutputDescriptorMapType& omap 
-      = bbGetDescriptor()->GetOutputDescriptorMap(); 
-    BlackBoxDescriptor::OutputDescriptorMapType::const_iterator i 
-      = omap.find(caller->GetBlackBoxFromOutput());
-    if (i!=omap.end())
-      {        
-       // Cast the BBOutputDescriptor into a ComplexBBOutputDescriptor
-       ComplexBlackBoxOutputDescriptor* d = 
-         (ComplexBlackBoxOutputDescriptor*)i->second;
-       // Get the internal box 
-       BlackBox::Pointer b = bbUnsafeGetBlackBox ( d->GetTarget() );
-       // Calls BackwardUpdate on it
-       bbtkDebugMessageInc("process",4,"Internal box connected to output : "<<d->GetTarget()<<std::endl);
-       // Because internal box can also be a complex box we have to 
-       // temporarily change the connection BlackBoxFromOutput to the 
-       // mapped one
-       
-       //      std::string oldout = caller->GetBlackBoxFromOutput();
-       //      std::cout << "oldout = "<<oldout<<std::endl;
-       //      std::cout << "tmpout = "<<d->GetOutput()<<std::endl;
-       //      caller->SetBlackBoxFromOutput(d->GetOutput());
-       //
-       //Connection newcaller(*caller);
-       //newcaller.SetBlackBoxFromOutput(d->GetOutput());
-       //IOStatus s1 = b->bbBackwardUpdate(&newcaller);
-       //IOStatus s1 =
-       b->bbBackwardUpdate(caller);
-       //newcaller.Clear();
-       // restore old output
-       //      caller->SetBlackBoxFromOutput(oldout);
-
-       // ??? STATUS OF CBBs ???
-       // ??? Here it is only the final status of the boxes connected to the output 
-       //      if (s1==MODIFIED) s=MODIFIED;
-      }
-    else 
-      {
-       bbtkError("Connection '"<<caller->GetFullName()<<"' does not point to a valid output of the complex box !");
-      }
-
-    return; // s;
+    mExecutionList.push_back( name );
+    
+    bbtkDebugDecTab("Kernel",9);   
     
   }
   //==================================================================
index cf4000fbd5e0b4c6bac2bce1e51c9d22a48001fa..7236a60a32b857cc6475eb87c94d4ab86fd8eb98 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkComplexBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 12:54:13 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.7 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -152,12 +152,6 @@ namespace bbtk
     /// Constructor from an existing box (copy) with a new name 
     ComplexBlackBox(ComplexBlackBox& from, const std::string &name);
     
-  public:
-    //IOStatus 
-    void bbBackwardUpdate(Connection::Pointer caller);
-    //  void bbForwardUpdate(Connection* caller);
-    //    void bbSetModifiedStatus(BlackBoxInputConnector* c);
-
   protected:
   
 
index 4e39eb45668d740ace70c5f68f1f7149e7333ece..bc6b3b1c001561de5335fb3311f7d027118dea5f 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkConnection.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/09 11:48:31 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.19 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -338,14 +338,14 @@ Connection::Connection(BlackBox::Pointer from, const std::string& output,
   //==================================================================
   
   //==================================================================
-  /// Backward Update
-  void Connection::BackwardUpdate()
+  /// Recursive execution
+  void Connection::RecursiveExecute()
   {
-    bbtkDebugMessage("process",3,
-                    "===> Connection::BackwardUpdate() ["
+    bbtkDebugMessage("process",4,
+                    "===> Connection::RecursiveExecute() ["
                     <<GetFullName()<<"]"<<std::endl);
 
-    mFrom->bbBackwardUpdate(GetThisPointer<Connection>());
+    mFrom->bbRecursiveExecute(GetThisPointer<Connection>());
 
     TransferData();
 
@@ -357,7 +357,7 @@ Connection::Connection(BlackBox::Pointer from, const std::string& output,
       }
     mTo->bbGetInputConnector(mInput).SetStatus(s);
     
-    bbtkDebugMessage("process",3,
+    bbtkDebugMessage("process",4,
                     " --> '"<<mTo->bbGetName()<<"."<<mInput
                     <<" ["<<&mTo->bbGetInputConnector(mInput)<<"] "
                     <<"' new status '"
@@ -365,31 +365,14 @@ Connection::Connection(BlackBox::Pointer from, const std::string& output,
                     <<"'"
                     << std::endl);
 
-    bbtkDebugMessage("process",3,
-                    "<=== Connection::BackwardUpdate() ["
+    bbtkDebugMessage("process",4,
+                    "<=== Connection::RecursiveExecute() ["
                     <<GetFullName()<<"]"<<std::endl);
-    return; // s;
+    return; 
   }
   //==================================================================
 
-  /*
-  //==================================================================
-  /// Forward Update
-  void Connection::ForwardUpdate()
-  {
-    bbtkDebugMessageInc("process",2,
-                       "Connection::ForwardUpdate() ["
-                       <<GetFullName()<<"]"<<std::endl);
-
-  
-    TransferData();
 
-    mTo->bbForwardUpdate(this);
-
-    bbtkDebugDecTab("process",2);
-  }
-  //==================================================================
-  */
 
   //==================================================================
   /// Transfers the data from the source output to the target input
@@ -503,24 +486,7 @@ Connection::Connection(BlackBox::Pointer from, const std::string& output,
 
   }
   //==================================================================
-  
-  /*
-  //==================================================================
-  /// Modified
-  void Connection::SetModifiedStatus()
-  {
-    bbtkDebugMessage("modified",2,
-                    "==> Connection::SetModifiedStatus() ["
-                    <<GetFullName()<<"]"<<std::endl);
-    
-    if (mAdaptor) mAdaptor->bbSetModifiedStatus();
-    
-    mTo->bbSetModifiedStatus(  mTo->bbGetInputConnectorMap().find(mInput)->second );
-    
-  }
-  //==================================================================
-  */
+
   //==================================================================
   /// From.Output change propagation
   void Connection::OnOutputChange(bbtk::BlackBox::Pointer, const std::string&, 
index 649b6eff5d8b48d27cf6a6323b98fd89c1149d5a..391385abea6ff7df7fea174e5416ed70a951d40a 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkConnection.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 12:54:23 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.11 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -85,12 +85,12 @@ namespace bbtk
     // void Delete();
     
     /// Pipeline processing method
-    /// 1) call bbBackwardUpdate(this) on the from box
+    /// 1) call bbRecursiveExecute(this) on the from box
     /// 2) copies the from box output to the to box input 
     ///    adapting it if needed
     /// 3) sets the new IOStatus of the to box input to the 
     ///    status of the from box output
-    void BackwardUpdate();
+    void RecursiveExecute();
     
     /// Change callback
     void OnOutputChange(BlackBoxPointer, const std::string&, 
index f0237f9a8b3ccbe16c7e094c9c341ff4475a06d1..6994d8bcc5386662726e619c0ff308762a0f8fb3 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkKWBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 12:54:26 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.7 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -110,46 +110,11 @@ namespace bbtk
   }
   //=========================================================================
 
-  //=========================================================================
-  /// Main processing method of the box.
-  void KWBlackBox::bbExecute(bool force)
-  {
-    bbtkDebugMessageInc("process",2,
-                       "=> KWBlackBox::bbExecute("<<(int)force<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-  
-    // If the output 'Widget' is connected then 
-    // we must execute the parent box
-    BlackBox::OutputConnectorMapType::const_iterator i 
-      = bbGetOutputConnectorMap().find("Widget");
-    
-    if ( i->second->GetConnectionVector().size() != 0 ) 
-      {
-       bbtkWarning("Execution called on '"<<bbGetFullName()
-                   <<"' although its Output 'Widget' is connected: "
-                   <<"if the widget is not created yet then it will not be! "
-                   <<"Execute the top level Layout widget to create and "
-                   <<"display the widget.");
-      }
-
-    AtomicBlackBox::bbExecute(force);
-
-    bbtkDebugMessageDec("process",2,
-                       "<= KWBlackBox::bbExecute() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-  }
-  //=========================================================================
-
 
   //=========================================================================
   void KWBlackBox::bbProcess()
   { 
-/*
-         if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
-    this->bbUserProcess(); 
-    bbShowWindow();
-    //    this->bbUserOnShow();
-*/
+
     this->bbUserProcess(); 
 
     // If output widget not connected create the window 
index f10a989050a29dcbc2596ee16eeb18481730e24a..6a2eb35f1a5767f7f564c645449d2ebcff422398 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkKWBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 12:54:26 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.5 $
 ========================================================================*/
 
 
@@ -68,11 +68,6 @@ namespace bbtk
 
 
 
-  //==================================================================
-  // Forward declaration of the widget event handler class
-  //  class KWBlackBoxWidgetEventHandler;
-  //==================================================================
-
 
   //==================================================================
   /// Widget black boxes
@@ -88,10 +83,7 @@ namespace bbtk
     BBTK_DECLARE_OUTPUT(Widget, vtkKWWidget*);
 
   public:
-    /// Main processing method of the box. Overloaded to handle windows inclusion : if the output Widget is connected then the execution is transfered to the box to which it is connected (as the container window must be created and displayed - this box will be executed by the normal pipeline recursion mechanism)
-    virtual void bbExecute(bool force = false);
-
-
+    
     typedef vtkKWBlackBoxDialog Window;
     
     /// Returns the **OWN** window associated to the box
@@ -108,10 +100,6 @@ namespace bbtk
     /// Else returns 0;
     Window* bbGetContainingWindow();
 
-    /// Returns the parent wxWindow that must be used to create the widget 
-         //
-         // LG 24/11/08 : New widget pipeline
-         //    wxWindow* bbGetKWParent();
 
     /// Returns true iff the 'containing window' exists and is shown 
     /// (see bbGetContainingWindow).
@@ -127,9 +115,7 @@ namespace bbtk
     virtual void bbUserOnHide() {}
     //==================================================================    
 
-    // LG 24/11/08 : New widget pipeline
-    //    void bbCreateWidgetAndEventHandler(vtkKWWidget* parent); 
-  /// Sets the window
+    /// Sets the window
     inline void bbSetWindow(Window* w) { bbmWindow=w; }
 
          
@@ -156,15 +142,10 @@ namespace bbtk
     //==================================================================    
 
 
+    //==================================================================
     vtkKWWidget* bbCreateWidgetOfInput(const std::string& in, 
                                       vtkKWFrame* parent);
-
-
     //==================================================================
-    /// Main processing method of the box.
-    //    virtual void bbBackwardUpdate( Connection::Pointer caller );
-    //==================================================================
-
 
 
     //==================================================================
@@ -190,37 +171,12 @@ namespace bbtk
     friend class vtkKWBlackBoxWindow;
     //    friend class KWBlackBoxWidgetEventHandler;
 
-  
-    /*
-    /// Sets the Widget Event Handler
-    inline void bbSetWidgetEventHandler(KWBlackBoxWidgetEventHandler* w) 
-    { bbmWidgetEventHandler = w; }
-    /// Gets the Widget Event Handler
-    inline KWBlackBoxWidgetEventHandler* bbGetWidgetEventHandler()
-    { return bbmWidgetEventHandler; }
-    */
-
     /// The KWBlackBoxWindow associated to the box
     Window* bbmWindow;
-    /// The KWBlackBoxWidgetEventHandler associated to the box
-    //    KWBlackBoxWidgetEventHandler* bbmWidgetEventHandler;
 
 
     void bbInitAttributes();
 
-  protected :
-
-    /*
-    /// For Forward update mechanism when execution is called 
-    /// on a contained window
-    /// Is set to true before transfering update to parent 
-    /// in order to not re-transfer a second time...
-    bool bbmUpdateTransferedToParent;
-
-    bool bbGetUpdateTransferedToParent() const { return bbmUpdateTransferedToParent; }
-    void bbSetUpdateTransferedToParent(bool b) 
-    { bbmUpdateTransferedToParent = b; }
-    */
   };
   //=================================================================
  
index beec07cbc532a81877784ef857c0ae47442a7ec7..3c99040dd699188f425cddfa1ae99d50442e393e 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 14:02:15 $
-  Version:   $Revision: 1.34 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.35 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -382,24 +382,6 @@ namespace bbtk
   //=========================================================================
   
 
-  /*
-  //=========================================================================
-  WxBlackBox::Widget*  WxBlackBox::bbGetWidget()
-  { 
-    if (bbGetOutputWidget() && bbGetOutputWidget()->IsDead()) 
-      {
-       bbtkDebugMessage("wx",9,"WxBlackBox::bbGetWidget() ["<<
-                        bbGetFullName()<<"] : Widget is dead : deleting it"
-                        <<std::endl);
-       delete bbGetOutputWidget();
-       bbSetOutputWidget(0);
-      }
-    return bbGetOutputWidget();
-  }
-  //=========================================================================
-  */
-
-
   //=========================================================================
   /**
    * \brief Initialize the attributes of the class
@@ -421,51 +403,10 @@ namespace bbtk
   }
   //=========================================================================
 
-  //=========================================================================
-  /// Main processing method of the box.
-  void WxBlackBox::bbExecute(bool force)
-  {
-    
-    bbtkDebugMessageInc("process",2,
-                       "=> WxBlackBox::bbExecute("<<(int)force<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-    
-    
-    // If the output 'Widget' is connected then 
-    // we must execute the parent box
-         /*
-    BlackBox::OutputConnectorMapType::const_iterator i 
-      = bbGetOutputConnectorMap().find("Widget");
-    
-    if ( i->second->GetConnectionVector().size() != 0 ) 
-      {
-       bbtkWarning("Execution called on '"<<bbGetFullName()
-                   <<"' although its Output 'Widget' is connected: "
-                   <<"if the widget is not created yet then it will not be! "
-                   <<"Execute the top level Layout widget to create and "
-                   <<"display the widget.");
-      }
-*/
-    AtomicBlackBox::bbExecute(force);
-
-    bbtkDebugMessageDec("process",2,
-                       "<= WxBlackBox::bbExecute() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-  }
-  //=========================================================================
-
-
   //=========================================================================
   void WxBlackBox::bbProcess()
   { 
-/*
-         if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
-         this->bbUserProcess(); 
-         bbShowWindow();
-         //    this->bbUserOnShow();
-         */
-    // LG 22/11/08 : new widget pipeline
-    // If output widget not connected : 
+    // If output widget not connected : have to create and show the window
     if ( (*bbGetOutputConnectorMap().find("Widget")).second
         ->GetConnectionVector().size() == 0 ) 
       {
@@ -485,7 +426,6 @@ namespace bbtk
                             "-> Creating the window"
                             <<std::endl);
            
-           
            // Input WinDialog set to true : creating a Dialog
            if (bbGetInputWinDialog()) 
              {
@@ -493,8 +433,6 @@ namespace bbtk
                                 "   Input WinDialog set to true : creating a Dialog"
                                 <<std::endl);
                show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
-                                                      // bbGetWxParent(), 
-                                                      // LG 24/11/08 : New widget pipeline
                                                       Wx::GetTopWindow(),
                                                       std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
                                                       wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
@@ -506,8 +444,6 @@ namespace bbtk
                                 "   Input WinDialog set to false : creating a Frame"
                                 <<std::endl);
                show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
-                                                     // bbGetWxParent(), 
-                                                     // LG 24/11/08 : New widget pipeline
                                                      Wx::GetTopWindow(),
                                                      std2wx( bbGetInputWinTitle()  + " - bbtk (c) CREATIS LRMN"),
                                                      wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
@@ -527,7 +463,7 @@ namespace bbtk
  
        
        
-  // LG 24/11/08 : New widget pipeline
+  //=========================================================================
   void WxBlackBox::bbCreateWidgetAndEventHandler(wxWindow* parent)
   {
     if (bbGetOutputWidget()==0)
@@ -561,10 +497,12 @@ namespace bbtk
     
     
   }
+  //=========================================================================
   
   
-  
-  wxWindow*  WxBlackBox::bbCreateWidgetOfInput(const std::string& in, wxWindow* parent)
+  //========================================================================= 
+  wxWindow*  WxBlackBox::bbCreateWidgetOfInput(const std::string& in, 
+                                              wxWindow* parent)
   {
     wxWindow* w = 0;
     // If input is connected 
@@ -583,127 +521,7 @@ namespace bbtk
       }
     return w;
   }
-  
-  /*
   //==================================================================
-  /// Specific methods for window creation during pipeline execution
-  /// Shows the window associated to the box 
-  /// (called after bbProcess during bbExecute)
-  void WxBlackBox::bbShowWindow()
-  {
-    bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbShowWindow() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-    // If Event Handler for the widget does not exist or is obsolete : create it 
-    if (bbGetOutputWidget()!=0)
-      {
-       if (bbGetWidgetEventHandler()==0)
-         {
-           bbtkDebugMessage("wx",3,
-                            "-> No widget event handler : creating one"
-                            <<std::endl);
-           new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
-                                            bbGetOutputWidget());
-         }
-       else if ( ! bbGetWidgetEventHandler()->IsHandlerOf 
-                 ( bbGetOutputWidget() ) )
-         {
-           bbtkDebugMessage("wx",3,
-                            "-> Obsolete widget event handler : re-creating one"
-                            <<std::endl);
-           delete bbGetWidgetEventHandler();
-           new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
-                                            bbGetOutputWidget());
-         }
-       // Sets the name of the wxWindow to the input WinTitle
-       bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle()));
-      }
-
-    // If the output 'Widget' is connected then it's gonna 
-    // be captured by its parent window : nothing to do 
-    if ( (*bbGetOutputConnectorMap().find("Widget")).second
-        ->GetConnectionVector().size() != 0 ) 
-      {
-       
-       bbtkDebugMessage("wx",2,
-                        "-> Output 'Widget' connected : nothing to do"
-                        <<std::endl);
-       return;
-      }
-
-
-    Window* show = 0;
-    // If the window already exists : no need creating it
-    if (bbGetWindow()!=0)
-      {
-       bbtkDebugMessage("wx",2,
-                        "-> Window already exists"
-                        <<std::endl);
-       show = bbGetWindow();
-      }
-    // Else if the widget exists : create window 
-    else if (bbGetOutputWidget()!=0) 
-      {
-       bbtkDebugMessage("wx",2,
-                        "-> Widget exists : creating the window"
-                        <<std::endl);
-
-
-       // Input WinDialog set to true : creating a Dialog
-       if (bbGetInputWinDialog()) 
-         {
-           bbtkDebugMessage("wx",2,
-                            "   Input WinDialog set to true : creating a Dialog"
-                            <<std::endl);
-           show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
-                                                 // bbGetWxParent(), 
-                                                                                         // LG 24/11/08 : New widget pipeline
-                                                                                         Wx::GetTopWindow(),
-                                                  std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
-                                                  wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
-         }
-       // Input WinDialog set to false : creating a Frame
-       else 
-         {
-           bbtkDebugMessage("process",2,
-                            "   Input WinDialog set to false : creating a Frame"
-                            <<std::endl);
-           show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
-                                                 // bbGetWxParent(), 
-                                                                                        // LG 24/11/08 : New widget pipeline
-                                                                                        Wx::GetTopWindow(),
-                                                 std2wx( bbGetInputWinTitle()  + " - bbtk (c) CREATIS LRMN"),
-                                                 wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
-         }
-
-      }
-    // No window nor widget : error
-    else
-      {
-       bbtkError("WxBlackBox::bbShowWindow() ["
-                 <<bbGetFullName()
-                 <<"] : No widget. Did you set the box output 'Widget' in the processing method of the box ?");
-      }
-    
-    // Show the window
-    if (true) //!show->IsShown())
-      {
-       show->bbShow(); 
-      }
-    else 
-      {
-       bbtkDebugMessage("wx",2,"-> Already shown : nothing to do"<<std::endl);
-      }
-  
-
-    bbtkDebugMessage("wx",2,"<= WxBlackBox::bbShowWindow() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-
-  }
-  //==================================================================
-*/
-
 
 
   //==================================================================
@@ -750,12 +568,6 @@ namespace bbtk
   //==================================================================
 
 
-  //==================================================================
-       // LG 24/11/08 : New widget pipeline
-       //  wxWindow* WxBlackBox::bbGetWxParent() { return Wx::GetTopWindow(); }
-  //==================================================================
-  
-  
   //==================================================================
   bool WxBlackBox::bbIsShown()
   {
index 2d9084c43f9102696717954adeb434957ea66d5e..be8bdfa79e821b2e2fe46167962c74f4d7361095 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 12:54:27 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2008/12/11 09:50:35 $
+  Version:   $Revision: 1.23 $
 ========================================================================*/
 
 
@@ -87,7 +87,7 @@ namespace bbtk
 
   public:
     /// Main processing method of the box. Overloaded to handle windows inclusion : if the output Widget is connected then the execution is transfered to the box to which it is connected (as the container window must be created and displayed - this box will be executed by the normal pipeline recursion mechanism)
-    virtual void bbExecute(bool force = false);
+    //   virtual void bbExecute(bool force = false);
 
 
     typedef WxBlackBoxWindow Window;
@@ -106,11 +106,6 @@ namespace bbtk
     /// Else returns 0;
     Window* bbGetContainingWindow();
 
-    /// Returns the parent wxWindow that must be used to create the widget 
-         //
-         // LG 24/11/08 : New widget pipeline
-         //    wxWindow* bbGetWxParent();
-
     /// Returns true iff the 'containing window' exists and is shown 
     /// (see bbGetContainingWindow).
     bool bbIsShown();
@@ -126,8 +121,9 @@ namespace bbtk
     //==================================================================    
 
 
-   // LG 24/11/08 : New widget pipeline
+    //==================================================================    
     void bbCreateWidgetAndEventHandler(wxWindow* parent); 
+    //==================================================================    
          
   protected:
     
@@ -144,7 +140,6 @@ namespace bbtk
     //==================================================================    
     /// User callback for creating the widget associated to the box
     /// ** Must be defined **
-    // LG 24/11/08 : New widget pipeline
     virtual void bbUserCreateWidget(wxWindow* parent) 
     {
       bbtkError(bbGetTypeName()<<" is a WxBlackBox whose bbUserCreateWidget methods is not overloaded : is it a feature or a bug ?!?");
@@ -158,13 +153,6 @@ namespace bbtk
     wxWindow* bbCreateWidgetOfInput(const std::string& in, wxWindow* parent);
     //==================================================================    
 
-
-    //==================================================================
-    /// Main processing method of the box.
-    //  No more overloaded
-    //  virtual void bbBackwardUpdate( Connection::Pointer caller );
-    //==================================================================
-
  
 
     //==================================================================
@@ -179,7 +167,7 @@ namespace bbtk
     /// (does nothing if the box output 'Widget' is connected which 
     /// means that the box does not have its own window but is contained 
     /// into another window)
-    void bbShowWindow();
+    //    void bbShowWindow();
     /// Hides the WxBlackBoxWindow associated to the box (if exists)
     void bbHideWindow();
     /// Closes (destroys) the WxBlackBoxWindow associated to the box (if exists)
index cc5fe49ba971661aa14f9ca56a000aee54344b61..3e284eb9a4f40961eeac7b82b57273cf2edaf5e7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer2D.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/09 15:25:08 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2008/12/11 09:50:38 $
+  Version:   $Revision: 1.31 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -333,13 +333,6 @@ namespace bbwxvtk
   }
 
 
-  // This callback is *no more*
-  // necessary to get actual processing of the view 
-  // when window is shown
-  void  Viewer2D::OnShowWidget()
-  {
-  }
-  
 
 }//namespace bbtk
 
index c72b8c893a91dce1fd2834b7b2a8456de8d554de..fdbdce284ef9ee1b9cc5e61f67125eefca85e99b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer2D.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/09 15:25:08 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2008/12/11 09:50:38 $
+  Version:   $Revision: 1.14 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -63,11 +63,11 @@ namespace bbwxvtk
     BBTK_DECLARE_OUTPUT(Renderer,vtkRenderer*);
     BBTK_PROCESS(Process);
     BBTK_CREATE_WIDGET(CreateWidget);
-    BBTK_ON_SHOW_WIDGET(OnShowWidget);
+    //   BBTK_ON_SHOW_WIDGET(OnShowWidget);
     
     void Process();
     void CreateWidget(wxWindow*);
-    void OnShowWidget();
+    //    void OnShowWidget();
     void bbUserConstructor();
   };