]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Mon, 8 Jun 2009 14:49:58 +0000 (14:49 +0000)
committerguigues <guigues>
Mon, 8 Jun 2009 14:49:58 +0000 (14:49 +0000)
29 files changed:
kernel/appli/bbi/bbi.cxx
kernel/cmake/BBTKBuildDoxygenDoc.cmake
kernel/doc/bbtkDoxygen/CMakeLists.txt
kernel/doc/bbtkDoxygen/DoxyMainPage.txt.in
kernel/src/bbtkBlackBox.cxx
kernel/src/bbtkBlackBox.h
kernel/src/bbtkBlackBoxInputConnector.cxx
kernel/src/bbtkBlackBoxInputConnector.h
kernel/src/bbtkBlackBoxOutputConnector.cxx
kernel/src/bbtkBlackBoxOutputConnector.h
kernel/src/bbtkExecuter.cxx
kernel/src/bbtkExecuter.h
kernel/src/bbtkFactory.cxx
kernel/src/bbtkFactory.h
kernel/src/bbtkInterpreter.cxx
kernel/src/bbtkPackage.cxx
kernel/src/bbtkPackage.h
kernel/src/bbtkQtBlackBoxDialogParent.h [deleted file]
kernel/src/bbtkSystem.h
kernel/src/bbtkTranscriptor.cxx
kernel/src/bbtkTranscriptor.h
kernel/src/bbtkVirtualExec.h
kernel/src/bbtkWidgetBlackBox.h
kernel/src/bbtkWxGUIPackageBrowser2.cxx
packages/std/src/bbstdMagicBox.cxx
packages/std/src/bbstdMagicBox.h
packages/std/src/bbstdSharedMemory.cxx [new file with mode: 0644]
packages/std/src/bbstdSharedMemory.h [new file with mode: 0644]
packages/wx/bbs/appli/exampleSynchronizeWidgets.bbs

index 76aaef3e6667d6c9ea8ebe984438f24029da464c..16cbb8f0b45565addc4cc3ed00180051f7e09380 100644 (file)
@@ -194,7 +194,7 @@ bool wxBBIApp::OnInit( )
   if (help_on_script) 
     {
       std::string package; 
-      I->GetInterpreter()->GetExecuter()->GetFactory()->HelpBlackBox("workspace",package,false);
+      I->GetInterpreter()->GetExecuter()->GetFactory()->PrintHelpDescriptor("workspace",package,false);
     }
 
   /*
@@ -281,9 +281,9 @@ int main(int argc, char* argv[])
        {
          I->SetNoExecMode(false);
          std::string package; 
-         I->GetExecuter()->GetFactory()->HelpBlackBox("workspace",
-                                                      package,
-                                                      false);
+         I->GetExecuter()->GetFactory()->PrintHelpDescriptor("workspace",
+                                                             package,
+                                                             false);
        }
       if (cmdline.input_file.size()==0)
        I->CommandLineInterpreter();
index 02d65786703e32b780e2632774cbdff7283edcb1..0d03d680d4c9eac5cc9717c098ecc7ec7642e37b 100644 (file)
@@ -46,6 +46,15 @@ MACRO(BBTK_BUILD_DOXYGEN_DOC NAME INPUT DOC_RELATIVE_INSTALL_PATH PREDEFINED)
     @ONLY IMMEDIATE
     )
  
+  FILE(GLOB HTML RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.html")
+  FOREACH(file ${HTML})
+    CONFIGURE_FILE(
+      ${CMAKE_CURRENT_SOURCE_DIR}/${file}
+      ${DOXYGEN_OUTPUT}/${DOXYGEN_HTML_OUTPUT}/${file}
+      COPYONLY IMMEDIATE
+      )
+  ENDFOREACH(file ${HTML})
+  
   
   ADD_CUSTOM_COMMAND(
     OUTPUT ${DOXYGEN_OUTPUT}/${DOXYGEN_HTML_OUTPUT}/index.html
@@ -53,7 +62,7 @@ MACRO(BBTK_BUILD_DOXYGEN_DOC NAME INPUT DOC_RELATIVE_INSTALL_PATH PREDEFINED)
     ${DOXYGEN}
     ARGS
     ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.txt
-    #  DEPENDS bbtk bbi 
+    DEPENDS DoxyMainPage.txt.in
     )
   
   ADD_CUSTOM_TARGET(doxygen_${NAME} ALL
index 421895655cd7193b57f3098af9b783ac93934b3c..fe9119de8d425e9700f0bf1d1a69df49702a2a27 100755 (executable)
@@ -12,6 +12,11 @@ CONFIGURE_FILE(
   ${CMAKE_CURRENT_BINARY_DIR}/DoxyMainPage.txt
   @ONLY IMMEDIATE
   )
+CONFIGURE_FILE(
+  ${CMAKE_CURRENT_SOURCE_DIR}/BlackBox.html
+  ${CMAKE_CURRENT_BINARY_DIR}/BlackBox.html
+  IMMEDIATE
+  )
 
 SET(INPUT 
   ${CMAKE_CURRENT_BINARY_DIR}/DoxyMainPage.txt
@@ -24,7 +29,7 @@ BBTK_BUILD_DOXYGEN_DOC(
   "BBTK" 
   "${INPUT}" 
   "bbtk" 
-  "${DOXYGEN_DOC_PREDEFINED}"
+  "${CREA_DEFINITIONS}"
   )
 
 MESSAGE(STATUS "=======================================")
index 94c4c710011ea2337b41e4ac6aa1689c7c827192..2019718d9e581e1d43619e64fa8eb01b13fb318f 100644 (file)
@@ -3,10 +3,8 @@
 
 \htmlonly 
 
-"A black box is any system in which only the input and output characteristics are of interest - without regard to its internal mechanism or structure" (from <A href="http://en.wikipedia.org/wiki/Black_box_%28disambiguation%29" > wikipedia </A>)
-
 <li> 
-<A href="../CodingStyle.html"> Coding Style </A>
+<A href="BlackBox.html"> Black boxes </A>
 </li>
 
 \endhtmlonly
index 316f8cb8142a711f57eed716f3e2486b00a17b82..c74b2e9e1cf4a53a87ab398660813ffadc5d580a 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 14:22:09 $
-  Version:   $Revision: 1.47 $
+  Date:      $Date: 2009/06/08 14:50:02 $
+  Version:   $Revision: 1.48 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -169,7 +169,6 @@ namespace bbtk
 
 
   //=========================================================================
-  /// Returns the name with the name of the parent prepended if any
   std::string BlackBox::bbGetNameWithParent() const
   {
     if (bbmParent.lock()) 
@@ -184,7 +183,6 @@ namespace bbtk
   //=========================================================================
 
   //=========================================================================
-  /// Prints the Help on the BlackBox type 
   void BlackBox::bbGetHelp(bool full) const
   {
     bbGetDescriptor()->GetHelp(full); 
@@ -193,7 +191,6 @@ namespace bbtk
 
 
   //=========================================================================
-  /// Returns true if the UserBlackBox has an input of name name
   bool BlackBox::bbHasInput(const std::string& name) const
   {
     bbtkBlackBoxDebugMessage("kernel",8,
@@ -209,7 +206,6 @@ namespace bbtk
 
 
   //=========================================================================  
-  /// Returns true if the UserBlackBox has an output of name name
   bool BlackBox::bbHasOutput(const std::string& name) const
   {
     bbtkBlackBoxDebugMessage("kernel",8,"BlackBox::bbHasOutput(\""
@@ -224,7 +220,6 @@ namespace bbtk
 
 
   //=========================================================================  
-  ///  Gets the output type of a given name
   TypeInfo BlackBox::bbGetOutputType( const std::string &name ) const 
   {
     bbtkBlackBoxDebugMessage("kernel",8,
@@ -238,7 +233,6 @@ namespace bbtk
   //=========================================================================
 
   //=========================================================================
-  ///  Gets the input type of a given name
   TypeInfo BlackBox::bbGetInputType( const std::string &name ) const
   {
     bbtkBlackBoxDebugMessage("kernel",8,
@@ -253,7 +247,6 @@ namespace bbtk
 
 
   //=========================================================================
-  /// Allocates the i/o connectors of the black box
   void BlackBox::bbAllocateConnectors()
   {  
     bbtkBlackBoxDebugMessage("kernel",8,
@@ -286,7 +279,6 @@ namespace bbtk
 
 
   //=========================================================================
-  /// Desallocates the i/o connectors of the black box
   void BlackBox::bbDesallocateConnectors()
   {
     bbtkBlackBoxDebugMessage("kernel",8,
@@ -315,7 +307,6 @@ namespace bbtk
 
 
   //=========================================================================
-  /// Copies the input / output values from another box
   void BlackBox::bbCopyIOValues(BlackBox& from)
   {
     bbtkBlackBoxDebugMessage("kernel",1,
@@ -365,19 +356,6 @@ namespace bbtk
 
 
 
-  //=========================================================================
-  /// User overloadable destruction method of a black box
-  void BlackBox::bbUserDelete() 
-  {   
-    bbtkBlackBoxDebugMessage("process",5,
-                            "=> BlackBox::bbUserDelete()"
-                            <<" : not overloaded; using standard deletion"
-                            <<std::endl);
-    delete this;
-  }
-  //=========================================================================
-
-
   //=========================================================================
   BlackBox::BoxProcessModeValue BlackBox::bbGetBoxProcessModeValue() const
   {
@@ -440,117 +418,7 @@ namespace bbtk
   //=========================================================================
 
 
-  /*
-  //=========================================================================
-  ///  Sets the ChangeTime of input 
-  void BlackBox::bbSetInputChangeTime(BlackBoxInputConnector* c, 
-                                     const ChangeTime& t)
-  {
-    bbtkBlackBoxDebugMessage("change",1,
-                    "==> BlackBox::bbSetInputChangeTime("<<c<<","<<t<<") ["
-                    <<bbGetFullName()<<"]"<<std::endl);
-    
-    // If new time is greater than old one
-    if ( c->SetChangeTime(t) ) 
-      {
-       bool was_up_to_date = bbIsUpToDate();
-       // If new time is greater than the old max time of inputs
-       if ( mMaxInputChangeTime.Set(t) ) 
-         {
-           // If the box turned out-of-date
-           if ( was_up_to_date && bbIsOutOfDate() )
-             {
-               // 
-               if ( ( bbBoxProcessModeIsReactive()  ||
-                      (c==bbGetInputConnectorMap().find("BoxExecute")->second))
-                    && (bbCanReact() ) )
-                 {
-                   bbtkBlackBoxDebugMessage("change",2,
-                                    "an input of "
-                                    <<bbGetFullName()
-                                    <<" changed and box is in Reactive mode or BoxExecute input changed : adding it to the global execution list"
-                                    <<std::endl);
-                   bbGlobalAddToExecutionList( GetThisPointer<BlackBox>() );
-                 }
-               // Have to propagate the modification to aval boxes
-               OutputConnectorMapType::iterator i;
-               for (i = bbGetOutputConnectorMap().begin();
-                    i != bbGetOutputConnectorMap().end();
-                    ++i)
-                 {
-                   i->second->SetChangeTime(t);
-                 }
-               // update the MinOutputChangeTime
-               mMinOutputChangeTime.Set(t);
-             }
-         }
-      }
-  }
-  //=========================================================================
-
- //=========================================================================
-  ///  Sets the ChangeTime of output 
-  void BlackBox::bbSetOutputChangeTime(BlackBoxOutputConnector* c, 
-                                      const ChangeTime& t)
-  {
-    bbtkBlackBoxDebugMessage("change",1,
-                    "==> BlackBox::bbSetOutputChangeTime("<<c<<","<<t<<") ["
-                    <<bbGetFullName()<<"]"<<std::endl);
-    
-    //ChangeTime old = 
-    c->SetChangeTime(t);
-    // c->GetChangeTime() = t;
-    //    bbUpdateMinOutputChangeTime(t);
-    // propagate
-    
-  }
-  //=========================================================================
-  */
-
-  /*
-  //=========================================================================
-  void BlackBox::bbUpdateMaxInputChangeTime(const ChangeTime& t)
-  {    
-
-    
-    if ( t > mMaxInputChangeTime ) 
-      {
-       mMaxInputChangeTime = t;
-       if ( mMinOutputChangeTime > mMaxInputChangeTime )
-         {
-           
-         }
-      }
-    
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void bbUpdateMinOutputChangeTime(const ChangeTime& t)
-  {
-    ChangeTime old = mMinOutputChangeTime;
-    mMinOutputChangeTime = MAXLONG;
-    OutputConnectorMapType::iterator i;
-    for (i = bbGetOutputConnectorMap.begin();
-        i != bbGetOutputConnectorMap.end();
-        ++i)
-      {
-       if (i->second->GetChangeTime() < mMinOutputChangeTime)
-         mMinOutputChangeTime = i->second->GetChangeTime();
-      }
-    if ( mMinOutputChangeTime < old )
-      {
-      }
-   
-  }
-  //=========================================================================
-  */
-
   //=========================================================================
-  /// Signals that the BlackBox has been modified through 
-  /// the input connector c
-  /// and propagates it downward
-  /// ** NOT USER INTENDED **
   void BlackBox::bbSetStatusAndPropagate(BlackBoxInputConnector* c,
                                         IOStatus s)
   {
@@ -785,7 +653,6 @@ namespace bbtk
 
   
   //=========================================================================
-  /// Main recursive processing method of the box.
   void BlackBox::bbRecursiveExecute( Connection::Pointer caller )
   {
     bbtkBlackBoxDebugMessage("process",3,
@@ -867,9 +734,6 @@ namespace bbtk
 
 
   //=========================================================================
-  /// Updates the BlackBox inputs
-  /// Calls RecursiveExecute on all BlackBoxInputConnector
-  /// \returns The maximum of final IOStatus after each input update
   IOStatus BlackBox::bbUpdateInputs()
   {
     bbtkBlackBoxDebugMessage("process",4,
@@ -912,8 +776,7 @@ namespace bbtk
   //=========================================================================
 
   //==================================================================
-  /// Computes the final IOStatus of inputs and outputs after processing
-  void BlackBox::bbComputePostProcessStatus()
+   void BlackBox::bbComputePostProcessStatus()
   {
     bbtkBlackBoxDebugMessage("process",4,
                        "=> BlackBox::bbComputePostProcessStatus()"
@@ -957,7 +820,6 @@ namespace bbtk
   //==================================================================
 
   //=========================================================================
-  /// Connects the input <name> to the connection c
   void BlackBox::bbConnectInput( const std::string& name, Connection* c)
   {
     bbtkBlackBoxDebugMessage("connection",2,
@@ -985,7 +847,6 @@ namespace bbtk
 
 
   //=========================================================================  
-  /// Connects the output <name> to the connection c
   void BlackBox::bbConnectOutput( const std::string& name, Connection* c)
   {
     bbtkBlackBoxDebugMessage("connection",2,
@@ -1010,8 +871,7 @@ namespace bbtk
 
 
   //=========================================================================
-  /// Disconnects the input <name> from the connection c
-  void BlackBox::bbDisconnectInput( const std::string& name, Connection* c)
+   void BlackBox::bbDisconnectInput( const std::string& name, Connection* c)
   {
 
     bbtkBlackBoxDebugMessage("connection",2,
@@ -1043,8 +903,7 @@ namespace bbtk
 
 
   //=========================================================================
-  /// Disconnects the output <name> from the connection c
-  void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c)
+   void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c)
   {
     bbtkBlackBoxDebugMessage("connection",2,
                     "==> BlackBox::bbDisconnectOutput(\""<<name
@@ -1072,8 +931,28 @@ namespace bbtk
   //=========================================================================
  
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
   //=========================================================================
-  /// Virtual
   void BlackBox::bbWriteDotInputOutputName(FILE *ff,bool inputoutput,int detail, int level)
   {
     fprintf(ff,"%s%p",bbGetTypeName().c_str(),this);
@@ -1330,7 +1209,7 @@ namespace bbtk
 
 
   //=========================================================================
-  void BlackBox::bbShowRelations(BlackBox::Pointer parentblackbox, 
+  void BlackBox::bbPrintHelp(BlackBox::Pointer parentblackbox, 
                                 int detail, int level
                                 /*,Factory *factory*/ )
   {
@@ -1470,6 +1349,23 @@ namespace bbtk
    }
   //=========================================================================
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
   static bool bbmgGlobalProcessingExecutionList = false;
 
   //=========================================================================
index 21bf67be52e52b9043ce8b299f37c70e74159df8..c4419ff19a1cd2bb099f63a0b734576c12132249 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:05 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2009/06/08 14:50:02 $
+  Version:   $Revision: 1.27 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -75,9 +75,12 @@ namespace bbtk
   class BBTK_EXPORT BlackBox : public Object
   {
     BBTK_ABSTRACT_OBJECT_INTERFACE(BlackBox);
+
+
   public: 
+
     //==================================================================
-    // INTERFACE
+    // Types
     //==================================================================
     typedef boost::signals::trackable OutputChangeObserverType;
     typedef boost::signal<void (bbtk::BlackBox::Pointer,
@@ -92,15 +95,35 @@ namespace bbtk
     /// The type of map of input connector pointers
     typedef std::map<std::string, BlackBoxInputConnector*> 
     InputConnectorMapType;
+    //==================================================================
 
-    /// Returns the pointer on the descriptor of the box
-    virtual BlackBoxDescriptor::Pointer bbGetDescriptor() const = 0;
 
+    //==================================================================
+    /// @name Pipeline processing methods
+    ///  Methods which participate to pipeline processing.
+    //@{
+    /// Main processing method of the box.
+    virtual void bbExecute(bool force = false);
+    //@}
+    //==================================================================
+    
+
+
+    //==================================================================
     /// Returns a pointer on a clone of the box with name <name>
     virtual BlackBox::Pointer bbClone(const std::string& name) = 0;
+    //==================================================================
+    
 
-    /// User overloadable destruction method of a black box
-    virtual void bbUserDelete();
+   //==================================================================
+    /// @name General accessors
+    ///  Methods which give access to general informations on the box
+    //@{
+
+    /// Returns the pointer on the descriptor of the box
+    virtual BlackBoxDescriptor::Pointer bbGetDescriptor() const = 0;
 
     /// Returns the Name of the Type of the BlackBox
     const std::string& bbGetTypeName() const 
@@ -118,78 +141,93 @@ namespace bbtk
     
     /// Returns the parent of the BlackBox, i.e the BlackBox that contains it (0 if none)
     BlackBox::Pointer bbGetParent() const { return bbmParent.lock(); }
+    
+    //@}
+    //==================================================================
 
-
-    /// Main processing method of the box.
-    virtual void bbExecute(bool force = false);
-
-
  
 
+    //==================================================================
+    /// @name Inputs/Outputs related methods
+    ///  Methods related to the box inputs and outputs
+    //@{
 
     /// Returns true iff the BlackBox has an input of name label
     virtual bool bbHasInput(const std::string& label) const;
-    /// Returns true iff the BlackBox has an output of name label
-    virtual bool bbHasOutput(const std::string& label) const;
-
     ///  Gets the input type of a given label
     virtual TypeInfo bbGetInputType( const std::string &label ) const;
-    ///  Gets the output type of a given label
-    virtual TypeInfo bbGetOutputType( const std::string &label ) const;
-
+    /// Gets the status of the input called <name>
+    IOStatus bbGetInputStatus( const std::string &name ) const 
+    { return mInputConnectorMap.find(name)->second->GetStatus(); }
     ///  Gets the data of the input called <name>
     virtual Data bbGetInput( const std::string &name )  = 0;
-    ///  Gets the data of the output called <name>
-    virtual Data bbGetOutput( const std::string &name ) = 0;
+    ///  Gets the data of the input called <name> as a string using an Adaptor if possible (else returns empty string)
+    std::string bbGetInputAsString( const std::string &input); 
 
-    /// Sets the data of the input called <name>.
+   /// Sets the data of the input called <name>.
     /// If update_time is false then does not update ChangeTime of input
     virtual void bbSetInput( const std::string &name, Data data,
                             bool update_time = true ) = 0;
+    /// [SYSTEM]: Sets the data of the input called <name> which **MUST* be a pointer
     virtual void bbBruteForceSetInputPointer( const std::string &name, 
                                              void* data, 
                                              bool update_time = true) =0;
+    
+  
+    /// Returns true iff the BlackBox has an output of name label
+    virtual bool bbHasOutput(const std::string& label) const;
+    ///  Gets the output type of a given label
+    virtual TypeInfo bbGetOutputType( const std::string &label ) const;
+    ///  Gets the data of the output called <name>
+    virtual Data bbGetOutput( const std::string &name ) = 0;
+    ///  Gets the data of the output called <name> as a string using an Adaptor if possible (else returns empty string)
+    std::string bbGetOutputAsString( const std::string &output ); //,Factory *factory);
+    
     ///  Sets the data of the output called <name>
     virtual void bbSetOutput( const std::string &name, Data data) = 0;
 
 
-    /// Gets the status of the input called <name>
-    IOStatus bbGetInputStatus( const std::string &name ) const 
-    { return mInputConnectorMap.find(name)->second->GetStatus(); }
-
     ///  Returns the input connectors map
     InputConnectorMapType&  bbGetInputConnectorMap() 
     { return mInputConnectorMap; }
-    ///  Returns the output connectors map
-    OutputConnectorMapType& bbGetOutputConnectorMap() 
-    { return mOutputConnectorMap; }
     ///  Returns the input connectors map (const)
     const InputConnectorMapType&  bbGetInputConnectorMap() const 
     { return mInputConnectorMap; } 
+   ///  Returns the input connector
+    BlackBoxInputConnector&  bbGetInputConnector(const std::string& n) 
+    { return *(mInputConnectorMap.find(n)->second); }
+    ///  Returns the input connector (const)
+    const BlackBoxInputConnector&  bbGetInputConnector(const std::string& n) const
+    { return *(mInputConnectorMap.find(n)->second); }
+
+
+    ///  Returns the output connectors map
+    OutputConnectorMapType& bbGetOutputConnectorMap() 
+    { return mOutputConnectorMap; }
     ///  Returns the output connectors map (const)
     const OutputConnectorMapType& bbGetOutputConnectorMap() const 
     { return mOutputConnectorMap; }      
-
-    ///  Returns the input connector
-    BlackBoxInputConnector&  bbGetInputConnector(const std::string& n) 
-    { return *(mInputConnectorMap.find(n)->second); }
     ///  Returns the output connector
     BlackBoxOutputConnector& bbGetOutputConnector(const std::string& n) 
     { return *(mOutputConnectorMap.find(n)->second); }
-    ///  Returns the input connector (const)
-    const BlackBoxInputConnector&  bbGetInputConnector(const std::string& n) const
-    { return *(mInputConnectorMap.find(n)->second); }
-    ///  Returns the output connector (const)
+     ///  Returns the output connector (const)
     const BlackBoxOutputConnector& bbGetOutputConnector(const std::string& n) const 
     { return *(mOutputConnectorMap.find(n)->second); }
 
-    
+    //@}
+    //==================================================================
 
     /// Prints the Help on the BlackBox type 
     virtual void bbGetHelp(bool full=true) const;
 
+
+
+    //==================================================================
+    /// @name Output signals / observers related methods
+    ///  Methods related to signals emitted by outputs and the 
+    //@{
+
     //==================================================================
     /// Adds the function f to the list of functions to call when 
     /// the output changes.
@@ -243,99 +281,53 @@ namespace bbtk
                                             output_name,
                                             bool reaction = true);
    //==================================================================
+    //@}
 
 
 
-    //==================================================================
-   /// 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"
+    /// @name Common inputs / outputs to all boxes
+    //@{
+    /// Returns the value of the input 'BoxProcessMode'
     std::string bbGetInputBoxProcessMode() { return bbmBoxProcessMode; }
-    /// Sets the value of the input "BoxProcessMode"
+    /// Sets the value of the input 'BoxProcessMode'
     void bbSetInputBoxProcessMode(std::string a) { bbmBoxProcessMode = a; }
+    /// The possible values of the input 'BoxProcessMode'
     typedef enum
       {
        Pipeline,
        Always,
        Reactive
       }
-      BoxProcessModeValue;
+    BoxProcessModeValue;
     /// Returns the "decoded" value of the input "BoxProcessMode"
     BoxProcessModeValue bbGetBoxProcessModeValue() const;
-  
+    /// Returns true iff the input 'BoxProcessMode' is set to 'Reactive' (or a synonym)
     virtual bool bbBoxProcessModeIsReactive() const;
-
+    /// Returns true iff the input 'BoxProcessMode' is set to 'Always' (or a synonym)
     virtual bool bbBoxProcessModeIsAlways() const;
 
-    /// Returns the value of the input "Execute" 
+    /// Returns the value of the input 'BoxExecute'
     Void bbGetInputBoxExecute() { return Void(); }
-    /// Sets the value of the input "Execute"
+    /// Sets the value of the input 'BoxExecute'
     void bbSetInputBoxExecute(Void = 0) {}
 
-    /// Returns the value of the output "Change"
+    /// Returns the value of the output 'BoxChange'
     Void bbGetOutputBoxChange() { return Void(); }
-    /// Sets the value of the output "Change" : signal a modification
-    void bbSetOutputBoxChange(Void = 0) { } //bbSetModifiedStatus(); }
-
+    /// Sets the value of the output 'BoxChange' 
+    void bbSetOutputBoxChange(Void = 0) { } 
+    //@}
     //==================================================================    
 
 
-    //==================================================================    
+
+    
+    virtual void bbPrintHelp(BlackBox::Pointer parentblackbox, 
+                            int detail, int level
+                            );
 
     /// Does nothing here : overloaded in ComplexBlackBox
     void bbInsertHTMLGraph(  std::ofstream& s, 
@@ -346,6 +338,57 @@ namespace bbtk
                             bool relative_link ) 
     {}
 
+    
+    //==================================================================
+    /// @name Window related methods
+    //@{ 
+    virtual void bbSetShown(bool) {}
+    virtual bool bbIsShown() { return false; }
+    //@}
+    //==================================================================
+
+  protected:
+
+
+
+   //==================================================================
+    /// @name User redefinable methods
+    ///  Virtual methods which can be redefined by inherited classes 
+    //@{
+
+
+    //==================================================================
+    /// 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() {}
+    ///
+    virtual void bbUserOnShow() {}
+
+    //==================================================================
+    // @}
+    //==================================================================
+
+
+
+
+    //==================================================================    
+
     /// Write Graphviz-dot description in file. 
     /// Here dumps a single box description (i/o) but overloaded 
     /// in ComplexBlackBox to dump the internal pipeline representation 
@@ -365,22 +408,15 @@ namespace bbtk
                                           int detail, int level);
     
      
-    virtual void bbShowRelations(BlackBox::Pointer parentblackbox, 
-                                int detail, int level
-                                );
     
-    std::string bbGetOutputAsString( const std::string &output ); //,Factory *factory);
-    std::string bbGetInputAsString( const std::string &input); //,Factory *factory);
-    virtual BlackBox::Pointer bbFindBlackBox(const std::string &blackboxname) 
+     virtual BlackBox::Pointer bbFindBlackBox(const std::string &blackboxname) 
     { return BlackBox::Pointer();}
 
     virtual void Check(bool recursive = true);
 
-    virtual void bbSetShown(bool) {}
-    virtual bool bbIsShown() { return false; }
-    virtual void bbUserOnShow() {}
 
-  protected:
+
     //==================================================================
     // PROTECTED PART : ACCESSIBLE TO THE BlackBox DEVELOPER 
     // (IN INHERITED CLASSES)
@@ -391,43 +427,11 @@ namespace bbtk
     //==================================================================
 
 
-    //==================================================================
-    /// Signals that the input whose connector is c has changed 
-    /// and propagates the info downward
-    /// ** NOT USER INTENDED **
-    virtual void bbSetStatusAndPropagate(BlackBoxInputConnector* c,
-                                        IOStatus s);
-    //==================================================================
-    
-  private:
-    //==================================================================
-    friend class Connection;
-    friend class ComplexBlackBox;
-
-    /// Sets the parent of the BlackBox
-    void bbSetParent(BlackBox::Pointer p) { bbmParent = p; }
-    
-
-    /// Connects the input <name> to the connection c
-    virtual void bbConnectInput( const std::string& name, 
-                                Connection* c);
-    /// Connects the output <name> to the connection c
-    virtual void bbConnectOutput( const std::string& name, 
-                                 Connection* c);
-    /// Disconnects the input <name> from the connection c
-    virtual void bbDisconnectInput( const std::string& name, 
-                                   Connection* c);
-    /// Disconnects the output <name> from the connection c
-    virtual void bbDisconnectOutput( const std::string& name, 
-                                    Connection* c);
 
     //==================================================================
-  protected: 
     /// @name Pipeline processing methods
     ///  Methods which participate to pipeline processing.
     //@{
-
-    
     //==================================================================   
     /// Recursive execution method
     /// 
@@ -475,46 +479,139 @@ namespace bbtk
     //==================================================================
     /// Computes the final IOStatus of inputs and outputs after processing
     void bbComputePostProcessStatus();
+    //@}
+    //==================================================================
+
+
+    //==================================================================
+    /// Signals that the input whose connector is c has changed 
+    /// and propagates the info downward
+    /// ** NOT USER INTENDED **
+    virtual void bbSetStatusAndPropagate(BlackBoxInputConnector* c,
+                                        IOStatus s);
+    //==================================================================
+    
+
+
+    //==================================================================
+    /// @name Box con(des)struction / initi(fin)alization methods
+    //@{
+
+    //==================================================================
+    /// Allocates the i/o connectors of the black box
+    virtual void bbAllocateConnectors();
+    /// Desallocates the i/o connectors of the black box
+    virtual void bbDesallocateConnectors();
+    /// Copies the values of the inputs/output from the BlackBox from
+    virtual void bbCopyIOValues(BlackBox& from);
+    //==================================================================
+    
+    //==================================================================  
+    /// 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() {}
     //==================================================================
 
     //@}
-  public: 
+    //==================================================================
+
+
+
+  private:
+    //==================================================================
+    friend class Connection;
+    friend class ComplexBlackBox;
+
+    /// Sets the parent of the BlackBox
+    void bbSetParent(BlackBox::Pointer p) { bbmParent = p; }
+    
+    //==================================================================
+    /// @name Input/output connection/disconnection
+    /// INTERNAL METHODS used by a Connection to connect/disconnect
+    /// itself to the i/o connectors of the box
+    //@{
+
+    /// Connects the input <name> to the connection c
+    virtual void bbConnectInput( const std::string& name, 
+                                Connection* c);
+    /// Connects the output <name> to the connection c
+    virtual void bbConnectOutput( const std::string& name, 
+                                 Connection* c);
+    /// Disconnects the input <name> from the connection c
+    virtual void bbDisconnectInput( const std::string& name, 
+                                   Connection* c);
+    /// Disconnects the output <name> from the connection c
+    virtual void bbDisconnectOutput( const std::string& name, 
+                                    Connection* c);
+    //@}
+    //==================================================================
 
+    /// Returns true if the box can "react",
+    /// which means execute in response to an input change 
+    virtual bool bbCanReact() const;
+
+
+
+    //==================================================================
+    /// @name Manage the execution
+    //@{
     static bool bbGlobalGetSomeBoxExecuting();
     static void bbGlobalSetSomeBoxExecuting(bool b);
 
     static void bbGlobalSetFreezeExecution(bool b);
     static bool bbGlobalGetFreezeExecution();
 
-    /// Returns true if the box can "react",
-    /// which means execute in response to an input change 
-    virtual bool bbCanReact() const;
+    static void bbGlobalAddToExecutionList( BlackBox::Pointer b );
+    static void bbGlobalProcessExecutionList();
+
+    //@}
     
     /// Returns true iff the box is executing
     bool bbGetExecuting() const { return bbmExecuting; }
-
-  protected:  
-    static void bbGlobalAddToExecutionList( BlackBox::Pointer b );
-    static void bbGlobalProcessExecutionList();
     /// Sets the bbmExecuting bool returned by bbGetExecuting
     void bbSetExecuting(bool b) { bbmExecuting = b; }
 
+
+
+  protected:  
+
     //==================================================================
   protected:
-    //==================================================================
-    /// Allocates the i/o connectors of the black box
-    virtual void bbAllocateConnectors();
-    /// Desallocates the i/o connectors of the black box
-    virtual void bbDesallocateConnectors();
-    /// Copies the values of the inputs/output from the BlackBox from
-    virtual void bbCopyIOValues(BlackBox& from);
-    //==================================================================
 
-    //==================================================================
-    // Black box objects have a special deleter 
-    // which must take care of releasing the descriptor 
-    // **AFTER** the box is deleted 
-    // (Releasing it in the destructor may cause dl close and crash)
+
+     //==================================================================
+    /// Black box objects have a special deleter 
+    /// which must take care of releasing the descriptor 
+    /// **AFTER** the box is deleted 
+    /// (Releasing it in the destructor may cause dl close and crash)
     /// Black box deleter 
     /// 1) Calls the user overloadable bbDelete method
     /// 2) Releases the box descriptor
@@ -526,6 +623,7 @@ namespace bbtk
     //==================================================================
 
     //==================================================================
+    /// Like Object::MakePointer but returns a boost::shared_pointer which uses a BlackBox::Deleter to delete the object instead of the default Object::Deleter
     template <class U>
     static boost::shared_ptr<U> MakeBlackBoxPointer(U* s, bool lock = false)
     {
@@ -534,6 +632,10 @@ namespace bbtk
     //==================================================================
 
     //==================================================================
+    /// Effective deletion method called by the Deleter.
+    /// The default implementation is to issue 'delete this'
+    /// but it can be redefined in inherited classes to handle special deletion mechanisms (e.g. ref counting, private destructors, such as vtk objects deletion with method Delete, etc.).
+    /// \return The number of remaining references on the object after the call (if meaningfull...): used by bbtk to warn a user if another smart pointing system is still holding the object...
     virtual int bbDelete() { delete this; return 0; }
     //==================================================================
 
index 5180428d18368d55b9574a932366decdca485bca..a2355debee3a22923e2279b16ad9b15a6933ab33 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxInputConnector.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:05 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2009/06/08 14:50:02 $
+  Version:   $Revision: 1.11 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 
 namespace bbtk
 {
+
+  //========================================================================
+  /// The Pimpl
+  class BlackBoxInputConnector::Pimpl
+  {
+  public:
+    Pimpl() : mConnection(0), mStatus(MODIFIED) {}
+      
+    /// 
+    BlackBoxWeakPointer mBox;
+    /// The connection plugged into the input
+    Connection* mConnection;
+    /// The status of the input (UPTODATE | MODIFIED | OUTOFDATE)
+    IOStatus mStatus;
+
+  };
+  //========================================================================
+
+  //========================================================================
+  BBTK_IMPL_PIMPL(BlackBoxInputConnector)
+  //========================================================================
+
+
   //========================================================================
   BlackBoxInputConnector::BlackBoxInputConnector(BlackBox::Pointer b)  
-    : mBox(b), mConnection(0), mStatus(MODIFIED)
+  //: mBox(b), mConnection(0), mStatus(MODIFIED)
   {
     bbtkDebugMessage("kernel",9,
                     "["<<b->bbGetName()
                     <<"] BlackBoxInputConnector()"<<std::endl);
+    PimplConstruct();
+    p->mBox = b;
   }
   //========================================================================
 
@@ -53,19 +78,64 @@ namespace bbtk
   BlackBoxInputConnector::~BlackBoxInputConnector() 
   {
     bbtkDebugMessage("kernel",9,
-                    "[NULL"//<<mBox.lock()->bbGetName()
-                    <<"] ~BlackBoxInputConnector()"
+                    "[DEAD BOX] ~BlackBoxInputConnector()"
                     <<std::endl);
+    PimplDestruct();
   }
   //========================================================================
 
+  //========================================================================
+  /// Returns the connection plugged into this input (const)
+  Connection* BlackBoxInputConnector::GetConnection() const 
+  { 
+    return p->mConnection; 
+  }
+  //========================================================================
+  
+
+  //========================================================================
+  /// Returns true iff a connection is connected to it
+    bool BlackBoxInputConnector::IsConnected() const 
+  { 
+    return (p->mConnection != 0); 
+  }
+   //========================================================================
+   
+
+   //========================================================================
+   /// Returns the status of the input 
+    IOStatus BlackBoxInputConnector::GetStatus() const 
+   { 
+     return p->mStatus; 
+   }
+  //========================================================================
+
+  //========================================================================
+    /// Sets the status of the input 
+    void BlackBoxInputConnector::SetStatus(IOStatus s) 
+    { 
+      p->mStatus = s; 
+    }
+   //========================================================================
+   
+    
+
+  //========================================================================
+    /// Returns the black box which owns the connector
+    BlackBoxPointer BlackBoxInputConnector::GetBlackBox() const 
+    { 
+      return p->mBox.lock(); 
+    } 
+
+  //========================================================================
+
   //========================================================================
   void BlackBoxInputConnector::SetConnection(Connection* c) 
   { 
     bbtkDebugMessage("kernel",9,
-                    "["<<mBox.lock()->bbGetName()
+                    "["<<p->mBox.lock()->bbGetName()
                     <<"] BlackBoxInputConnector::SetConnection("<<c<<")"<<std::endl);
-    mConnection = c; 
+    p->mConnection = c; 
   }
   //========================================================================
 
@@ -73,10 +143,10 @@ namespace bbtk
   void BlackBoxInputConnector::UnsetConnection(Connection* c) 
   { 
     bbtkDebugMessage("kernel",9,
-                    "["<<mBox.lock()->bbGetName()
+                    "["<<p->mBox.lock()->bbGetName()
                     <<"] BlackBoxInputConnector::UnsetConnection("
                     <<c<<")"<<std::endl);
-    mConnection = 0; 
+    p->mConnection = 0; 
   }
   //========================================================================
   
@@ -86,20 +156,20 @@ namespace bbtk
     // If connected and OUTOFDATE : recursive update
     // Post-update status is updated by the connection 
     // (either MODIFIED or OUTOFDATE)
-    if ( mConnection && (mStatus == OUTOFDATE) )
+    if ( p->mConnection && (p->mStatus == OUTOFDATE) )
       {
-       mConnection->RecursiveExecute();
+       p->mConnection->RecursiveExecute();
       }
     else
       {
-       if (!mBox.expired())
-         bbtkDebugMessage("process",5,"["<<mBox.lock()->bbGetName()
+       if (!p->mBox.expired())
+         bbtkDebugMessage("process",5,"["<<p->mBox.lock()->bbGetName()
                           <<"] --> BlackBoxInputConnector::RecursiveExecute() : "
                           <<"No connection or input not Out-of-date : nothing to do"
                           <<std::endl);
        else
-         bbtkDebugMessage("process",5,"[UNKNOWN"
-                          <<"] --> BlackBoxInputConnector::RecursiveExecute() : "
+         bbtkDebugMessage("process",5,
+                          "[DEAD BOX] --> BlackBoxInputConnector::RecursiveExecute() : "
                           <<"No connection or input not Out-of-date : nothing to do"
                           <<std::endl);
          
index ff25f5138fd558179fe223ad42193f67bf70f71e..4d6a91fa62c0baa944a7a6c6bbe6fa004234c4df 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxInputConnector.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/11 09:50:35 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2009/06/08 14:50:03 $
+  Version:   $Revision: 1.8 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -42,6 +42,7 @@
 #define __bbtkBlackBoxInputConnector_h__
 
 #include "bbtkConnection.h"
+#include "bbtkPimpl.h"
 #include <vector>
 
 namespace bbtk
@@ -58,38 +59,37 @@ namespace bbtk
     BlackBoxInputConnector(BlackBoxPointer b);
     /// Dtor
     ~BlackBoxInputConnector();    
+
     /// Sets a connection
     void SetConnection(Connection* c);
     /// Unsets the connection 
     /// The parameter is USELESS today but would be useful if we allow multiple connections on inputs
     void UnsetConnection(Connection* c);
-  
-    // Recursive execution
-    void RecursiveExecute();
-
     /// Returns the connection plugged into this input (const)
-    Connection* GetConnection() const { return mConnection; }
+    Connection* GetConnection() const;
     /// Returns true iff a connection is connected to it
-    bool IsConnected() const { return (mConnection != 0); }
+    bool IsConnected() const;
     
 
+    // Recursive execution
+    void RecursiveExecute();
+
+
     /// Returns the status of the input 
-    IOStatus GetStatus() const { return mStatus; }
+    IOStatus GetStatus() const;
     /// Sets the status of the input 
-    void SetStatus(IOStatus s) { mStatus = s; }
-    
+    void SetStatus(IOStatus s);
     
-
     /// Returns the black box which owns the connector
-    BlackBoxPointer GetBlackBox() const { return mBox.lock(); } 
-  private:
-    /// 
-    BlackBoxWeakPointer mBox;
-    /// The connection plugged into the input
-    Connection* mConnection;
-    /// The status of the input (UPTODATE | MODIFIED | OUTOFDATE)
-    IOStatus mStatus;
+    BlackBoxPointer GetBlackBox() const;
+
+
+    /// Private implementation
+    BBTK_DECLARE_PIMPL(BlackBoxInputConnector);
  
+  private:
+    /// Purposedly not implemented
+    BlackBoxInputConnector(const BlackBoxInputConnector&);
   };
   
 }
index 6631657a3c3a76f374545f3061b77aa1c566cc13..e6ba06c5c9780ba86018a56923b4f6537e8f4b60 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:05 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2009/06/08 14:50:03 $
+  Version:   $Revision: 1.13 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 namespace bbtk
 {
 
+  //========================================================================
+  /// The Pimpl
+  class BlackBoxOutputConnector::Pimpl
+  {
+  public:
+    Pimpl() : mStatus(OUTOFDATE) {}
+    Pimpl(const Pimpl&) {}
+   /// 
+    BlackBoxWeakPointer mBox;
+    /// The vector of output connections
+    ConnectionVector mConnection;
+    /// The status of the output 
+    IOStatus mStatus;
+    /// The output changed signal 
+    BlackBox::OutputChangeSignalType mChangeSignal;
+
+
+  };
+  //========================================================================
+
+  //========================================================================
+  BBTK_IMPL_PIMPL(BlackBoxOutputConnector)
+  //========================================================================
+
+
   //======================================================================
   BlackBoxOutputConnector::BlackBoxOutputConnector(BlackBox::Pointer b) 
-    : mBox(b),
-      mStatus(OUTOFDATE)
   {
     bbtkDebugMessage("kernel",9,
                     "["<<b->bbGetName()
                     <<"] BlackBoxOutputConnector()"<<std::endl);
+    PimplConstruct();
+    p->mBox = b;
   }
   //======================================================================
 
@@ -58,8 +83,7 @@ namespace bbtk
   BlackBoxOutputConnector::~BlackBoxOutputConnector() 
   {
     bbtkDebugMessage("kernel",9,
-                    "[NULL"//<<mBox.lock()->bbGetName()
-                    <<"] ==> ~BlackBoxOutputConnector()"
+                    "[DEAD BOX] ==> ~BlackBoxOutputConnector()"
                     <<std::endl);
     /*
     ConnectionVector::iterator i;
@@ -68,10 +92,11 @@ namespace bbtk
         ++i)
       (*i) = Connection::WeakPointer();
     */
-    mConnection.clear();
+    p->mConnection.clear();
+    PimplDestruct();
+  
     bbtkDebugMessage("kernel",9,
-                    "[NULL"//<<mBox.lock()->bbGetName()
-                    <<"] <== ~BlackBoxOutputConnector()"
+                    "[DEAD BOX] <== ~BlackBoxOutputConnector()"
                     <<std::endl);
   }
   //======================================================================
@@ -81,10 +106,10 @@ namespace bbtk
   void BlackBoxOutputConnector::SetConnection(Connection* c)
   {
     bbtkDebugMessage("kernel",9,
-                    "["<<mBox.lock()->bbGetName()
+                    "["<<p->mBox.lock()->bbGetName()
                     <<"] BlackBoxOutputConnector::SetConnection("
                     <<c<<")"<<std::endl);
-    mConnection.push_back(c);
+    p->mConnection.push_back(c);
     //    AddChangeObserver(boost::bind(&Connection::SignalChange,c));
   }
   //======================================================================
@@ -93,13 +118,13 @@ namespace bbtk
   //======================================================================
   void BlackBoxOutputConnector::UnsetConnection(Connection* c)
   {
-    bbtkDebugMessage("kernel",9,"["<<mBox.lock()->bbGetName()
+    bbtkDebugMessage("kernel",9,"["<<p->mBox.lock()->bbGetName()
                     <<"] BlackBoxOutputConnector::UnsetConnection("
                     <<c<<")"<<std::endl);
 
     if (!c) 
       {
-       bbtkInternalError(mBox.lock()->bbGetFullName()
+       bbtkInternalError(p->mBox.lock()->bbGetFullName()
                          <<": BlackBoxOutputConnector::UnsetConnection("
                          <<c<<") : invalid connection");
 
@@ -108,28 +133,51 @@ namespace bbtk
     //Connection::WeakPointer w(c);
     ConnectionVector::iterator i;
     //  = find(mConnection.begin(),mConnection.end(),c);
-    for (i=mConnection.begin();
-        i!=mConnection.end();
+    for (i=p->mConnection.begin();
+        i!=p->mConnection.end();
         ++i)
       {
        if (*i==c) break;
       }
-    if (i==mConnection.end())
+    if (i==p->mConnection.end())
       {
-       bbtkInternalError(mBox.lock()->bbGetFullName()
+       bbtkInternalError(p->mBox.lock()->bbGetFullName()
                          <<": BlackBoxOutputConnector::UnsetConnection("
                          <<c
                          <<") : connection is absent from connections list");
       }
-    mConnection.erase(i);
+    p->mConnection.erase(i);
     //    RemoveChangeObserver(boost::bind(&Connection::SignalChange,c));
 
 
   }
   //======================================================================
+  
+  //======================================================================
+  const BlackBoxOutputConnector::ConnectionVector& 
+  BlackBoxOutputConnector::GetConnectionVector() const
+  { 
+    return p->mConnection; 
+  }
+  //======================================================================
+  
+  //======================================================================
+  /// Returns the status of the input 
+  IOStatus BlackBoxOutputConnector::GetStatus() const 
+  { 
+    return p->mStatus; 
+  }
+  //======================================================================
 
+  //======================================================================
+  /// Sets the status of the input 
+  void BlackBoxOutputConnector::SetStatus( IOStatus s ) 
+  {
+    p->mStatus = s; 
+  }
+  //======================================================================
   
-   //======================================================================
+  //======================================================================
   void BlackBoxOutputConnector::SignalChange( BlackBox::Pointer box,
                                              const std::string& output )
   {
@@ -146,7 +194,7 @@ namespace bbtk
     //    std::cout<<"BlackBoxOutputConnector::SignalChange("
     //      <<box->bbGetName()<<",'"
     //      <<output<<"')"<<std::endl;
-    mChangeSignal(box,output,s);
+    p->mChangeSignal(box,output,s);
     
     bbtkDebugMessage("change",2,
                     "["<<box->bbGetName()
@@ -156,66 +204,12 @@ namespace bbtk
                     <<std::endl);
   }
   //======================================================================
- /*
-  void BlackBoxOutputConnector::SetModifiedStatus()
-  {
-    bbtkDebugMessage("modified",2,
-                    "==> BlackBoxOutputConnector::SetModifiedStatus() ["
-                    <<this<<"]"
-                    <<std::endl);
-    ConnectionVector::iterator i;
-    for (i=mConnection.begin();i!=mConnection.end();++i) 
-      {
-       (*i)->SetModifiedStatus();
-      }
-    
-    
-   }
-  */
-  /*
-  //======================================================================
-  void BlackBoxOutputConnector::SetChangeTime(const ChangeTime& t)
-  {
-    bbtkDebugMessage("change",2,
-                    "==> BlackBoxOutputConnector::SetChangeTime("<<t<<") ["
-                    <<this<<"]"
-                    <<std::endl);
-    if (mChangeTime.Set(t))
-      {
-       mChangeSignal(this);
-      }
-    bbtkDebugMessage("change",2,
-                    "<== BlackBoxOutputConnector::SetChangeTime("<<t<<") ["
-                    <<this<<"]"
-                    <<std::endl);
-  }
-  //======================================================================
-  */
-  /*
- //======================================================================
-  void BlackBoxOutputConnector::SetChangeTimeToCurrentTime()
-  {
-    bbtkDebugMessage("change",2,
-                    "==> BlackBoxOutputConnector::SetChangeTimetoCurrentTime() ["
-                    <<this<<"]"
-                    <<std::endl);
-    mChangeTime.Set(ChangeTime::GetCurrentTime());
-    mChangeSignal(this);
-    
-    bbtkDebugMessage("change",2,
-                    "<==> BlackBoxOutputConnector::SetChangeTimetoCurrentTime() ["
-                    <<this<<"]"
-                    <<std::endl);
-  }
-  //======================================================================
-  */
-
 
   //======================================================================
   void BlackBoxOutputConnector::AddChangeObserver(OutputChangeCallbackType f)
   { 
     //    std::cout << "BlackBoxOutputConnector::AddChangeObserver" << std::endl;
-    mChangeSignal.connect(f); 
+    p->mChangeSignal.connect(f); 
   }
   //======================================================================
   
index d40703db7638a868d67c523ee79a23155df53b9b..53248857fd1adc3cb6da0ce829b286b32bf37bf0 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxOutputConnector.h,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:05 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2009/06/08 14:50:03 $
+  Version:   $Revision: 1.10 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 #ifndef __bbtkBlackBoxOutputConnector_h__
 #define __bbtkBlackBoxOutputConnector_h__
 
+#include "bbtkPimpl.h"
 #include "bbtkConnection.h"
 #include "bbtkBlackBox.h"
 #include "bbtkMessageManager.h"
 #include <vector>
 
-// Change time management
-//#include <bbtkChangeTime.h>
-
-// Signal/slot mechanism for output change events
-//#include <boost/signal.hpp>
-//#include <boost/bind.hpp>
 
 namespace bbtk
 {
 
-  //  class BlackBox;
-  //  BBTK_FORWARD_DECLARE_POINTER(BlackBox);
-
-  //  void  operator (void*)(ChangeCallbackType t) { return (void*)t; };
  
-/*
-  typedef void (*ChangeSignalFunctionType)(BlackBoxOutputConnector*);
-  bool operator==(void (*sg1)(BlackBoxOutputConnector*),
-                 void (*sg2)(BlackBoxOutputConnector*)) 
-  { return sg1==sg2;}
-*/
-/*
-  bool operator==(boost::function1<void, bbtk::BlackBoxOutputConnector*, std::allocator<void> >,boost::function1<void, bbtk::BlackBoxOutputConnector*, std::allocator<void> >)
-  {
-  }
-*/
-  //boost::function<void ()(bbtk::BlackBoxOutputConnector*), std::allocator<void> >]
   class BBTK_EXPORT BlackBoxOutputConnector 
   {
   public:
  
-    //    typedef boost::signals::trackable ChangeObserverType;
-    //    typedef boost::signal<void (bbtk::BlackBox::Pointer*,const std::string&,IOStatus)>  ChangeSignalType;
-    //    typedef ChangeSignalType::slot_function_type ChangeCallbackType;
-
+  
     typedef BlackBox::OutputChangeCallbackType OutputChangeCallbackType;
 
+    /// Ctor
     BlackBoxOutputConnector(BlackBoxPointer b);
+    /// Dtor
     ~BlackBoxOutputConnector();
 
+    /// Sets a connection
     void SetConnection(Connection* c);
+    /// Unsets the connection 
     void UnsetConnection(Connection* c);
+    /// The type of vector of output connections
     typedef std::vector<Connection*> ConnectionVector;
-    const ConnectionVector& GetConnectionVector() const { return mConnection; }
+    /// Returns the vector of connection plugged into this output (const)
+    const ConnectionVector& GetConnectionVector() const;
+    
+    /// Returns the status of the input 
+    IOStatus GetStatus() const;
+    /// Sets the status of the input 
+    void SetStatus( IOStatus s );
     
-    IOStatus GetStatus() const { return mStatus; }
-    void SetStatus( IOStatus s ) { mStatus = s; }
+    /// Signals the change observers that the output has changed
     void SignalChange( BlackBox::Pointer box, const std::string& output );
 
 
-    //    void SetModifiedStatus();
-
-    /// Returns the ChangeTime of the output (const)
-    //  const ChangeTime& GetChangeTime() const { return mChangeTime; }
-    /// Returns the ChangeTime of the output 
-    //    ChangeTime& GetChangeTime() { return mChangeTime; }
-
-    /// To be called when the output has changed
-    /// (sets the ChangeTime to current time and 
-    ///  signals the change to observers)
-    //    void SetChangeTime(const ChangeTime&); 
-   
-    /// To be called when the output has changed
-    /// (sets the ChangeTime to current time and 
-    ///  signals the change to observers)
-    //    void SetChangeTimeToCurrentTime(); 
-
     /// Adds the function f to the list of functions to call when 
     /// the output changes.
     void AddChangeObserver(OutputChangeCallbackType f); 
@@ -121,16 +90,12 @@ namespace bbtk
     /// the output changes (TO WRITE)
     void RemoveChangeObserver(OutputChangeCallbackType f); 
 
-
+      /// Private implementation
+    BBTK_DECLARE_PIMPL(BlackBoxOutputConnector);
+    
   private:
-    /// 
-    BlackBoxWeakPointer mBox;
-    /// The vector of output connections
-    ConnectionVector mConnection;
-    /// The status of the output 
-    IOStatus mStatus;
-    /// The output changed signal 
-    BlackBox::OutputChangeSignalType mChangeSignal;
+    /// Purposedly not implemented
+    BlackBoxOutputConnector(const BlackBoxOutputConnector&);
 
   };
   
index 91054a35c8c026b47be07c4315fa66c5d4c0750e..39a3d003b9d4561b49384b3625998809acdd691a 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkExecuter.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:05 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2009/06/08 14:50:03 $
+  Version:   $Revision: 1.31 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -114,7 +114,7 @@ namespace bbtk
   {
     bbtkDebugMessage("kernel",9,"==> Executer::Reset()" <<std::endl);
 
-    GetFactory()->CheckPackages();
+    //    GetFactory()->Check();
  
     mOpenDefinition.clear();
     mOpenPackage.clear();
@@ -142,7 +142,7 @@ namespace bbtk
     r->AddToDescription("User's workspace");
     mOpenDefinition.push_back(CBBDefinition(r,"user"));
     // Register it into the user package
-    p->RegisterBlackBox(r);
+    p->Register(r);
     mRootCBB = r;
 
     //    Object::PrintObjectListInfo();
@@ -156,7 +156,7 @@ namespace bbtk
   /// changes the workspace name
   void Executer::SetWorkspaceName( const std::string& n )
   {
-    GetUserPackage()->ChangeBlackBoxName( GetWorkspace()->GetTypeName(), n );
+    GetUserPackage()->ChangeDescriptorName( GetWorkspace()->GetTypeName(), n );
   }
   //=======================================================================
 
@@ -253,7 +253,8 @@ namespace bbtk
       {
        p = mOpenPackage.back().lock();
       }
-    p->RegisterBlackBox(GetCurrentDescriptor());
+    // Register the descriptor in the current package
+    p->Register(GetCurrentDescriptor());
     
     bbtkDebugMessage("kernel",9,"<== Executer::EndDefine(\""
                     <<GetCurrentDescriptor()->GetTypeName()<<"\")" 
@@ -501,9 +502,11 @@ namespace bbtk
   }
   //=======================================================================
 
+
+
   //=======================================================================
   /// prints the list of the boxes of the current descriptor
-  void Executer::PrintBoxes()
+  void Executer::PrintHelpListBoxes()
   {
     bbtkMessage("help",1,"The black box descriptor \""
                <<GetCurrentDescriptor()->GetTypeName()<<"\" contains : "<<std::endl);
@@ -644,7 +647,7 @@ namespace bbtk
   //=======================================================================
 
   //=======================================================================
-  void Executer::ShowRelations(const std::string &nameblackbox, 
+  void Executer::PrintHelpBlackBox(const std::string &nameblackbox, 
                               const std::string &detailStr, 
                               const std::string &levelStr)
   {
@@ -665,12 +668,12 @@ namespace bbtk
     if (blackbox)
       {
        found=true;
-       blackbox->bbShowRelations(blackbox,detail,level); //,mFactory);
+       blackbox->bbPrintHelp(blackbox,detail,level); //,mFactory);
       }
     
     if (!found) 
       {
-       bbtkError("Blackbox Name not found.. <"  <<nameblackbox<<">");
+       bbtkError("box with name '"  <<nameblackbox<<"' unknown");
       }
   }
   //=======================================================================
index 922ca0754dbf39a5aae0512d46def83ff843a600..71f92d227b10fe8960e0836f7240d8e603d6af18 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkExecuter.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/12 12:11:21 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2009/06/08 14:50:03 $
+  Version:   $Revision: 1.18 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -165,8 +165,13 @@ namespace bbtk
     /// The description string which explains what does the ComplexBox
     void Description(const std::string & d);
 
+
+
+
+
+
     /// prints the list off the boxes of the current box
-    void PrintBoxes();
+    void PrintHelpListBoxes();
 
    /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
     std::string ShowGraph(const std::string &nameblackbox, 
@@ -180,9 +185,14 @@ namespace bbtk
     /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
     std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
     
-    /// Description of the actual pipeline
-    void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
+    /// Prints help on a black box
+    void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
     
+
+
+
+
+
     /// Resets the workspace : destroys all boxes / unloads all packages
     void Reset();
 
index bd057e349e8aeaa24c19f58d148fe078074bd8b7..37563de8e3523386c3d7076837e0d32c0bf15a2c 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkFactory.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 14:22:10 $
-  Version:   $Revision: 1.44 $
+  Date:      $Date: 2009/06/08 14:50:03 $
+  Version:   $Revision: 1.45 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -390,8 +390,7 @@ namespace bbtk
 
 
   //===================================================================  
-  /// Displays the list of packages loaded
-  void Factory::PrintPackages(bool details, bool adaptors) const
+  void Factory::PrintHelpListPackages(bool details, bool adaptors) const
   {
     bbtkDebugMessageInc("kernel",9,"Factory::PrintPackages"<<std::endl);
 
@@ -400,7 +399,7 @@ namespace bbtk
     {
       bbtkMessage("help",1, i->first << std::endl);
       if (details) {
-         i->second->PrintBlackBoxes(false,adaptors);
+         i->second->PrintHelpListDescriptors(false,adaptors);
       }
     }
 
@@ -410,9 +409,10 @@ namespace bbtk
 
   //===================================================================  
   /// Displays help on a package
-  void Factory::HelpPackage(const std::string& name, bool adaptors) const
+  void Factory::PrintHelpPackage(const std::string& name, bool adaptors) const
   {
-    bbtkDebugMessageInc("kernel",9,"Factory::HelpPackage(\""<<name<<"\")"
+    bbtkDebugMessageInc("kernel",9,"Factory::PrintHelpPackage(\""
+                       <<name<<"\")"
                         <<std::endl);
 
     PackageMapType::const_iterator i = mPackageMap.find(name);
@@ -432,10 +432,10 @@ namespace bbtk
       bbtkMessageCont("help",1,std::endl);
       bbtkIncTab("help",1);
       bbtkMessage("help",1,i->second->GetDescription()<<std::endl);
-      if (i->second->GetNumberOfBlackBoxes()>0) 
+      if (i->second->GetNumberOfDescriptors()>0) 
         {
           bbtkMessage("help",1, "Black boxes : "<<std::endl);
-          i->second->PrintBlackBoxes(true,adaptors);
+          i->second->PrintHelpListDescriptors(true,adaptors);
         }
       else 
         {
@@ -456,20 +456,21 @@ namespace bbtk
   //===================================================================
   /// Prints help on the black box of type <name>
   /// Returns the package to which it belongs
-  void Factory::HelpBlackBox(const std::string& name, 
+  void Factory::PrintHelpDescriptor(const std::string& name, 
                             std::string& package,
                             bool full) const
   {
-    bbtkDebugMessageInc("kernel",9,"Factory::HelpBlackBox(\""<<name<<"\")"
+    bbtkDebugMessageInc("kernel",9,"Factory::PrintHelpDescriptor(\""
+                       <<name<<"\")"
                         <<std::endl);
 
     bool found = false;
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-      if (i->second->ContainsBlackBox(name)) 
+      if (i->second->ContainsDescriptor(name)) 
         {
-          i->second->HelpBlackBox(name,full);
+          i->second->PrintHelpDescriptor(name,full);
              package = i->second->GetName();
           found = true;
         }
@@ -784,14 +785,14 @@ namespace bbtk
   
 
   //===================================================================
-  void Factory::CheckPackages() const
+  void Factory::Check() const
   {
     bbtkMessage("debug",1,"****** Checking Factory "<<(void*)this
                 <<std::endl);
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-       i->second->CheckBoxes();
+       i->second->Check();
       }
     bbtkMessage("debug",1,"****** Checking Factory "<<(void*)this
                <<" ... OK"<<std::endl);
@@ -832,41 +833,41 @@ namespace bbtk
    PackageMapType::const_iterator i;
    for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
    {
-      if (i->second->ContainsBlackBox(name)) 
-      {
+     if (i->second->ContainsDescriptor(name)) 
+       {
          std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
-
-            // Don't pollute the file store with  "temp_dir" directories ...    
+        
+        // Don't pollute the file store with  "temp_dir" directories ...    
          std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
          std::string directory = "\"" + default_doc_dir + separator + "temp_dir"  +separator + "\"";
          std::string filename2 =  default_doc_dir + separator + "temp_dir" + separator + "tmp.html"; 
-
+        
 #if defined(_WIN32)  
-        std::string command("start \"Titre\" /D ");
+        std::string command("start \"Titre\" /D ");
 #else 
-        std::string command("gnome-open ");
+        std::string command("gnome-open ");
 #endif
-        command=command + directory +" tmp.html";
-        FILE *ff;
-        ff=fopen(filename2.c_str(),"w");
-
-        fprintf(ff,"<html><head><title>TMP</title> <script type=\"text/javascript\"> <!--\n");
-        fprintf(ff,"  window.location=\"%s#%s\";\n" , i->second->GetDocURL().c_str(),name.c_str() );
-        fprintf(ff,"//--></script></head><body></body></html>\n");
-
-
-        //fprintf(ff, "<a  href=\"%s#%s\">Link</a>\n", i->second->GetDocURL().c_str(),name.c_str() );
-        fclose(ff);
-        system( command.c_str() );      
-        found = true;
-     }
+        command=command + directory +" tmp.html";
+        FILE *ff;
+        ff=fopen(filename2.c_str(),"w");
+        
+        fprintf(ff,"<html><head><title>TMP</title> <script type=\"text/javascript\"> <!--\n");
+        fprintf(ff,"  window.location=\"%s#%s\";\n" , i->second->GetDocURL().c_str(),name.c_str() );
+        fprintf(ff,"//--></script></head><body></body></html>\n");
+        
+        
+        //fprintf(ff, "<a  href=\"%s#%s\">Link</a>\n", i->second->GetDocURL().c_str(),name.c_str() );
+        fclose(ff);
+        system( command.c_str() );      
+        found = true;
+       }
    }
-    
+   
    bbtkDebugDecTab("kernel",9);
    if (!found) 
    {
-      bbtkError("No package of the factory contains any black box <"
-                <<name<<">");
+     bbtkError("No package of the factory contains any black box <"
+              <<name<<">");
    }
  }
     
@@ -890,9 +891,9 @@ namespace bbtk
       {
        Package::Pointer pack = i->second;
        if (pack->GetName()=="user") continue;
-       Package::BlackBoxMapType::const_iterator j;
-       for (j = pack->GetBlackBoxMap().begin(); 
-            j!= pack->GetBlackBoxMap().end(); 
+       Package::DescriptorMapType::const_iterator j;
+       for (j = pack->GetDescriptorMap().begin(); 
+            j!= pack->GetDescriptorMap().end(); 
             ++j)
          {
            
index a686fa4f9debc5e62513d9ecae06c2da7b839eaf..33d886174ae63564a5bf43dd9fd3d83890fe69da 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkFactory.h,v $
   Language:  C++
-  Date:      $Date: 2008/10/17 08:18:13 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2009/06/08 14:50:03 $
+  Version:   $Revision: 1.17 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -57,21 +57,45 @@ namespace bbtk
   public:
     static Pointer New();
 
-    
+    // @name Packages management
+    //@{
+    /// Pushes back the names of the Package s which are in the Factory
     void GetPackagesList(std::vector<std::string>&);
+    /// Loads a dynamic library which contains a Package 
     void LoadPackage( const std::string& name );
+    /// Unloads a Package which was loaded from a dynamic library
     void UnLoadPackage( const std::string& name );
-    void PrintPackages(bool details = true, bool adaptors = false) const;
-    void HelpPackage(const std::string& name, bool adaptors = false) const;
-    void HelpBlackBox(const std::string& name, std::string& package,
-                     bool full=true ) const;
-    void ShowGraphTypes(const std::string& name) const;
+    /// Inserts a Package in the Factory
     void InsertPackage( Package::Pointer );
+    /// Removess a Package from the Factory
     void RemovePackage( Package::Pointer );
-
+    /// Returns the pointer on a Package provided by name
     Package::Pointer GetPackage(const std::string& name) const;
-
+    /// The type of map of packages
+    typedef std::map< std::string, Package::Pointer > PackageMapType;
+    /// Returns the map of Packages
+    const PackageMapType& GetPackageMap() const { return mPackageMap; }
+    //@}
+
+    // @name Methods which print help
+    //@{
+    /// Prints the list of Package
+    void PrintHelpListPackages(bool details = true, 
+                              bool adaptors = false) const;
+    /// Prints help on a particular Package
+    void PrintHelpPackage(const std::string& name, 
+                         bool adaptors = false) const;
+    /// Prints help on a BlackBoxDescriptor
+    void PrintHelpDescriptor(const std::string& name, 
+                            std::string& package,
+                            bool full=true ) const;
     
+    void ShowGraphTypes(const std::string& name) const;
+    // @}
+
+
+    /// @name Object creation methods
+    //@{
     BlackBox::Pointer NewBlackBox(const std::string& type, 
                           const std::string& name) const;
     
@@ -83,6 +107,15 @@ namespace bbtk
                               const DataInfo& typeout,
                               const std::string& name) const;
 
+    Connection::Pointer NewConnection(BlackBox::Pointer from,
+                                     const std::string& output,
+                                     BlackBox::Pointer to,
+                                     const std::string& input) const;
+   //@}
+
+    /// @name Package inspection methods
+    /// Allow to test if an Adaptor is present in the packages WITHOUT instanciating it
+    //@{
     bool FindAdaptor(const DataInfo& typein,
                     const DataInfo& typeout,
                     std::string& adaptor) const;
@@ -95,17 +128,14 @@ namespace bbtk
                            const DataInfo& typeout,
                            std::string& widget,
                            std::string& adaptor) const;
-
-    Connection::Pointer NewConnection(BlackBox::Pointer from,
-                                     const std::string& output,
-                                     BlackBox::Pointer to,
-                                     const std::string& input) const;
-
+    //@}
+  
     void WriteDotFilePackagesList(FILE *ff);
 
+    /// Releases all the packages of the Factory
     void Reset();
     
-    void CheckPackages() const;
+    void Check() const;
 
     typedef enum
       {
@@ -127,24 +157,16 @@ namespace bbtk
 
   private:
 
-    bool DoLoadPackage(std::string libname,
-                      std::string pkgname,
-                      std::string path);
-
-  public:
 
-    /// The type of map of packages
-    typedef std::map< std::string, Package::Pointer > PackageMapType;
-
-    const PackageMapType& GetPackageMap() const { return mPackageMap; }
-
-  private:
     /// The map of packages
     PackageMapType mPackageMap;
 
     /// The executer which created the factory (if any)
     ExecuterWeakPointer mExecuter;
 
+    bool DoLoadPackage(std::string libname,
+                      std::string pkgname,
+                      std::string path);
     void CloseAllPackages();
     void ClosePackage(PackageMapType::iterator& i);
 
index a9b480f86ae3c3a178c5af19d0a2b107704732d4..8e87d7a4dd0d72222eed7f8549de2ee25639447e 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:06 $
-  Version:   $Revision: 1.85 $
+  Date:      $Date: 2009/06/08 14:50:03 $
+  Version:   $Revision: 1.86 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -1593,7 +1593,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
     {
       if (words[1]=="packages") 
       {
-         GetExecuter()->GetFactory()->PrintPackages(true);
+         GetExecuter()->GetFactory()->PrintHelpListPackages(true);
          return;
       }
       try 
@@ -1604,7 +1604,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
       {
          try 
          {
-            GetExecuter()->GetFactory()->HelpPackage(words[1]);
+            GetExecuter()->GetFactory()->PrintHelpPackage(words[1]);
            if ( mUser != 0 )
              {
                std::string url = 
@@ -1621,7 +1621,8 @@ void Interpreter::Help(const std::vector<std::string>& words)
           try 
             {
               std::string package;
-              GetExecuter()->GetFactory()->HelpBlackBox(words[1],package);
+              GetExecuter()->GetFactory()->PrintHelpDescriptor(words[1],
+                                                               package);
               if ( mUser != 0 )
                 {
                   std::string url = 
@@ -1638,7 +1639,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
             {
               try
                 {
-                  GetExecuter()->ShowRelations(words[1],"0","9999");
+                  GetExecuter()->PrintHelpBlackBox(words[1],"0","9999");
                 }
               catch (bbtk::Exception h){
                 bbtkError("\""<<words[1].c_str()
@@ -1654,12 +1655,12 @@ void Interpreter::Help(const std::vector<std::string>& words)
       {
          if ( words[1]=="packages" )
          {
-            GetExecuter()->GetFactory()->PrintPackages(true,true);
+            GetExecuter()->GetFactory()->PrintHelpListPackages(true,true);
             return;
           }
          try 
          {
-            GetExecuter()->GetFactory()->HelpPackage(words[1],true);
+            GetExecuter()->GetFactory()->PrintHelpPackage(words[1],true);
          }
          catch (bbtk::Exception f) 
          {
@@ -2274,7 +2275,7 @@ void  Interpreter::NewGUI(const std::string& boxname,
          {
            //      int o = MessageManager::GetMessageLevel("debug");
            //      if (o<2) MessageManager::SetMessageLevel("debug",2);
-           mVirtualExecuter->GetFactory()->CheckPackages();
+           mVirtualExecuter->GetFactory()->Check();
            //      MessageManager::SetMessageLevel("debug",o);
          }
       }
index ebd5ddf7ad1ae4112d8a70b396b96544faeb3bc0..05d5d1f5fa3f9b5bb1e161648039e51c3185a1d9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkPackage.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 14:22:10 $
-  Version:   $Revision: 1.29 $
+  Date:      $Date: 2009/06/08 14:50:04 $
+  Version:   $Revision: 1.30 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -118,49 +118,49 @@ namespace bbtk
 
 
   //==========================================================================
-         void PackageReleaseBlackBoxDescriptorInternal(Package::WeakPointer pack,
-                                                       const std::string& descname)
-         {
-               // Try to release descriptor
-               std::string packname = pack.lock()->GetName();
-
-               bbtkDebugMessage("package",5,"--- Releasing descriptor '"
-                                <<packname<<"::"<<descname<<"'"<<bbtkendl);
-
-
-               Package::BlackBoxMapType::iterator desc = 
-                 pack.lock()->GetBlackBoxMap().find(descname);
-               if (desc ==  pack.lock()->GetBlackBoxMap().end())
-                 {
-               bbtkDebugMessage("package",5,
-                                "    Descriptor has already been released"
+  void PackageReleaseBlackBoxDescriptorInternal(Package::WeakPointer pack,
+                                               const std::string& descname)
+  {
+    // Try to release descriptor
+    std::string packname = pack.lock()->GetName();
+    
+    bbtkDebugMessage("package",5,"--- Releasing descriptor '"
+                    <<packname<<"::"<<descname<<"'"<<bbtkendl);
+    
+    
+    Package::DescriptorMapType::iterator desc = 
+      pack.lock()->GetDescriptorMap().find(descname);
+    if (desc ==  pack.lock()->GetDescriptorMap().end())
+      {
+       bbtkDebugMessage("package",5,
+                        "    Descriptor has already been released"
                                 <<bbtkendl);
-               return;
+       return;
                  }
-               //    bbtkDebugMessage("package",3,
-               //                   "    Trying unreferencing it ... "<<std::endl);
-               BlackBoxDescriptor::WeakPointer pdesc = desc->second;
-               desc->second.reset();
-               // if it is dead : remove it 
-               if (pdesc.expired()) 
-               {
-                 bbtkDebugMessage("package",2," ==> '"<<packname<<"::"<<descname<<"' Descriptor expired"<<bbtkendl);
-                 if (pack.expired()) 
-                 {
-                       bbtkDebugMessage("package",2,
+    //    bbtkDebugMessage("package",3,
+    //              "    Trying unreferencing it ... "<<std::endl);
+    BlackBoxDescriptor::WeakPointer pdesc = desc->second;
+    desc->second.reset();
+    // if it is dead : remove it 
+    if (pdesc.expired()) 
+      {
+       bbtkDebugMessage("package",2," ==> '"<<packname<<"::"<<descname<<"' Descriptor expired"<<bbtkendl);
+       if (pack.expired()) 
+         {
+           bbtkDebugMessage("package",2,
                                         "     ... and caused its package death"
-                                        <<bbtkendl);
-                       return;
-                 } // pack.expired
-                 desc = pack.lock()->GetBlackBoxMap().find(descname);
-                 if (desc !=  pack.lock()->GetBlackBoxMap().end())       pack.lock()->GetBlackBoxMap().erase(desc);
-               }   else    {  //pdesc.expired
-                    bbtkDebugMessage("package",5,"    ... Descriptor still alive ("
-                                <<pdesc.use_count()<<" refs)"
-                                <<bbtkendl);
-                    pack.lock()->GetBlackBoxMap()[descname] = pdesc.lock();
-               } // pdesc.expired
-         }
+                            <<bbtkendl);
+           return;
+         } // pack.expired
+       desc = pack.lock()->GetDescriptorMap().find(descname);
+       if (desc !=  pack.lock()->GetDescriptorMap().end())       pack.lock()->GetDescriptorMap().erase(desc);
+      }   else    {  //pdesc.expired
+      bbtkDebugMessage("package",5,"    ... Descriptor still alive ("
+                      <<pdesc.use_count()<<" refs)"
+                      <<bbtkendl);
+      pack.lock()->GetDescriptorMap()[descname] = pdesc.lock();
+    } // pdesc.expired
+  }
   //==========================================================================
 
 
@@ -173,7 +173,7 @@ namespace bbtk
                     packname<<"')"<<bbtkendl);
 
     long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
-    long ndesc = pack.lock()->GetBlackBoxMap().size();
+    long ndesc = pack.lock()->GetDescriptorMap().size();
     long nrefs = pack.use_count();
 
     bbtkDebugMessage("package",5," "<<nrefs<<" refs / "
@@ -207,9 +207,9 @@ namespace bbtk
 
        // The list of descriptors names at start
        std::vector<std::string> descnamelist;
-       BlackBoxMapType::iterator i;
-       for (i=pack.lock()->mBlackBoxMap.begin();
-            i!= pack.lock()->mBlackBoxMap.end();
+       DescriptorMapType::iterator i;
+       for (i=pack.lock()->mDescriptorMap.begin();
+            i!= pack.lock()->mDescriptorMap.end();
             ++i)
          descnamelist.push_back(i->first);
 
@@ -229,7 +229,7 @@ namespace bbtk
              }
            
 #if defined(MACOSX)
-                 BlackBoxDescriptor::Pointer desc = pack.lock()->mBlackBoxMap[*descname];
+                 BlackBoxDescriptor::Pointer desc = pack.lock()->mDescriptorMap[*descname];
                  if ( (dyn==0) || (boost::dynamic_pointer_cast<ComplexBlackBoxDescriptor>(desc)) )
                          PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
 #else
@@ -256,7 +256,7 @@ namespace bbtk
     if (!pack.expired())
       {
        long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
-       long ndesc = pack.lock()->GetBlackBoxMap().size();
+       long ndesc = pack.lock()->GetDescriptorMap().size();
        long nrefs = pack.use_count();
        
        bbtkDebugMessage("package",1," ... Package still alive ("
@@ -289,7 +289,7 @@ namespace bbtk
                     <<descr.use_count()<<bbtkendl);
 
     long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
-    long ndesc = pack.lock()->GetBlackBoxMap().size();
+    long ndesc = pack.lock()->GetDescriptorMap().size();
     long nrefs = pack.use_count();
 
     bbtkDebugMessage("package",5," "<<nrefs<<" refs / "
@@ -325,7 +325,7 @@ namespace bbtk
     if (!pack.expired())
       {
        long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
-       long ndesc = pack.lock()->GetBlackBoxMap().size();
+       long ndesc = pack.lock()->GetDescriptorMap().size();
        long nrefs = pack.use_count();
        
        bbtkDebugMessage("package",3," ... Package still alive ("
@@ -582,7 +582,7 @@ namespace bbtk
                     <<packname<<"')"
                     <<std::endl);
     
-    if (!pack.lock()->GetBlackBoxMap().empty())
+    if (!pack.lock()->GetDescriptorMap().empty())
       {
        
        bbtkDebugMessage("package",5,"   Package not empty ... abort"
@@ -590,7 +590,7 @@ namespace bbtk
        return;
        /*
        bbtkGlobalError("Package::UnLoadDynamicLibrary('"<<packname<<") : "
-                       <<"BlackBoxMap not empty "
+                       <<"DescriptorMap not empty "
                        <<BBTK_INTERNAL_ERROR_MESSAGE);
        */
        
@@ -689,8 +689,8 @@ namespace bbtk
   {
     bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::NewBlackBox(\""<<type<<"\",\""<<name<<"\")"<<bbtkendl);
     
-    BlackBoxMapType::const_iterator i = mBlackBoxMap.find(type);
-    if (i == mBlackBoxMap.end())  
+    DescriptorMapType::const_iterator i = mDescriptorMap.find(type);
+    if (i == mDescriptorMap.end())  
     {
           bbtkDebugDecTab("kernel",8);
           return BlackBox::Pointer();
@@ -828,26 +828,26 @@ namespace bbtk
 
   //==========================================================================
   /// Registers a black box descriptor in the package
-  bool Package::RegisterBlackBox(BlackBoxDescriptor::Pointer d) 
+  bool Package::Register(BlackBoxDescriptor::Pointer d) 
   {
-    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::Register(\""<<d->GetTypeName()<<"\")"<<std::endl);
     
-    BlackBoxMapType::iterator i = mBlackBoxMap.find(d->GetTypeName());
-    if (i!=mBlackBoxMap.end())
+    DescriptorMapType::iterator i = mDescriptorMap.find(d->GetTypeName());
+    if (i!=mDescriptorMap.end())
       {
        bbtkWarning("Package<"<<GetName()<<"> : Trying to register box type <"
                    <<d->GetTypeName()<<"> which is already in the package");
        return false;
       }
 
-    mBlackBoxMap[d->GetTypeName()] = d;
+    mDescriptorMap[d->GetTypeName()] = d;
     //    d->Reference();
     d->SetPackage(GetThisPointer<Package>());
     
     // If it is a default adaptor, also register it in the adaptors map
     if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR )
       {
-       bbtkDebugMessage("kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\") : The box is an adaptor, inserting it in adaptors map ..."<<std::endl);   
+       bbtkDebugMessage("kernel",8,"Package<"<<GetName()<<">::Register(\""<<d->GetTypeName()<<"\") : The box is an adaptor, inserting it in adaptors map ..."<<std::endl);   
        
        TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
        TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
@@ -877,7 +877,7 @@ namespace bbtk
     // If it is a default adaptor, also register it in the adaptors map
     else if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_GUI)
       {
-       bbtkDebugMessage("kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\") : The box is a widget adaptor, inserting it in adaptors map ..."<<std::endl);   
+       bbtkDebugMessage("kernel",8,"Package<"<<GetName()<<">::Register(\""<<d->GetTypeName()<<"\") : The box is a widget adaptor, inserting it in adaptors map ..."<<std::endl);   
        
        TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
        DataInfo infoin(typeid(void),"");
@@ -912,13 +912,13 @@ namespace bbtk
   //==========================================================================
   
   //===================================================================
-  void Package::CheckBoxes() const
+  void Package::Check() const
   {
     bbtkMessage("debug",1,"****** Checking Package "<<(void*)this
                <<" ["<<GetName()<<"]"<<std::endl);
-    BlackBoxMapType::const_iterator i;
-    for (i=mBlackBoxMap.begin();
-        i!=mBlackBoxMap.end();
+    DescriptorMapType::const_iterator i;
+    for (i=mDescriptorMap.begin();
+        i!=mDescriptorMap.end();
         ++i) 
       {
        i->second->Check(true);
@@ -931,20 +931,22 @@ namespace bbtk
 
   //==========================================================================
   /// Changes the name of a black box type
-  void Package::ChangeBlackBoxName( const std::string& oldname, const std::string& newname )
+  void Package::ChangeDescriptorName( const std::string& oldname, const std::string& newname )
   { 
-    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::ChangeBlackBoxName(\""<<oldname<<"\",\""<<newname<<"\")"<<std::endl);
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()
+                       <<">::ChangeDescriptorName(\""<<oldname
+                       <<"\",\""<<newname<<"\")"<<std::endl);
     // Looking into the bb map
-    BlackBoxMapType::iterator i = mBlackBoxMap.find(oldname);
-    if (i == mBlackBoxMap.end())  
+    DescriptorMapType::iterator i = mDescriptorMap.find(oldname);
+    if (i == mDescriptorMap.end())  
       {
          bbtkDebugDecTab("kernel",8);
-         bbtkError("ChangeBlackBoxName : The package <"<<GetName()<<"> does not contains the black box <"<<oldname<<">");
+         bbtkError("ChangeDescriptorName : The package <"<<GetName()<<"> does not contains the black box <"<<oldname<<">");
       }
 
     i->second->SetTypeName(newname);
-    mBlackBoxMap[newname] = i->second;
-    mBlackBoxMap.erase(i);
+    mDescriptorMap[newname] = i->second;
+    mDescriptorMap.erase(i);
 
     bbtkDebugDecTab("kernel",8);    
   }
@@ -953,17 +955,16 @@ namespace bbtk
 
 
   //==========================================================================
-  /// Displays the list of black boxes of the package
-  void Package::PrintBlackBoxes(bool description, bool adaptors) const
+  void Package::PrintHelpListDescriptors(bool description, bool adaptors) const
   {
     unsigned int lmax = 0;
     std::vector<std::string> names;
     std::vector<std::string> kinds;
     std::vector<std::string> descrs;
 
-    BlackBoxMapType::const_iterator i;
-    for (i=mBlackBoxMap.begin();
-        i!=mBlackBoxMap.end();
+    DescriptorMapType::const_iterator i;
+    for (i=mDescriptorMap.begin();
+        i!=mDescriptorMap.end();
         ++i) 
       {
        if ( adaptors || 
@@ -1025,11 +1026,11 @@ namespace bbtk
 
   //==========================================================================
   /// Displays the list of adaptors of the package
-  void Package::PrintAdaptors(bool description) const
+  void Package::PrintHelpListAdaptors(bool description) const
   {
-    BlackBoxMapType::const_iterator i;
-    for (i=mBlackBoxMap.begin();
-        i!=mBlackBoxMap.end();
+    DescriptorMapType::const_iterator i;
+    for (i=mDescriptorMap.begin();
+        i!=mDescriptorMap.end();
         ++i) 
       {
        if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD ) 
@@ -1072,14 +1073,15 @@ namespace bbtk
   //==========================================================================
 
   //==========================================================================
-  /// Prints help on a black box
-  void Package::HelpBlackBox(const std::string& name, bool full) const
+  /// Prints help on a black box descriptor
+  void Package::PrintHelpDescriptor(const std::string& name, bool full) const
   {
-    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()
+                       <<">::PrintHelpDescriptor(\""
                        <<name<<"\")"<<bbtkendl);
 
-    BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
-    if (i == mBlackBoxMap.end())  
+    DescriptorMapType::const_iterator i = mDescriptorMap.find(name);
+    if (i == mDescriptorMap.end())  
       {
        bbtkDebugDecTab("kernel",8);
        bbtkError("The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
@@ -1094,13 +1096,14 @@ namespace bbtk
 
   //==========================================================================
   /// Returns true iff the package contains the box of name boxname
-  bool Package::ContainsBlackBox(const std::string& name) const 
+  bool Package::ContainsDescriptor(const std::string& name) const 
   {
-    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()
+                       <<">::ContainsDescriptor(\""
                        <<name<<"\")"<<bbtkendl);
     
-    BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
-    if (i == mBlackBoxMap.end())  
+    DescriptorMapType::const_iterator i = mDescriptorMap.find(name);
+    if (i == mDescriptorMap.end())  
     {
       bbtkDebugDecTab("kernel",8);
       return false;
@@ -1225,8 +1228,8 @@ namespace bbtk
 
     s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
 
-    BlackBoxMapType::const_iterator i;
-    for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i) 
+    DescriptorMapType::const_iterator i;
+    for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i) 
       {
        if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD) 
          continue;
@@ -1259,9 +1262,9 @@ namespace bbtk
        s << "<p><b> Adaptors : </b>\n";
        s << "<ul>\n";
 
-       //    BlackBoxMapType::const_iterator i;
+       //    DescriptorMapType::const_iterator i;
        s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
-       for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end();++i) 
+       for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end();++i) 
          {
            if ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) 
              continue;
@@ -1313,8 +1316,8 @@ namespace bbtk
       dir = filename.substr(0,slash_position);
     }
 
-    for (i=mBlackBoxMap.begin();
-        i!=mBlackBoxMap.end();
+    for (i=mDescriptorMap.begin();
+        i!=mDescriptorMap.end();
         ++i) 
       {
        i->second->InsertHtmlHelp(s,detail,level,dir,relative_link);
@@ -1353,7 +1356,7 @@ namespace bbtk
   std::string Package::GetObjectInfo() const 
   {
     std::stringstream i;
-    i << "  - "<<mBlackBoxMap.size() << " boxes" << std::endl;
+    i << "  - "<<mDescriptorMap.size() << " boxes" << std::endl;
     if (mDynamicLibraryHandler) 
       {
        i<< "  - Loaded from dynamic library"<<std::endl;
@@ -1384,8 +1387,8 @@ namespace bbtk
     size_t s = Superclass::GetObjectRecursiveSize();
     s += Package::GetObjectInternalSize();
     
-    BlackBoxMapType::const_iterator i;
-    for (i = mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i )
+    DescriptorMapType::const_iterator i;
+    for (i = mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i )
       {
        s += i->second->GetObjectRecursiveSize();
       }
index 4b8d649f19ec5b1ddae40bc8a6402c05108946c9..419f3fea752e3e2b4e6ef6afe055e1e6f3d5810f 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkPackage.h,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:26:59 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2009/06/08 14:50:04 $
+  Version:   $Revision: 1.15 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -92,6 +92,11 @@ namespace bbtk
     /// if it is no more used (released)
     /// Note : Any non-weak pointer on the package must have been freed
     static void Release(Package::WeakPointer p);
+
+
+    /// Registers the BlackBoxDescriptor in the Package
+    bool Register(BlackBoxDescriptor::Pointer); 
+
     /// "Releases" a black box descriptor
     /// Signals the package that it can free the given descriptor
     /// if it is no more used and frees and put it the the 
@@ -135,33 +140,44 @@ namespace bbtk
     /// Returns the version of the package
     const std::string& GetVersion() const { return mVersion; }
 
-       bool ContainsBlackBox(const std::string& boxname) const;
+    /// Returns true iff the package contains a BlackBoxDescriptor
+    /// with the name provided
+    bool ContainsDescriptor(const std::string& name) const;
 
+    /// Creates a new BlackBox of given type with name name
     BlackBox::Pointer NewBlackBox(const std::string& type,
                             const std::string& name) const;
-  
+    
+    /// Creates a new adaptor BlackBox for the given input and output types 
+    /// with name name
     BlackBox::Pointer NewAdaptor(const DataInfo& typein,
-                        const DataInfo& typeout,
-                        const std::string& name) const;
+                                const DataInfo& typeout,
+                                const std::string& name) const;
     
+    /// Creates a new widget adaptor BlackBox 
+    /// for the given input and output types 
+    /// with name name
     BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein,
-                             const DataInfo& typeout,
-                             const std::string& name) const;
+                                      const DataInfo& typeout,
+                                      const std::string& name) const;
     bool FindAdaptor(const DataInfo& typein,
-                          const DataInfo& typeout,
-                          std::string& adaptor) const;
+                    const DataInfo& typeout,
+                    std::string& adaptor) const;
     bool FindWidgetAdaptor(const DataInfo& typein,
                           const DataInfo& typeout,
                           std::string& adaptor) const;
 
-    bool RegisterBlackBox(BlackBoxDescriptor::Pointer); 
 
-    void PrintBlackBoxes(bool description = false, 
-                        bool adaptors = false) const;
-    void PrintAdaptors(bool description = false) const;
-    void HelpBlackBox(const std::string& name, bool full=true) const;
+    /// Displays the list of black box descriptors of the package    
+    void PrintHelpListDescriptors(bool description = false, 
+                             bool adaptors = false) const;
+    /// Displays the list of adaptors of the package
+    void PrintHelpListAdaptors(bool description = false) const;
+    /// Prints help on a particular Descriptor
+    void PrintHelpDescriptor(const std::string& name, bool full=true) const;
     
+
+
     void CreateHtmlPage(const std::string& filename,
                        const std::string& caller = "?",
                        const std::string& source = "?",
@@ -178,16 +194,16 @@ namespace bbtk
     const std::string& GetDocRelativeURL() const { return mDocRelativeURL; }
 
 
-    unsigned int GetNumberOfBlackBoxes() const { return mBlackBoxMap.size(); }
+    unsigned int GetNumberOfDescriptors() const { return mDescriptorMap.size(); }
     
-    /// Changes the name of a black box type
-    void ChangeBlackBoxName( const std::string& oldname, 
-                            const std::string& newname );
+    /// Changes the name of a descriptor
+    void ChangeDescriptorName( const std::string& oldname, 
+                              const std::string& newname );
     /// The type of map of descriptors
     typedef std::map< std::string, BlackBoxDescriptor::Pointer> 
-    BlackBoxMapType;
-    const BlackBoxMapType& GetBlackBoxMap() const { return mBlackBoxMap; }
-    BlackBoxMapType& GetBlackBoxMap() { return mBlackBoxMap; }
+    DescriptorMapType;
+    const DescriptorMapType& GetDescriptorMap() const { return mDescriptorMap; }
+    DescriptorMapType& GetDescriptorMap() { return mDescriptorMap; }
 
     /// The type of key in the map of adaptor descriptors
     class AdaptorKey 
@@ -237,7 +253,7 @@ namespace bbtk
     /// Gets the set of factories which use the package (const)
     const FactorySet& GetFactorySet() const { return mFactorySet; }
     
-    void CheckBoxes() const;
+    void Check() const;
 
   private:
     /// Default ctor is private : use the static New method
@@ -276,7 +292,7 @@ namespace bbtk
     std::string mDocRelativeURL;
 
     /// The map of black boxes descriptors
-    BlackBoxMapType mBlackBoxMap;
+    DescriptorMapType mDescriptorMap;
 
     /// The map of adaptors descriptors
     AdaptorMapType mAdaptorMap;
@@ -375,19 +391,19 @@ namespace bbtk
 //====================================================================
 #define BBTK_ADD_BLACK_BOX_TO_PACKAGE(NAME,CLASS)                      \
   bool bbDummy##NAME##CLASS = NAME ## GetPackage ()    \
-    ->RegisterBlackBox(CLASS ## Descriptor::Instance());
+    ->Register(CLASS ## Descriptor::Instance());
   //====================================================================
   
   //====================================================================
 #define BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(NAME,CLASS,TEMPLATE_PARAM) \
   bool bbDummy##NAME##CLASS##TEMPLATE_PARAM = NAME ## GetPackage ()    \
-    ->RegisterBlackBox(CLASS ## Descriptor <TEMPLATE_PARAM>::Instance());
+    ->Register(CLASS ## Descriptor <TEMPLATE_PARAM>::Instance());
   //====================================================================
   
   //====================================================================
 #define BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(NAME,CLASS,T1,T2)      \
   bool bbDummy##NAME##CLASS##T1##T2 = NAME ## GetPackage ()            \
-    ->RegisterBlackBox(CLASS ## Descriptor <T1,T2>::Instance()); 
+    ->Register(CLASS ## Descriptor <T1,T2>::Instance()); 
   //====================================================================
   
 
diff --git a/kernel/src/bbtkQtBlackBoxDialogParent.h b/kernel/src/bbtkQtBlackBoxDialogParent.h
deleted file mode 100644 (file)
index 95f5a87..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <QDialog>
-
-namespace bbtk
-{
-  class QtBlackBoxDialogParent : public WidgetBlackBoxWindow<QWidget>, 
-                                public QDialog
-  {
-  public:
-    QtBlackBoxDialogParent(QtBlackBox::Pointer box,
-                    QWidget *parent)
-      :
-      WidgetBlackBoxWindow<QWidget>(box),
-      QDialog( parent )
-    {
-      
-    }
-
-  };
-
-}
index 740dcb9aecd02285ae71d52c59249dbb44dffe32..cef7b64465d0591122c997136681beba09597a0b 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkSystem.h,v $
   Language:  C++
-  Date:      $Date: 2009/05/25 12:48:57 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2009/06/08 14:50:04 $
+  Version:   $Revision: 1.14 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -246,3 +246,14 @@ namespace bbtk
 #ifdef _MSC_VER
 # define access _access
 #endif
+
+
+
+
+//===========================================================
+// Define the groups (modules) for doxygen documentation
+/**
+ * \defgroup box Black boxes related classes
+ * \defgroup interface Graphical User Interface components
+ * \defgroup data Data
+*/
index 69e3456ed7be3e5dab3ed473d4be6b52d9cd1742..9f73066f63de092df64f7ab711d4399837e2851f 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkTranscriptor.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:06 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2009/06/08 14:50:04 $
+  Version:   $Revision: 1.17 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -269,7 +269,7 @@ namespace bbtk
   }
 
   /// prints the list of the boxes of the current descriptor
-  void Transcriptor::PrintBoxes()
+  void Transcriptor::PrintHelpListBoxes()
   {
      m_Fp << "  e->PrintBoxes( );" << std::endl;
  }
@@ -301,7 +301,7 @@ namespace bbtk
   
   }
 
-void Transcriptor::ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr)
+void Transcriptor::PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr)
   {
      
   }
index dba498ba9f91b2e4d3673b1e35141de8efa2d491..ca0a54729c306bb5210f96640d1f8658d5ec79a2 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkTranscriptor.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/12 12:11:21 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2009/06/08 14:50:04 $
+  Version:   $Revision: 1.14 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -165,7 +165,7 @@ namespace bbtk
     void Description(const std::string & d);
 
     /// prints the list off the boxes of the current box
-    void PrintBoxes();
+    void PrintHelpListBoxes();
 
    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
     std::string ShowGraph(const std::string &nameblackbox, 
@@ -179,8 +179,8 @@ namespace bbtk
    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
     std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
 
-   /// Description of the actual pipeline
-      void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
+    /// Prints help on a black box
+    void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
 
       void Reset();
  
index d09ed5aeb4c6a95f816f21599add33f64e09e45a..73010f242481c732f1ca237a09115583ccdf104d 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkVirtualExec.h,v $
   Language:  C++
-  Date:      $Date: 2008/12/12 12:11:21 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2009/06/08 14:50:04 $
+  Version:   $Revision: 1.19 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -172,10 +172,10 @@ namespace bbtk
     /// The description string which explains what does the ComplexBox
     virtual void Description(const std::string &d) = 0;
 
-    /// prints the list off the boxes of the current box
-    virtual void PrintBoxes() = 0;
+    /// prints the list of the boxes of the current box
+    virtual void PrintHelpListBoxes() = 0;
 
-   /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
+   /// Generate a HTML file with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
     virtual std::string ShowGraph(const std::string &nameblackbox, 
                          const std::string &detailStr, 
                          const std::string &levelStr,
@@ -187,8 +187,8 @@ namespace bbtk
    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
     virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0;
 
-    /// Description of the actual pipeline
-    virtual void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
+    /// Prints help on a black box
+    virtual void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
     
     virtual void Reset() = 0;
     
index 20dc069fae3d79f174516989aea5db71bb3420d3..fc09745b15c65bbac6c951ddf2882477c7473664 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWidgetBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:06 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2009/06/08 14:50:04 $
+  Version:   $Revision: 1.5 $
 ========================================================================*/
 
 
@@ -94,7 +94,6 @@ namespace bbtk
     bool bbIsOutputWidgetConnected();
 
     //==================================================================    
-    void bbSetShown(bool);
     bool bbIsShown();
     //==================================================================    
  
@@ -111,7 +110,7 @@ namespace bbtk
          
   protected:
     
-  
+    void bbSetShown(bool);
 
     //==================================================================
     /// Convenient method for layout widgets which creates and returns
index 00a8c099c2c623e869ebf57977fd7c05f64ed0c4..1593d3d320f29c7fde35f1ea6173e65391472c4d 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/02/11 11:35:20 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2009/06/08 14:50:04 $
+  Version:   $Revision: 1.13 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -992,9 +992,9 @@ namespace bbtk
        Package::Pointer P = i->second;
        if (P->GetName() == "user") continue;
        
-       Package::BlackBoxMapType::iterator j;
-       for (j=P->GetBlackBoxMap().begin();
-            j!=P->GetBlackBoxMap().end();
+       Package::DescriptorMapType::iterator j;
+       for (j=P->GetDescriptorMap().begin();
+            j!=P->GetDescriptorMap().end();
             ++j)
          {
            //      std::cout << "Insert "<<j->second->GetTypeName()<<std::endl;
index 16d7c975b53e7f0990911053b9c48e4e3f141afa..0bebe536f148a40e4609039c0e5cff862626e122 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbstdMagicBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/14 14:43:38 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2009/06/08 14:50:06 $
+  Version:   $Revision: 1.8 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -37,29 +37,9 @@ using namespace bbtk;
 namespace bbstd
 {
 
-  void MagicBox::bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c,
-                                        bbtk::IOStatus s)
-  {
-    bbtkDebugMessageInc("change",5,
-                       "=> MagicBox::bbSetStatusAndPropagate(input,"
-                       <<GetIOStatusString(s)<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-   if (mCanSet)
-      {
-       if (c->IsConnected())
-         {
-           std::string do_input = c->GetConnection()->GetBlackBoxToInput();
-           c->GetConnection()->TransferData();
-           bbSetOutputOut( bbGetInput(do_input) );     
-         }
-       mCanSet = false;
-      }
-   BlackBox::bbSetStatusAndPropagate(c,s);
-  }
 
   void MagicBox::bbUserSetDefaultValues()
   {
-    mCanSet = true;
   }
   void MagicBox::bbUserInitializeProcessing() 
   { 
@@ -69,7 +49,7 @@ namespace bbstd
   }
   void MagicBox::DoProcess()
   { 
-    mCanSet = true;
+    bbSetOutputOut( bbGetInputIn() );
   }
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MagicBox);
index ec5a16966850b9784203a82deb465682adc97edc..4f0bebe06f61353be8b87c4856afb0b3fbc49b72 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbstdMagicBox.h,v $
   Language:  C++
-  Date:      $Date: 2009/05/14 14:43:38 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2009/06/08 14:50:06 $
+  Version:   $Revision: 1.13 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 
 namespace bbstd
 {
-#define BBTK_MB_DECLARE_INPUT(NAME,TYPE)                               \
-  protected:                                                           \
-  TYPE bbmInput##NAME;                                                 \
-public:                                                                        \
-  TYPE bbGetInput##NAME ()                                             \
-  { return bbmInput##NAME; }                                           \
-    void bbSetInput##NAME (TYPE d)                                     \
-    { bbmInput##NAME = d;                                              \
-      if (mCanSet) { bbSetOutputOut(d); mCanSet = false; } }                           
 
   //==================================================================
   class bbstd_EXPORT MagicBox
@@ -53,28 +44,13 @@ public:                                                                     \
     public bbtk::AtomicBlackBox
   {
     BBTK_BLACK_BOX_INTERFACE(MagicBox,bbtk::AtomicBlackBox);
-    BBTK_MB_DECLARE_INPUT(In,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In1,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In2,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In3,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In4,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In5,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In6,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In7,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In8,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In9,bbtk::Data);
+    BBTK_DECLARE_INPUT(In,bbtk::Data);
     BBTK_DECLARE_OUTPUT(Out,bbtk::Data);
     BBTK_PROCESS(DoProcess);
     void DoProcess();
-  protected:
-    //    virtual void bbUserConstructor();
-    virtual void bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c,
-                                        bbtk::IOStatus s);
-    bool mCanSet;
  };
   //==================================================================
   
-#undef BBTK_MB_DECLARE_INPUT  
 
   //==================================================================
   // We have to create a particular SetFunctor for MagicBox because
@@ -117,33 +93,14 @@ public:                                                                    \
   };
   //===========================================================================
   
-#define MAGIC_BOX_INPUT(NAME)                                          \
-  AddInputDescriptor                                                   \
-  (new bbtk::AtomicBlackBoxInputDescriptor                             \
-   (typeid(MagicBoxDescriptor),                                                \
-    #NAME,"Input data","",                                             \
-    new bbtk::AtomicBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data>        \
-    (&MagicBox::bbGetInput ## NAME),                                   \
-    new MagicBoxSetFunctor (&MagicBox::bbSetInput ## NAME) ) );                
 
   //===========================================================================
   BBTK_BEGIN_DESCRIBE_BLACK_BOX(MagicBox,bbtk::AtomicBlackBox);
   BBTK_NAME("MagicBox");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_CATEGORY("misc");
-  BBTK_DESCRIPTION("Takes *any kind* of data and copies it to its output. Is a magic box as any box output can be plugged into it and its output can be plugged into any other box input (dynamic type checking, see below), hence it can be put between **any** two boxes. Type matching between its output and the input of the box(es) to which it is connected is made at *run-time*. The pipeline will be executed if the data types : i) match exactly ii) can be transformed by an adaptor iii) are related pointers, i.e. if the output pointer can be upcasted (static_cast) or downcasted (dynamic_cast) to an input type pointer (see the bbtk::any output connection rule in the guide for details). Important uses of the MagicBox are : 1) performing run-time pointer cast, either upward or backward an object hierarchy 2) perform data adaptation (adaptor creation) at run-time vs. pipeline creation time. Any has now 9 more inputs and the value of the output is the value of the lower index input which has changed. This functionality is used to implement a memory which can be written by different boxes. The current value of the memory (the output) is that of the last input which has changed, i.e. has 'written' the memory. It is used for example for synchronization issues between boxes.");
-  MAGIC_BOX_INPUT(In)  
-  MAGIC_BOX_INPUT(In1) 
-  MAGIC_BOX_INPUT(In2) 
-  MAGIC_BOX_INPUT(In3) 
-  MAGIC_BOX_INPUT(In4) 
-  MAGIC_BOX_INPUT(In5) 
-  MAGIC_BOX_INPUT(In6) 
-  MAGIC_BOX_INPUT(In7) 
-  MAGIC_BOX_INPUT(In8) 
-  MAGIC_BOX_INPUT(In9) 
-
- /*
+  BBTK_DESCRIPTION("Takes *any kind* of data and copies it to its output. Is a magic box as any box output can be plugged into it and its output can be plugged into any other box input (dynamic type checking, see below), hence it can be put between **any** two boxes. Type matching between its output and the input of the box(es) to which it is connected is made at *run-time*. The pipeline will be executed if the data types : i) match exactly ii) can be transformed by an adaptor iii) are related pointers, i.e. if the output pointer can be upcasted (static_cast) or downcasted (dynamic_cast) to an input type pointer (see the bbtk::any output connection rule in the guide for details). Important uses of the MagicBox are : 1) performing run-time pointer cast, either upward or backward an object hierarchy 2) perform data adaptation (adaptor creation) at run-time vs. pipeline creation time.");
  AddInputDescriptor
   (new bbtk::AtomicBlackBoxInputDescriptor
    (typeid(MagicBoxDescriptor),
@@ -151,7 +108,7 @@ public:                                                                     \
     new bbtk::AtomicBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data>
     (&MagicBox::bbGetInputIn),
     new MagicBoxSetFunctor (&MagicBox::bbSetInputIn) ) );
- */
+
   AddOutputDescriptor
   (new bbtk::AtomicBlackBoxOutputDescriptor
    (typeid(MagicBoxDescriptor),
diff --git a/packages/std/src/bbstdSharedMemory.cxx b/packages/std/src/bbstdSharedMemory.cxx
new file mode 100644 (file)
index 0000000..778e4c1
--- /dev/null
@@ -0,0 +1,86 @@
+/*=========================================================================                                                                               
+  Program:   bbtk
+  Module:    $RCSfile: bbstdSharedMemory.cxx,v $
+  Language:  C++
+  Date:      $Date: 2009/06/08 14:50:06 $
+  Version:   $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+*  This software is governed by the CeCILL-B license under French law and 
+*  abiding by the rules of distribution of free software. You can  use, 
+*  modify and/ or redistribute the software under the terms of the CeCILL-B 
+*  license as circulated by CEA, CNRS and INRIA at the following URL 
+*  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
+*  or in the file LICENSE.txt.
+*
+*  As a counterpart to the access to the source code and  rights to copy,
+*  modify and redistribute granted by the license, users are provided only
+*  with a limited warranty  and the software's author,  the holder of the
+*  economic rights,  and the successive licensors  have only  limited
+*  liability. 
+*
+*  The fact that you are presently reading this means that you have had
+*  knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */                                                                         
+
+
+#include "bbstdSharedMemory.h"
+#include "bbstdPackage.h"
+#include "bbtkBlackBoxOutputConnector.h"
+using namespace bbtk;
+
+namespace bbstd
+{
+
+  void SharedMemory::bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c,
+                                        bbtk::IOStatus s)
+  {
+    bbtkDebugMessageInc("change",5,
+                       "=> SharedMemory::bbSetStatusAndPropagate(input,"
+                       <<GetIOStatusString(s)<<") ["
+                       <<bbGetFullName()<<"]"<<std::endl);
+   if (mCanSet)
+      {
+       bbtkDebugMessageInc("change",5,"Memory writable"<<std::endl);
+       if (c->IsConnected())
+         {
+           bbtkDebugMessageInc("change",5,"Input connected"<<std::endl);
+           // Transfer the data from the black box connected to the input
+           // which changed
+           c->GetConnection()->TransferData();
+           // Get the name of the input which changed
+           std::string input_name = c->GetConnection()->GetBlackBoxToInput();
+           // Set the output to the value of the input which changed
+           bbSetOutputOut( bbGetInput(input_name) );   
+         }
+       // No more change allowed
+       mCanSet = false;
+      }
+   BlackBox::bbSetStatusAndPropagate(c,s);
+  }
+
+  void SharedMemory::bbUserSetDefaultValues()
+  {
+    mCanSet = true;
+  }
+  void SharedMemory::bbUserInitializeProcessing() 
+  { 
+  }
+  void  SharedMemory::bbUserFinalizeProcessing() 
+  {
+  }
+  void SharedMemory::DoProcess()
+  { 
+    mCanSet = true;
+  }
+
+  BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,SharedMemory);
+  BBTK_BLACK_BOX_IMPLEMENTATION(SharedMemory,bbtk::AtomicBlackBox);
+  
+}
+// EO namespace bbstd
diff --git a/packages/std/src/bbstdSharedMemory.h b/packages/std/src/bbstdSharedMemory.h
new file mode 100644 (file)
index 0000000..f012e78
--- /dev/null
@@ -0,0 +1,168 @@
+/*=========================================================================                                                                               
+  Program:   bbtk
+  Module:    $RCSfile: bbstdSharedMemory.h,v $
+  Language:  C++
+  Date:      $Date: 2009/06/08 14:50:06 $
+  Version:   $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+*  This software is governed by the CeCILL-B license under French law and 
+*  abiding by the rules of distribution of free software. You can  use, 
+*  modify and/ or redistribute the software under the terms of the CeCILL-B 
+*  license as circulated by CEA, CNRS and INRIA at the following URL 
+*  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
+*  or in the file LICENSE.txt.
+*
+*  As a counterpart to the access to the source code and  rights to copy,
+*  modify and redistribute granted by the license, users are provided only
+*  with a limited warranty  and the software's author,  the holder of the
+*  economic rights,  and the successive licensors  have only  limited
+*  liability. 
+*
+*  The fact that you are presently reading this means that you have had
+*  knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */                                                                         
+
+
+#ifndef __bbstdSharedMemory_h_INCLUDED_H__
+#define __bbstdSharedMemory_h_INCLUDED_H__
+
+#include "bbtkAtomicBlackBox.h"
+#include "bbstd_EXPORT.h"
+
+namespace bbstd
+{
+#define BBTK_MB_DECLARE_INPUT(NAME,TYPE)                               \
+  protected:                                                           \
+  TYPE bbmInput##NAME;                                                 \
+public:                                                                        \
+  TYPE bbGetInput##NAME ()                                             \
+  { return bbmInput##NAME; }                                           \
+    void bbSetInput##NAME (TYPE d)                                     \
+    { bbmInput##NAME = d;                                              \
+      if (mCanSet) { bbSetOutputOut(d); mCanSet = false; } }                           
+
+  //==================================================================
+  class bbstd_EXPORT SharedMemory
+    : 
+    public bbtk::AtomicBlackBox
+  {
+    BBTK_BLACK_BOX_INTERFACE(SharedMemory,bbtk::AtomicBlackBox);
+    BBTK_MB_DECLARE_INPUT(In,bbtk::Data);
+    BBTK_MB_DECLARE_INPUT(In1,bbtk::Data);
+    BBTK_MB_DECLARE_INPUT(In2,bbtk::Data);
+    BBTK_MB_DECLARE_INPUT(In3,bbtk::Data);
+    BBTK_MB_DECLARE_INPUT(In4,bbtk::Data);
+    BBTK_MB_DECLARE_INPUT(In5,bbtk::Data);
+    BBTK_MB_DECLARE_INPUT(In6,bbtk::Data);
+    BBTK_MB_DECLARE_INPUT(In7,bbtk::Data);
+    BBTK_MB_DECLARE_INPUT(In8,bbtk::Data);
+    BBTK_MB_DECLARE_INPUT(In9,bbtk::Data);
+    BBTK_DECLARE_OUTPUT(Out,bbtk::Data);
+    BBTK_PROCESS(DoProcess);
+    void DoProcess();
+  protected:
+    //    virtual void bbUserConstructor();
+    virtual void bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c,
+                                        bbtk::IOStatus s);
+    bool mCanSet;
+ };
+  //==================================================================
+  
+#undef BBTK_MB_DECLARE_INPUT  
+
+  //==================================================================
+  // We have to create a particular SetFunctor for SharedMemory because
+  // its input is of type bbtk::Data (i.e. any) and :
+  // 1) an any cannot store an any (construction with an any invokes the copy constr.)
+  // 2) we cannot invoke the Set method with the content of the any because 
+  //   it expects an any 
+  // hence the Set method of the functor **MUST NOT** extract the 
+  // content of the Data prior to invoking the set method of the box
+  class SharedMemorySetFunctor : public bbtk::AtomicBlackBoxSetFunctor
+  {
+  public:
+    /// Type of pointer on a UBB::Set method  
+    typedef void (SharedMemory::*SetMethodPointerType)(bbtk::Data);
+    
+    /// Construction with the pointer on the Set method
+    SharedMemorySetFunctor(SetMethodPointerType s) :
+       mSetMethodPointer(s) 
+       {
+       }
+    
+    /// Concrete application of the Set method of object o
+    void Set(bbtk::AtomicBlackBox* o, const bbtk::Data& d)
+    { 
+      bbtkDebugMessage("data",9,"SharedMemorySetfunctor::Set("<<
+                      bbtk::HumanTypeName(d.type())<<
+                      ")"<<std::endl);
+      (((SharedMemory*)o)->*mSetMethodPointer)(d);
+    }
+    
+    /// 
+    bbtk::TypeInfo GetTypeInfo() const { return typeid(bbtk::Data); }
+    std::string GetTypeName() const { return bbtk::TypeName<bbtk::Data>(); }
+    std::string GetHumanTypeName() const { return bbtk::HumanTypeName<bbtk::Data>(); }
+    bool IsPointerType() const { return false; }
+    void BruteForceSetPointer(bbtk::AtomicBlackBox*, void*) {}
+  private:
+    ///  Pointer on the Set method  
+    SetMethodPointerType mSetMethodPointer;
+  };
+  //===========================================================================
+  
+#define MAGIC_BOX_INPUT(NAME)                                          \
+  AddInputDescriptor                                                   \
+  (new bbtk::AtomicBlackBoxInputDescriptor                             \
+   (typeid(SharedMemoryDescriptor),                                            \
+    #NAME,"Input data","",                                             \
+    new bbtk::AtomicBlackBoxTGetFunctor<SharedMemory,bbtk::Data,bbtk::Data>    \
+    (&SharedMemory::bbGetInput ## NAME),                                       \
+    new SharedMemorySetFunctor (&SharedMemory::bbSetInput ## NAME) ) );                
+
+  //===========================================================================
+  BBTK_BEGIN_DESCRIBE_BLACK_BOX(SharedMemory,bbtk::AtomicBlackBox);
+  BBTK_NAME("SharedMemory");
+  BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+  BBTK_CATEGORY("misc");
+  BBTK_DESCRIPTION("Implements a memory which can be shared by different boxes. The value of the output is the value of the lower index input which has changed. It is used for example for synchronization issues between boxes.");
+  MAGIC_BOX_INPUT(In)  
+  MAGIC_BOX_INPUT(In1) 
+  MAGIC_BOX_INPUT(In2) 
+  MAGIC_BOX_INPUT(In3) 
+  MAGIC_BOX_INPUT(In4) 
+  MAGIC_BOX_INPUT(In5) 
+  MAGIC_BOX_INPUT(In6) 
+  MAGIC_BOX_INPUT(In7) 
+  MAGIC_BOX_INPUT(In8) 
+  MAGIC_BOX_INPUT(In9) 
+
+ /*
+ AddInputDescriptor
+  (new bbtk::AtomicBlackBoxInputDescriptor
+   (typeid(SharedMemoryDescriptor),
+    "In","Input data","",
+    new bbtk::AtomicBlackBoxTGetFunctor<SharedMemory,bbtk::Data,bbtk::Data>
+    (&SharedMemory::bbGetInputIn),
+    new SharedMemorySetFunctor (&SharedMemory::bbSetInputIn) ) );
+ */
+  AddOutputDescriptor
+  (new bbtk::AtomicBlackBoxOutputDescriptor
+   (typeid(SharedMemoryDescriptor),
+    "Out","Output data","",
+    new bbtk::AtomicBlackBoxTGetFunctor<SharedMemory,bbtk::Data,bbtk::Data>
+    (&SharedMemory::bbGetOutputOut),
+    new SharedMemorySetFunctor (&SharedMemory::bbSetOutputOut) ) );
+  BBTK_END_DESCRIBE_BLACK_BOX(SharedMemory);
+  //===========================================================================
+
+}
+// namespace bbstd
+
+#endif // __bbstdSharedMemory_h_INCLUDED_H__
index 1a465241c95b3902e9ab12887a1419f8a0f766c5..21b5a4bf0f6f24ca394d9c327c21a94edbb15a64 100644 (file)
@@ -10,7 +10,7 @@ new Slider slider2
 new Slider slider3
 new Slider slider4
 new LayoutLine layout
-new MagicBox position
+new SharedMemory position
 
 set position.In 20
 set position.BoxProcessMode Reactive
@@ -29,8 +29,5 @@ connect slider2.Widget layout.Widget2
 connect slider3.Widget layout.Widget3
 connect slider4.Widget layout.Widget4
 
-//message process 3
-//message change 1
-//message data 1
 exec layout