From: guigues Date: Thu, 11 Dec 2008 09:50:32 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: v0.9.1~40 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=bfd7e9034cbfd9c535e98ccb302c08e5e42da8c6;p=bbtk.git *** empty log message *** --- diff --git a/kernel/doc/bbtkDevelopersGuide/bbtkDevelopersGuide.tex b/kernel/doc/bbtkDevelopersGuide/bbtkDevelopersGuide.tex index 2c97a8d..facad1d 100644 --- a/kernel/doc/bbtkDevelopersGuide/bbtkDevelopersGuide.tex +++ b/kernel/doc/bbtkDevelopersGuide/bbtkDevelopersGuide.tex @@ -11,7 +11,7 @@ % ========================================== -\tableofcontents +%\tableofcontents % ========================================== % ========================================== @@ -22,6 +22,30 @@ \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()); + // Calls bbRecursiveExecute on the initial box + mFrom->bbRecursiveExecute(GetThisPointer()); // 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 + + % ========================================== diff --git a/kernel/src/bbtkAtomicBlackBox.cxx b/kernel/src/bbtkAtomicBlackBox.cxx index d421851..bf354ab 100644 --- a/kernel/src/bbtkAtomicBlackBox.cxx +++ b/kernel/src/bbtkAtomicBlackBox.cxx @@ -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")<<") [" - < already executing : returning"< Up-to-date : nothing to do" - <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 - //=========================================================================== - + //==================================================================== } diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index 2e5716e..914bf14 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -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<<") [" - < already executing : bailing out"< FreezeExecution global flag is 'true' : abort execution"< BlackBox::bbExecute("<<(int)force<<") [" + < already executing : abort"< FreezeExecution global flag is 'true' : abort execution"< BlackBox::bbRecursiveExecute(" + <<(caller?caller->GetFullName():"0")<<") [" + < already executing : abort"<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 [" + <first<<"' is Out-of-date ???"); + } + } + + bbtkDebugMessage("process",3," -> Up-to-date : nothing to do" + <second->BackwardUpdate(); + i->second->RecursiveExecute(); IOStatus t = i->second->GetStatus(); if (t > s) s = t; bbtkDebugMessageDec("change",2, diff --git a/kernel/src/bbtkBlackBox.h b/kernel/src/bbtkBlackBox.h index 53e286d..a8299e4 100644 --- a/kernel/src/bbtkBlackBox.h +++ b/kernel/src/bbtkBlackBox.h @@ -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& - 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& + 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) diff --git a/kernel/src/bbtkBlackBoxInputConnector.cxx b/kernel/src/bbtkBlackBoxInputConnector.cxx index dcfcb33..0acb246 100644 --- a/kernel/src/bbtkBlackBoxInputConnector.cxx +++ b/kernel/src/bbtkBlackBoxInputConnector.cxx @@ -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" - <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" < ComplexBlackBox::bbSetModifiedStatus(" - <GetBlackBox()->bbSetModifiedStatus(c); - - } - //================================================================== -*/ - //================================================================== void ComplexBlackBox::bbAddToExecutionList( const std::string& name ) { - bbtkDebugMessageInc("Kernel",9, + bbtkDebugMessageInc("Kernel",9, "ComplexBlackBox::bbAddToExecutionList(\"" < ComplexBlackBox::bbBackwardUpdate(" - <<(caller?caller->GetFullName():"0")<<") [" - <GetBlackBoxFrom()->bbGetFullName() - <<"."<GetBlackBoxFromOutput()<<"----" - <GetOriginalBlackBoxFrom()->bbGetFullName() - <<"."<GetOriginalBlackBoxFromOutput()<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 : "<GetTarget()<GetBlackBoxFromOutput(); - // std::cout << "oldout = "<GetFullName()<<"' does not point to a valid output of the complex box !"); - } - - return; // s; + mExecutionList.push_back( name ); + + bbtkDebugDecTab("Kernel",9); } //================================================================== diff --git a/kernel/src/bbtkComplexBlackBox.h b/kernel/src/bbtkComplexBlackBox.h index cf4000f..7236a60 100644 --- a/kernel/src/bbtkComplexBlackBox.h +++ b/kernel/src/bbtkComplexBlackBox.h @@ -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: diff --git a/kernel/src/bbtkConnection.cxx b/kernel/src/bbtkConnection.cxx index 4e39eb4..bc6b3b1 100644 --- a/kernel/src/bbtkConnection.cxx +++ b/kernel/src/bbtkConnection.cxx @@ -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() [" <bbBackwardUpdate(GetThisPointer()); + mFrom->bbRecursiveExecute(GetThisPointer()); 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, " --> '"<bbGetName()<<"."<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() [" <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() [" - <bbSetModifiedStatus(); - - mTo->bbSetModifiedStatus( mTo->bbGetInputConnectorMap().find(mInput)->second ); - - - } - //================================================================== - */ + //================================================================== /// From.Output change propagation void Connection::OnOutputChange(bbtk::BlackBox::Pointer, const std::string&, diff --git a/kernel/src/bbtkConnection.h b/kernel/src/bbtkConnection.h index 649b6ef..391385a 100644 --- a/kernel/src/bbtkConnection.h +++ b/kernel/src/bbtkConnection.h @@ -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&, diff --git a/kernel/src/bbtkKWBlackBox.cxx b/kernel/src/bbtkKWBlackBox.cxx index f0237f9..6994d8b 100644 --- a/kernel/src/bbtkKWBlackBox.cxx +++ b/kernel/src/bbtkKWBlackBox.cxx @@ -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<<") [" - <second->GetConnectionVector().size() != 0 ) - { - bbtkWarning("Execution called on '"<bbUserCreateWidget(); - this->bbUserProcess(); - bbShowWindow(); - // this->bbUserOnShow(); -*/ + this->bbUserProcess(); // If output widget not connected create the window diff --git a/kernel/src/bbtkKWBlackBox.h b/kernel/src/bbtkKWBlackBox.h index f10a989..6a2eb35 100644 --- a/kernel/src/bbtkKWBlackBox.h +++ b/kernel/src/bbtkKWBlackBox.h @@ -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; } - */ }; //================================================================= diff --git a/kernel/src/bbtkWxBlackBox.cxx b/kernel/src/bbtkWxBlackBox.cxx index beec07c..3c99040 100644 --- a/kernel/src/bbtkWxBlackBox.cxx +++ b/kernel/src/bbtkWxBlackBox.cxx @@ -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" - < WxBlackBox::bbExecute("<<(int)force<<") [" - <second->GetConnectionVector().size() != 0 ) - { - bbtkWarning("Execution called on '"<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" <(), - // 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" <(), - // 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() [" - < No widget event handler : creating one" - <(), - bbGetOutputWidget()); - } - else if ( ! bbGetWidgetEventHandler()->IsHandlerOf - ( bbGetOutputWidget() ) ) - { - bbtkDebugMessage("wx",3, - "-> Obsolete widget event handler : re-creating one" - <(), - 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" - < Window already exists" - < Widget exists : creating the window" - <(), - // 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" - <(), - // 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() [" - <IsShown()) - { - show->bbShow(); - } - else - { - bbtkDebugMessage("wx",2,"-> Already shown : nothing to do"<