]> Creatis software - bbtk.git/blobdiff - kernel/doc/bbtkDevelopersGuide/bbtkDevelopersGuide.tex
*** empty log message ***
[bbtk.git] / kernel / doc / bbtkDevelopersGuide / bbtkDevelopersGuide.tex
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 
+
+
 
 
 % ==========================================