]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkBlackBox.h
*** MAJOR CHANGE *** NOT WORKING YET !!!
[bbtk.git] / kernel / src / bbtkBlackBox.h
index d25fc88c01d2dc505dce8162df5803b6ae031095..ce1117fed4214d3f691a80f384436b7545ecba28 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2009/04/30 14:31:31 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2009/05/14 14:43:33 $
+  Version:   $Revision: 1.25 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -118,14 +118,6 @@ namespace bbtk
 
 
  
-    //==================================================================
-    /// System callback which calls bbUserConstructor for all its ancestors 
-    /// and the box itself
-    virtual void bbConstructor() {}
-    /// System callback which calls bbUserDestructor for all its ancestors 
-    /// and the box itself
-    virtual void bbDestructor() {}
-    //==================================================================    
  
 
 
@@ -247,6 +239,62 @@ namespace bbtk
 
 
 
+    //==================================================================
+   /// User can redefine this method to set 
+    /// the default values of the box inputs and outputs
+    /// (it is called in the box constructor)
+    virtual void bbUserSetDefaultValues() {}
+
+    /// User can redefine this method to initialize what must be 
+    /// initialized for the box to work, for example allocate dynamic data.
+    /// It is called once and only once before any call to bbUserCreateWidget
+    /// or bbUserProcess.
+    /// What has been allocated here must be desalocated in 
+    /// bbFinalizeProcessing
+    virtual void bbUserInitializeProcessing() {}
+
+    /// User must redefine this method to uninitialize what has been
+    /// initialized in bbUserInitializeProcessing,
+    /// typically desallocate memory that has been allocated dynamically.
+    /// It is called in the box destructor if and only if (iff) 
+    /// bbUserInitializeProcessing has been called previously.
+    virtual void bbUserFinalizeProcessing() {}
+
+
+    /// Initializes processing IF NEEDED. 
+    /// Calls bbRecursiveInitializeProcessing if the box is in 
+    /// "uninitialized" state and put it in "initialized" state.
+    /// On construction, boxes are "uninitialized".
+    /// See also bbFinalizeProcessing
+    void bbInitializeProcessing();
+
+    /// Finalizes processing IF NEEDED.
+    /// Calls bbRecursiveFinalizeProcessing if the box is in 
+    /// "initialized" state and put it in "uninitialized" state.
+    /// On construction, boxes are "uninitialized".
+    /// See also bbInitializeProcessing
+    void bbFinalizeProcessing();
+
+    /// Abstract prototype of the method which 
+    /// Recursively calls itself for the parent black box and then
+    /// calls bbUserInitializeProcessing for its own class. 
+    /// It is redefined in each black box descendant.
+    /// Allows to call bbUserInitializeProcessing for all inherited classes
+    /// (like a constructor does)
+    virtual void bbRecursiveInitializeProcessing() {}
+
+
+    /// Abstract prototype of the method which 
+    /// calls bbUserFinalizeProcessing for its own class and then 
+    /// recursively calls itself for the parent black box.
+    /// It is redefined in each black box descendant.
+    /// Allows to call bbUserFinalizeProcessing for all inherited classes
+    /// (like a destructor does)
+   virtual void bbRecursiveFinalizeProcessing() {}
+
+    //==================================================================
+
+
    //==================================================================
     // Common inputs / outputs to all boxes
     /// Returns the value of the input "BoxProcessMode"
@@ -502,8 +550,8 @@ namespace bbtk
  
     //==================================================================
     // ATTRIBUTES
-    /// Is the box "constructed" ? (initialized)
-    bool bbmConstructed;
+    /// Is the box initialized ?
+    bool bbmInitialized;
     /// Is the box executing ?
     bool bbmExecuting;
     /// The name of the black-box