]> Creatis software - bbtk.git/commitdiff
=== MAJOR RELEASE ====
authorguigues <guigues>
Fri, 18 Apr 2008 12:59:13 +0000 (12:59 +0000)
committerguigues <guigues>
Fri, 18 Apr 2008 12:59:13 +0000 (12:59 +0000)
* All bbtk major objects are now smart pointed (using boost::shared_ptr) and auto-destruct when no more used. They inherit from bbtk::Object with pose the basis for the mechanism...

143 files changed:
kernel/appli/bbc/main.cxx.in
kernel/appli/bbfy/bbfy.cpp
kernel/appli/bbi/bbi.cxx
kernel/appli/bbs2cpp/bbs2cpp.cxx
kernel/cmake/BBTKDefineOptions.cmake
kernel/cmake/BBTKKernelConfig.cmake
kernel/doc/bbtkDoxygen/Doxyfile.txt.in
kernel/src/CMakeLists.txt
kernel/src/bbtkAtomicBlackBox.cxx
kernel/src/bbtkAtomicBlackBox.h
kernel/src/bbtkAtomicBlackBoxDescriptor.cxx [new file with mode: 0644]
kernel/src/bbtkAtomicBlackBoxDescriptor.h
kernel/src/bbtkAtomicBlackBoxMacros.h
kernel/src/bbtkBlackBox.cxx
kernel/src/bbtkBlackBox.h
kernel/src/bbtkBlackBoxDescriptor.cxx
kernel/src/bbtkBlackBoxDescriptor.h
kernel/src/bbtkBlackBoxInputConnector.cxx
kernel/src/bbtkBlackBoxInputConnector.h
kernel/src/bbtkBlackBoxOutputConnector.cxx
kernel/src/bbtkBlackBoxOutputConnector.h
kernel/src/bbtkComplexBlackBox.cxx
kernel/src/bbtkComplexBlackBox.h
kernel/src/bbtkComplexBlackBoxDescriptor.cxx
kernel/src/bbtkComplexBlackBoxDescriptor.h
kernel/src/bbtkConnection.cxx
kernel/src/bbtkConnection.h
kernel/src/bbtkData.h
kernel/src/bbtkExecuter.cxx
kernel/src/bbtkExecuter.h
kernel/src/bbtkFactory.cxx
kernel/src/bbtkFactory.h
kernel/src/bbtkInterpreter.cxx
kernel/src/bbtkInterpreter.h
kernel/src/bbtkMessageManager.cxx
kernel/src/bbtkObject.cxx [new file with mode: 0644]
kernel/src/bbtkObject.h [new file with mode: 0644]
kernel/src/bbtkPackage.cxx
kernel/src/bbtkPackage.h
kernel/src/bbtkTranscriptor.cxx
kernel/src/bbtkTranscriptor.h
kernel/src/bbtkVirtualExec.cxx [new file with mode: 0644]
kernel/src/bbtkVirtualExec.h
kernel/src/bbtkWxBlackBox.cxx
kernel/src/bbtkWxBlackBox.h
kernel/src/bbtkWxGUIConsole.cxx
kernel/src/bbtkWxGUIConsole.h
kernel/src/bbtkWxGUIPackageBrowser.cxx
kernel/src/bbtkWxGUIPackageBrowser.h
kernel/src/bbtkWxGUIPackageBrowser2.cxx
kernel/src/bbtkWxGUIPackageBrowser2.h
kernel/src/bbtkWxGUIScriptingInterface.cxx
kernel/src/bbtkWxGUIScriptingInterface.h
packages/itk/src/bbitkAnyImageToTypedImage.cxx
packages/itk/src/bbitkAnyImageToTypedImage.h
packages/itk/src/bbitkBinaryThresholdImageFilter.cxx
packages/itk/src/bbitkBinaryThresholdImageFilter.h
packages/itk/src/bbitkExtractImageFilter.cxx
packages/itk/src/bbitkExtractImageFilter.h
packages/itk/src/bbitkImage.cxx
packages/itk/src/bbitkImageProperties.cxx
packages/itk/src/bbitkImageProperties.h
packages/itk/src/bbitkImageReader.cxx
packages/itk/src/bbitkImageReader.h
packages/itk/src/bbitkImageRegion.cxx
packages/itk/src/bbitkImageRegion.h
packages/itk/src/bbitkImageSeriesReader.cxx
packages/itk/src/bbitkImageSeriesReader.h
packages/itk/src/bbitkImageToString.cxx
packages/itk/src/bbitkImageWriter.cxx
packages/itk/src/bbitkImageWriter.h
packages/itk/src/bbitkResampleImageFilter.cxx
packages/itk/src/bbitkResampleImageFilter.h
packages/itk/src/bbitkTypedImageToAnyImage.cxx
packages/itk/src/bbitkTypedImageToAnyImage.h
packages/itkvtk/src/bbitkvtkitkImage2vtkImageData.cxx
packages/itkvtk/src/bbitkvtkitkImage2vtkImageData.h
packages/itkvtk/src/bbitkvtkvtkImageData2itkImage.cxx
packages/itkvtk/src/bbitkvtkvtkImageData2itkImage.h
packages/std/src/bbstdASCII.cxx
packages/std/src/bbstdASCII.h
packages/std/src/bbstdCast.cxx
packages/std/src/bbstdCast.h
packages/std/src/bbstdConcatStrings.cxx
packages/std/src/bbstdConcatStrings.h
packages/std/src/bbstdConfiguration.cxx
packages/std/src/bbstdConfiguration.h
packages/std/src/bbstdExecBbiCommand.cxx
packages/std/src/bbstdExecBbiCommand.h
packages/std/src/bbstdExecSystemCommand.cxx
packages/std/src/bbstdExecSystemCommand.h
packages/std/src/bbstdMagicBox.cxx
packages/std/src/bbstdMagicBox.h
packages/std/src/bbstdMakeFileName.cxx
packages/std/src/bbstdMakeFileName.h
packages/std/src/bbstdRelay.cxx
packages/std/src/bbstdRelay.h
packages/std/src/bbstdStringSelect.cxx
packages/std/src/bbstdStringSelect.h
packages/std/src/bbstdStringTo.cxx
packages/std/src/bbstdStringTo.h
packages/std/src/bbstdStringToVector.cxx
packages/std/src/bbstdStringToVector.h
packages/std/src/bbstdToString.cxx
packages/std/src/bbstdToString.h
packages/std/src/bbstdVectorToString.cxx
packages/std/src/bbstdVectorToString.h
packages/vtk/src/bbvtkImageDataToString.cxx
packages/vtk/src/bbvtkImagePlanes.cxx
packages/vtk/src/bbvtkImagePlanes.h
packages/vtk/src/bbvtkIsoSurfaceExtractor.cxx
packages/vtk/src/bbvtkIsoSurfaceExtractor.h
packages/vtk/src/bbvtkMIPCreator.cxx
packages/vtk/src/bbvtkMIPCreator.h
packages/vtk/src/bbvtkMarchingCubes.cxx
packages/vtk/src/bbvtkMarchingCubes.h
packages/wx/src/bbwxColourSelector.cxx
packages/wx/src/bbwxColourSelector.h
packages/wx/src/bbwxColourSelectorButton.cxx
packages/wx/src/bbwxColourSelectorButton.h
packages/wx/src/bbwxCommandButton.cxx
packages/wx/src/bbwxCommandButton.h
packages/wx/src/bbwxDirectorySelector.cxx
packages/wx/src/bbwxDirectorySelector.h
packages/wx/src/bbwxFileSelector.cxx
packages/wx/src/bbwxFileSelector.h
packages/wx/src/bbwxInputText.cxx
packages/wx/src/bbwxInputText.h
packages/wx/src/bbwxLayoutLine.cxx
packages/wx/src/bbwxLayoutLine.h
packages/wx/src/bbwxLayoutSplit.cxx
packages/wx/src/bbwxLayoutSplit.h
packages/wx/src/bbwxLayoutTab.cxx
packages/wx/src/bbwxLayoutTab.h
packages/wx/src/bbwxRadioButton.cxx
packages/wx/src/bbwxRadioButton.h
packages/wx/src/bbwxSlider.cxx
packages/wx/src/bbwxSlider.h
packages/wxvtk/src/bbwxvtkViewer2D.cxx
packages/wxvtk/src/bbwxvtkViewer2D.h
packages/wxvtk/src/bbwxvtkViewer3D.cxx
packages/wxvtk/src/bbwxvtkViewer3D.h
packages/wxvtk/src/bbwxvtkwxVTKRenderWindowInteractorTovtkRenderWindowInteractor.cxx

index b4ac5271a21814caf1630d47c2a88404f91ec531..47e150a1c34f98c4e7a80fcc517df654541af5ca 100644 (file)
@@ -35,7 +35,7 @@ public:
   bool OnCmdLineParsed(wxCmdLineParser& parser);
   void Run(bbtk::Interpreter*);
 
-  bbtk::Executer* mExecuter;
+  bbtk::Executer::Pointer mExecuter;
   //  int argc;
   //  std::vector<std::string> argv;
   bool command;
@@ -111,7 +111,7 @@ bool wxBBIApp::OnInit( )
   bbtk::Wx::CreateInvisibleTopWindow();
 
   try {
-    mExecuter = new bbtk::Executer();
+    mExecuter = bbtk::Executer::New();
     mExecuter->SetInputs(param_map);
 
     if (help) mExecuter->SetNoExecMode(true);
@@ -135,7 +135,6 @@ bool wxBBIApp::OnInit( )
       mess += bbtk::std2wx ( e.GetMessage() );
       wxMessageBox(mess,_T("Error"),wxOK | wxICON_ERROR);
       bbtk::Wx::GetTopWindow()->Close();
-      delete mExecuter;
       return false;
     }
   if (help || !bbtk::Wx::IsSomeWindowAlive()) 
index a7b85338078634f8bbf8429d8a0d3cde0d7a67a8..4aeb878c5719e47b2b1e9d657646ad44da31e59e 100644 (file)
@@ -541,7 +541,7 @@ void bbfy::CreateHeader()
   mFile << "{\n";
 
   // Interface
-  mFile << "  BBTK_USER_BLACK_BOX_INTERFACE("
+  mFile << "  BBTK_BLACK_BOX_INTERFACE("
        << mName << ","
        << mParentBlackBox << ");\n";
 
@@ -846,7 +846,7 @@ void bbfy::WriteGenericITKFilterHeader()
   mFile << "{\n";
 
   // Interface
-  mFile << "  BBTK_USER_BLACK_BOX_INTERFACE("
+  mFile << "  BBTK_BLACK_BOX_INTERFACE("
        << mName << "Generic,bbtk::AtomicBlackBox);\n";
 
   // Inputs
@@ -991,14 +991,14 @@ void bbfy::CreateCode()
   if (mTemplateParam.size()>0) 
     {
       // Implementation
-      mFile << "BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION("
+      mFile << "BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION("
            << mName << ","  
            << mParentBlackBox << ");\n";
      
       if (mGeneric) 
        {       
          // Implementation
-         mFile << "BBTK_USER_BLACK_BOX_IMPLEMENTATION("
+         mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
                << mName << "Generic,bbtk::AtomicBlackBox);\n";
          // Package
          mFile << "BBTK_ADD_BLACK_BOX_TO_PACKAGE("
@@ -1015,7 +1015,7 @@ void bbfy::CreateCode()
            << mName << ")\n";
 
       // Implementation
-      mFile << "BBTK_USER_BLACK_BOX_IMPLEMENTATION("
+      mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
            << mName << ","  
            << mParentBlackBox << ");\n"; 
     }
index 0ee9e1a0c9b7b3d5b641b130c36eb33e316922d0..3c00bb8db477d4ed45b9990f03cd761bb9b87951 100644 (file)
@@ -3,6 +3,7 @@
 //==========================================================================
 // WITH WX
 //==========================================================================
+#include "bbtkObject.h"
 #include "bbtkInterpreter.h"
 #include "bbtkWxBlackBox.h"
 #include "bbtkWxGUIConsole.h"
@@ -14,6 +15,7 @@
 
 static const wxCmdLineEntryDesc cmdLineDesc[] =
 {
+  { wxCMD_LINE_SWITCH, _T("M"), _T("Memory debug"), _T("Display memory debug message on exit") },
   { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Debug messages on (message All 9)") },
   { wxCMD_LINE_SWITCH, _T("c"), _T("command"), _T("turn to command line mode after file(s) processing") },
   { wxCMD_LINE_SWITCH, _T("q"), _T("quiet"),   _T("be quiet") },
@@ -34,6 +36,7 @@ public:
   bool OnInit( );
   int  OnExit() { 
     //    std::cout << "wxBBIApp::OnExit()"<<std::endl;
+    // bbtk::Object::PrintObjectListInfo();
     return true; }
   void OnInitCmdLine(wxCmdLineParser& parser);
   bool OnCmdLineParsed(wxCmdLineParser& parser);
@@ -66,6 +69,11 @@ void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser)
 
 bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser)
 {
+  if (parser.Found(_T("M"))) 
+    {
+      bbtk::StaticInitTime::PrintObjectListInfo = true;
+    }
+  
   debug = ( parser.Found(_T("d")) );
   quiet = ( parser.Found(_T("q")) );
   help = ( parser.Found(_T("h")) );
index 529a035dc6386d47d3a266548217444ce7784c54..0fd3e0c7e6a0a392dfcbc03a6b200174b0afe315 100644 (file)
@@ -8,7 +8,7 @@ int main(int argc, char* argv[])
   std::string file,path;
   file = bbtk::Utilities::ExtractScriptName(argv[1],path);
   file += ".h";
-  bbtk::Interpreter* I = new bbtk::Interpreter(file);
+  bbtk::Interpreter::Pointer I = bbtk::Interpreter::New(file);
 
   I->SetThrow(true);
 
@@ -21,8 +21,6 @@ int main(int argc, char* argv[])
       e.Print();
     }
 
-  delete I;
-
   return 0;
 }
         
index 92f4cc99af9ca590b52fc9618f1f85fef634fc45..69531a065b95b7991ec2b233257c6201dba42616 100644 (file)
@@ -50,3 +50,12 @@ ELSE(BUILD_BBTK_DOC)
   
 ENDIF(BUILD_BBTK_DOC)
 #-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# BOOST C++
+OPTION(BBTK_USE_BOOST "Use the boost C++ library" ON)
+IF(BBTK_USE_BOOST)
+ADD_DEF( _USE_BOOST_ )
+ENDIF(BBTK_USE_BOOST)
+#-----------------------------------------------------------------------------
+
index 4645ed286033817ca38a2b2afea6f6c5bf10eba2..1b6136449df5f9b6908e6feb85cee4383222ccf8 100644 (file)
@@ -6,6 +6,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_BINARY_DIR}/kernel/src )
 # SOURCES DIR MUST ALSO BE IN INCLUDE DIRS FOR FILES COMPILED IN BINARY DIR 
 # WHICH NEED TO INCLUDE OTHER FILES OF THE PACKAGE
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/kernel/src )
+INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/kernel/src/ThirdParty )
 #----------------------------------------------------------------------------
 
 #----------------------------------------------------------------------------
index f06f3fd1dee6deea7e1ddb09b6fb37057dab8aac..2f63cfd493d130d06891ec0c77a9723119be46a4 100644 (file)
@@ -1235,7 +1235,7 @@ GROUP_GRAPHS           = YES
 # collaboration diagrams in a style similar to the OMG's Unified Modeling 
 # Language.
 
-UML_LOOK               = YES
+UML_LOOK               = NO
 
 # If set to YES, the inheritance and collaboration graphs will show the 
 # relations between templates and their instances.
index 6003f596f5b103f4226210ebe721af3239a5dbad..a2933c56d337812dfcc38e033795a06c74df5720 100644 (file)
@@ -151,7 +151,6 @@ ENDIF(NOT BBTK_INSTALL_NO_DEVELOPMENT)
 # Symbols must be exported (Windows)
 ADD_DEF(BBTK_EXPORT_SYMBOLS)
 
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty)
 ADD_DEFINITIONS(-DCHECKBOXVIEW=1)
 #-----------------------------------------------------------------------------
 # Sources files 
index 981b16c14d1dd8be1558312d14def889b4e6e7b5..ae0869d31b64694259efc79f36c475e9321b2e91 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkAtomicBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:29 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/04/18 12:59:14 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,10 +30,12 @@ namespace bbtk
   AtomicBlackBox::AtomicBlackBox(const std::string &name, bool alloc)
     : BlackBox(name)
   {
-    bbtkDebugMessageInc("Kernel",7,
-            "AtomicBlackBox::AtomicBlackBox(\""
-            <<name<<"\")"<<std::endl);
-    bbtkDebugDecTab("Kernel",7);
+    bbtkDebugMessage("object",3,
+                    "==> AtomicBlackBox::AtomicBlackBox(\""
+                    <<name<<"\")"<<std::endl);
+    bbtkDebugMessage("object",3,
+                    "<== AtomicBlackBox::AtomicBlackBox(\""
+                    <<name<<"\")"<<std::endl);
   }
   //========================================================================= 
   
@@ -44,11 +46,14 @@ namespace bbtk
                 bool alloc)
     : BlackBox(from,name)
   {
-    bbtkDebugMessageInc("Kernel",7,
-        "AtomicBlackBox::AtomicBlackBox("
-        <<from.bbGetFullName()<<",\""
-        <<name<<"\")"<<std::endl);
-    bbtkDebugDecTab("Kernel",7);
+    bbtkDebugMessage("object",3,
+                    "==>AtomicBlackBox::AtomicBlackBox("
+                    <<from.bbGetFullName()<<",\""
+                    <<name<<"\")"<<std::endl);
+    bbtkDebugMessage("object",3,
+                    "<==AtomicBlackBox::AtomicBlackBox("
+                    <<from.bbGetFullName()<<",\""
+                    <<name<<"\")"<<std::endl);
     
   }
   //=========================================================================
@@ -58,16 +63,18 @@ namespace bbtk
   ///  Destructor
   AtomicBlackBox::~AtomicBlackBox()
   {
-    bbtkDebugMessage("Kernel",7,"AtomicBlackBox::~AtomicBlackBox()"
-            <<std::endl);
+    bbtkDebugMessage("object",3,"==> AtomicBlackBox::~AtomicBlackBox()"
+                    <<std::endl);
+    bbtkDebugMessage("object",3,"<== AtomicBlackBox::~AtomicBlackBox()"
+                    <<std::endl);
   } 
   //=========================================================================
   
-  
+
 
   //=========================================================================
   /// Main processing method of the box.
-  IOStatus AtomicBlackBox::bbBackwardUpdate( Connection* caller )
+  IOStatus AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
   {
     bbtkDebugMessageInc("Process",1,
                        "=> AtomicBlackBox::bbBackwardUpdate("
@@ -250,6 +257,32 @@ namespace bbtk
     bbtkDebugDecTab("Data",7);
   }
   //=========================================================================
+
+
+  //==========================================================================
+  std::string AtomicBlackBox::GetObjectInfo() const 
+  {
+    std::stringstream i;
+    return i.str();
+  }
+  //==========================================================================
+
+  //==========================================================================
+  size_t AtomicBlackBox::GetObjectSize() const 
+  {
+    return sizeof(*this);
+  }
+  //==========================================================================
   
+  //==========================================================================
+  size_t AtomicBlackBox::GetObjectRecursiveSize() const 
+  {
+    size_t s = GetObjectSize();
+    return s;
+  }
+  //==========================================================================
+
 }
 // EO namespace bbtk
index 02cb9a5fa39f894370213ab2f81398ca1342c084..0af4403a74a2487652ec71a99ca82f2218c8ec85 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkAtomicBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:29 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/04/18 12:59:14 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -42,6 +42,11 @@ namespace bbtk
   {
     //==================================================================
   public: 
+    //==================================================================
+    bbtk::BlackBoxDescriptor::Pointer bbGetDescriptor() const
+    {
+      return bbmDescriptorPointer;
+    }
     //==================================================================
     /// Gets the output Data of a given label
     Data bbGetOutput( const std::string &label );
@@ -59,8 +64,9 @@ namespace bbtk
     //==================================================================
 
     //==================================================================
-    ///  Destructor
-    virtual ~AtomicBlackBox();
+    std::string GetObjectInfo() const;      
+    size_t GetObjectSize() const;
+    size_t GetObjectRecursiveSize() const;
     //==================================================================
 
     //==================================================================
@@ -72,6 +78,17 @@ namespace bbtk
     AtomicBlackBox(AtomicBlackBox& from, const std::string &name, 
                 bool alloc = true);
     //==================================================================
+    //==================================================================
+    ///  Destructor
+    virtual ~AtomicBlackBox();
+    //==================================================================
+
+    //==================================================================
+  protected:
+    virtual void bbLockDescriptor() = 0;
+    //  private:
+    //    virtual void bbReleaseDescriptor();
+    //==================================================================
 
   public:
     //==================================================================   
@@ -85,7 +102,7 @@ namespace bbtk
     /// - updates its inputs by calling bbUpdateInputs (which recursively calls bbBackwardUpdate on upstream boxes)
     /// - calls bbProcess which here simply calls the user callback bbUserProcess which does the actual processing. 
     ///    bbProcess is overloaded in WxBlackBox to handle widget creation and show
-    virtual IOStatus bbBackwardUpdate(Connection* caller);
+    virtual IOStatus bbBackwardUpdate(Connection::Pointer caller);
     //==================================================================
 
     //==================================================================
@@ -126,6 +143,11 @@ namespace bbtk
     AtomicBlackBox() : BlackBox("") {}
     //================================================================== 
 
+  protected:
+    //================================================================== 
+    // The pointer on the descriptor
+    bbtk::BlackBoxDescriptor::Pointer bbmDescriptorPointer;  
+    //================================================================== 
 
   };
   // Class AtomicBlackBox
diff --git a/kernel/src/bbtkAtomicBlackBoxDescriptor.cxx b/kernel/src/bbtkAtomicBlackBoxDescriptor.cxx
new file mode 100644 (file)
index 0000000..6511313
--- /dev/null
@@ -0,0 +1,51 @@
+#include "bbtkAtomicBlackBoxDescriptor.h"
+#include "bbtkBlackBox.h"
+#include "bbtkPackage.h"
+
+namespace bbtk
+{
+  AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor() 
+  {  
+    bbtkDebugMessage("object",3,"==> AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor()"<<std::endl);
+    // Creates the input 'BoxProcessMode'
+    AddInputDescriptor
+      (new 
+       bbtk::AtomicBlackBoxInputDescriptor
+       (typeid(AtomicBlackBoxDescriptor),
+       "BoxProcessMode",
+       "Sets the processing mode of the box (Pipeline | Always | Reactive)",
+       "",
+       new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,std::string,std::string>(&BlackBox::bbGetInputBoxProcessMode), 
+       new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,std::string,std::string>(&BlackBox::bbSetInputBoxProcessMode) ) );
+    // Creates the input 'BoxExecute'
+    AddInputDescriptor
+      (new
+       bbtk::AtomicBlackBoxInputDescriptor
+       (typeid(AtomicBlackBoxDescriptor),
+       "BoxExecute",
+       "Any signal received by this input executes the box",
+       "",
+       new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,Void,Void>(&BlackBox::bbGetInputBoxExecute), 
+       new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,Void,Void>(&BlackBox::bbSetInputBoxExecute) ) );
+    // Creates the output 'BoxChange'      
+    AddOutputDescriptor
+      (new 
+       bbtk::AtomicBlackBoxOutputDescriptor
+       (typeid(AtomicBlackBoxDescriptor),
+       "BoxChange",
+       "Signal modifications of the box", 
+       "",
+       new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,Void,Void>(&BlackBox::bbGetOutputBoxChange), 
+       new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,Void,Void>(&BlackBox::bbSetOutputBoxChange) ) );
+    //
+    AddToCategory("atomic box");
+    bbtkDebugMessage("object",3,"<== AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor()"<<std::endl);
+  }
+  //===================================================================
+
+  AtomicBlackBoxDescriptor::~AtomicBlackBoxDescriptor() 
+  {  
+    bbtkDebugMessage("object",3,"==> AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor()"<<std::endl);
+    bbtkDebugMessage("object",3,"<== AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor()"<<std::endl);
+  }
+}// namespace bbtk
index 80201c64ea7fd10c84decda1a64cc9b378747f63..e9ab401e5c8ae2b64c375c4be67128a657033d03 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkAtomicBlackBoxDescriptor.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:29 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:14 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,43 +39,15 @@ namespace bbtk
   class BBTK_EXPORT AtomicBlackBoxDescriptor : public bbtk::BlackBoxDescriptor
   {
   public:
-    AtomicBlackBoxDescriptor() 
-    {  
-      // Creates the input 'BoxProcessMode'
-      AddInputDescriptor
-       (new 
-        bbtk::AtomicBlackBoxInputDescriptor
-        (typeid(AtomicBlackBoxDescriptor),
-         "BoxProcessMode",
-         "Sets the processing mode of the box (Pipeline | Always | Reactive)",
-         "",
-         new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,std::string,std::string>(&BlackBox::bbGetInputBoxProcessMode), 
-         new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,std::string,std::string>(&BlackBox::bbSetInputBoxProcessMode) ) );
-      // Creates the input 'BoxExecute'
-      AddInputDescriptor
-       (new
-        bbtk::AtomicBlackBoxInputDescriptor
-        (typeid(AtomicBlackBoxDescriptor),
-         "BoxExecute",
-         "Any signal received by this input executes the box",
-         "",
-         new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,Void,Void>(&BlackBox::bbGetInputBoxExecute), 
-         new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,Void,Void>(&BlackBox::bbSetInputBoxExecute) ) );
-      // Creates the output 'BoxChange'      
-      AddOutputDescriptor
-       (new 
-        bbtk::AtomicBlackBoxOutputDescriptor
-        (typeid(AtomicBlackBoxDescriptor),
-         "BoxChange",
-         "Signal modifications of the box", 
-         "",
-         new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,Void,Void>(&BlackBox::bbGetOutputBoxChange), 
-         new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,Void,Void>(&BlackBox::bbSetOutputBoxChange) ) );
-      //
-      AddToCategory("atomic box");
-    }
+    /// Releases the descriptor
+    //    virtual void Release(bool release_package = true);
+
+  protected:
+    AtomicBlackBoxDescriptor();
+    virtual ~AtomicBlackBoxDescriptor();
+    virtual AtomicBlackBoxDescriptor::Pointer GetInstance() const = 0;
+
   };
-    
 }
 // namespace bbtk
 #endif
index ed05e79981dca978b3b07c2991ef93f8f92ebb3c..7ff6640249c0f4c5baddb15655bf704a77581c37 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:56 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 //============================================================================
 /// Declares the standard interface of a AtomicBlackBox 
 /// (ctor, New, descriptor related methods)
-#define BBTK_USER_BLACK_BOX_INTERFACE(CLASS,PARENT)                    \
+#define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT)                \
+  BBTK_OBJECT_MINIMAL_INTERFACE;                               \
   private:                                                             \
-  inline static void bbCreateDescriptorIfNeeded();                     \
   protected:                                                           \
   CLASS(const std::string& name, bool allocate_connectors = true);     \
-  CLASS(CLASS& from, const std::string& name,                          \
+  CLASS(Self& from, const std::string& name,                           \
        bool allocate_connectors = true);                               \
   ~CLASS();                                                            \
-  public: \
-  inline static CLASS* bbNew(const std::string& name)                  \
-  {                                                                    \
-    bbtkDebugMessageInc("Kernel",9,#CLASS<<"::bbNew(\""<<name<<"\")"<<std::endl); \
-    bbCreateDescriptorIfNeeded();                                      \
-    CLASS* c = new CLASS(name);                                                \
-    c->bbGetDescriptor()->Reference();                                 \
-    bbtkDebugDecTab("Kernel",9);                                       \
-    return c;                                                          \
-  }                                                                    \
-  inline bbtk::BlackBox* bbClone(const std::string& name)              \
-  {                                                                    \
-    bbtkDebugMessageInc("Kernel",9,#CLASS<<"::bbClone(\""<<name<<"\")"<<std::endl); \
-    bbCreateDescriptorIfNeeded();                                      \
-    CLASS* c = new CLASS(*this,name);                                  \
-    bbGetDescriptor()->Reference();                                    \
-    bbtkDebugDecTab("Kernel",9);                                       \
-    return c;                                                          \
-  }                                                                    \
-  bbtk::BlackBoxDescriptor* bbGetDescriptor() const                    \
+  public:                                                              \
+  std::string GetObjectName() const                                    \
+  { return std::string(#CLASS)+std::string(" '")                       \
+      +bbGetNameWithParent()+std::string("'"); }                       \
+  inline static Pointer New(const std::string& name)                   \
   {                                                                    \
-    return (bbtk::BlackBoxDescriptor*)bbDescriptor();                  \
+    bbtkDebugMessage("object",1,"##> "<<#CLASS                         \
+                    <<"::New(\""<<name<<"\")"<<std::endl);             \
+    Pointer p = MakeBlackBoxPointer(new Self(name));                   \
+    bbtkDebugMessage("object",1,"<## "<<#CLASS                         \
+                    <<"::New(\""<<name<<"\")"<<std::endl);             \
+    return p;                                                          \
   }                                                                    \
-  static bbtk::BlackBoxDescriptor* bbDescriptor()                      \
+  inline bbtk::BlackBox::Pointer bbClone(const std::string& name)      \
   {                                                                    \
-    bbCreateDescriptorIfNeeded();                                      \
-    return bbDescriptorPointer();                                      \
+    bbtkDebugMessage("object",1,"##> "<<#CLASS                         \
+                    <<"::bbClone(\""<<name<<"\")"<<std::endl);         \
+    Pointer p = MakeBlackBoxPointer(new Self(*this,name));             \
+    bbtkDebugMessage("object",1,"<## "<<#CLASS                         \
+                    <<"::bbClone(\""<<name<<"\")"<<std::endl);         \
+    return p;                                                          \
   }                                                                    \
+  virtual void bbLockDescriptor();                                     \
   private:                                                             \
   CLASS() : PARENT("") {}                                              \
-  static bbtk::BlackBoxDescriptor*& bbDescriptorPointer()              \
-  {                                                                    \
-    static bbtk::BlackBoxDescriptor* d = 0;                            \
-    return d;                                                          \
-  }                                                                    
+  CLASS(const CLASS&) : PARENT("") {}                                  
+
 //============================================================================
 
+//============================================================================
+#define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
+  public : typedef CLASS Self;                         \
+  BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
+//============================================================================
 
 //============================================================================
 /// Defines the bbUserProcess method
 
 //============================================================================
 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC)                  \
-  bbtkDebugMessageInc("Kernel",7,#CLASS<<"::"<<#CLASS                  \
-                     <<"(\""<<bbGetName()<<"\")"<<std::endl);          \
-  if (ALLOC) bbAllocateConnectors();                                   
+  bbtkDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS             \
+                  <<"(\""<<bbGetName()<<"\")"<<std::endl);             \
+  if (ALLOC)                                                           \
+    {                                                                  \
+      bbLockDescriptor();                                              \
+      bbAllocateConnectors();                                          \
+    }
+//============================================================================
+
+//============================================================================
+#define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS)                          \
+  bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS             \
+                  <<"(\""<<bbGetName()<<"\")"<<std::endl);             
 //============================================================================
 
 //============================================================================
 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC)                \
-  bbtkDebugMessageInc("Kernel",7,#CLASS<<"::"<<#CLASS                  \
+  bbtkDebugMessageInc("object",2,"==> "<<#CLASS<<"::"<<#CLASS          \
                      <<"("<<FROM.bbGetFullName()<<",\""                \
                      <<bbGetName()<<"\")"<<std::endl);                 \
   if (ALLOC)                                                           \
     {                                                                  \
+      bbLockDescriptor();                                              \
       bbAllocateConnectors();                                          \
       bbCopyIOValues(FROM);                                            \
    }
 //============================================================================
 
-
 //============================================================================
-#define BBTK_END_BLACK_BOX_CONSTRUCTOR         \
-  bbtkDebugDecTab("Kernel",7)
+#define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM)                        \
+  bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS             \
+                  <<"("<<FROM.bbGetFullName()<<",\""                   \
+                  <<bbGetName()<<"\")"<<std::endl);            
 //============================================================================
 
 //============================================================================
 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS)                         \
-  bbtkDebugMessageInc("Kernel",7,#CLASS <<"::~"<< #CLASS                       \
-                     <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
+  bbtkDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS          \
+                  <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
 //============================================================================
 
-
-
-
 //============================================================================
-#define BBTK_END_BLACK_BOX_DESTRUCTOR          \
-  bbtkDebugDecTab("Kernel",7)
+#define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS)                           \
+  bbtkDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS          \
+                  <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
+
 //============================================================================
 
 
 //============================================================================
 /// AtomicBlackBox std implementation of ctor and dtor
-#define BBTK_USER_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT)               \
+#define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT)            \
   CLASS::CLASS(const std::string& name, bool allocate_connectors)      \
     : PARENT(name,false)                                               \
   {                                                                    \
     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors);       \
     CLASS::bbUserConstructor();                                                \
-    BBTK_END_BLACK_BOX_CONSTRUCTOR;                                    \
+    BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS);                             \
   }                                                                    \
   CLASS::CLASS(CLASS& from,                                            \
               const std::string& name, bool allocate_connectors)       \
   {                                                                    \
     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
     CLASS::bbUserCopyConstructor();                                    \
-    BBTK_END_BLACK_BOX_CONSTRUCTOR;                                    \
+    BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from);                   \
   }                                                                    \
   CLASS::~CLASS()                                                      \
   {                                                                    \
     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                            \
     CLASS::bbUserDestructor();                                         \
-    BBTK_END_BLACK_BOX_DESTRUCTOR;                                     \
-  }                                                                    
+    BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS);                              \
+  }                                                                    \
+  void CLASS::bbLockDescriptor()                                       \
+  {                                                                    \
+    bbmDescriptorPointer = CLASS ## Descriptor::Instance();            \
+  }
 //============================================================================
 
 
 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT)                    \
   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
   {                                                                    \
+  public: typedef CLASS ## Descriptor Self;                            \
+    BBTK_OBJECT_MINIMAL_INTERFACE;                                     \
   public:                                                              \
-    bbtk::BlackBox::Pointer CreateInstance(const std::string& name)    \
+    std::string GetObjectName() const                                  \
+    {                                                                  \
+      return std::string(BBTK_STRINGIFY(CLASS))                                \
+       +std::string("Descriptor '")+GetFullTypeName()                  \
+       +std::string("'");                                              \
+    }                                                                  \
+    size_t GetObjectSize() const { return sizeof(*this); }             \
+    bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)       \
     {                                                                  \
-      return CLASS::bbNew(name);                                       \
+      return CLASS::New(name);                                         \
     }                                                                  \
+    virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance()      const \
+      {                                                                        \
+       return Instance();                                              \
+      }                                                                        \
+    static bbtk::AtomicBlackBoxDescriptor::Pointer Instance()                  \
+      {                                                                        \
+       static bbtk::AtomicBlackBoxDescriptor::WeakPointer i;                   \
+       bbtk::AtomicBlackBoxDescriptor::Pointer j;                              \
+       if (!i.lock()) { j = Self::New(); i = j; }                      \
+       return i.lock();                                                \
+      }                                                                        \
+    static CLASS ## Descriptor::Pointer New()                          \
+      {                                                                        \
+       bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS)       \
+                        <<"Descriptor::New" <<std::endl);              \
+       CLASS ## Descriptor::Pointer p =                                \
+         MakePointer(new CLASS ## Descriptor());                       \
+       bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS)       \
+                        <<"Descriptor::New" <<std::endl);              \
+       return p;                                                       \
+      }                                                                        \
+  protected:                                                           \
     CLASS ## Descriptor()                                              \
       {                                                                        \
-       bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS   \
-                           <<"Descriptor()"<<std::endl)
+       bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::"      \
+                        <<#CLASS<<"Descriptor()"<<std::endl);          
 //============================================================================
 
 //============================================================================
 /// Ends the AtomicBlackBox description block
 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS)                             \
-  bbtkDecTab("Kernel",9);                                                      \
+  bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::"           \
+                  <<#CLASS<<"Descriptor()"<<std::endl);                \
   }                                                                    \
   };                                                                   \
-  void CLASS::bbCreateDescriptorIfNeeded()                             \
-  {                                                                    \
-    if ( !bbDescriptorPointer() )                                      \
-      bbDescriptorPointer() = new CLASS ## Descriptor;                 \
-  }
+  
 //============================================================================
 
 
 
 //============================================================================
 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
-#define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE)                               \
+#define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE)                       \
   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor           \
                     (typeid(CLASS ## Descriptor),                      \
                      #NAME,DESCR,NATURE,                               \
 //============================================================================
 //============================================================================
 
+//============================================================================
+#define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T)      \
+  public : typedef CLASS<T> Self;                              \
+  BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
+//============================================================================
+
 //============================================================================
 /// Begins a template AtomicBlackBox of template param T description block
-#define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)  \
-  template <class T>                                   \
-  class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
+#define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT)           \
+  template <class T>                                                   \
+  class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
   {                                                                    \
+  public: typedef CLASS ## Descriptor<T> Self;                         \
+    BBTK_OBJECT_MINIMAL_INTERFACE;                                     \
   public:                                                              \
-    bbtk::BlackBox::Pointer CreateInstance(const std::string& name)    \
+    std::string GetObjectName() const                                  \
+    {                                                                  \
+      return std::string(BBTK_STRINGIFY(CLASS))                                \
+       +std::string("Descriptor<")+bbtk::TypeName<T>()                 \
+       +std::string("> '")+GetFullTypeName()                           \
+       +std::string("'");                                              \
+    }                                                                  \
+    static Pointer New()                                               \
+      {                                                                        \
+       bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS)       \
+                        <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
+                        <<std::endl);                                  \
+       Pointer p = MakePointer(new Self());                            \
+       bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS)       \
+                        <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
+                        <<std::endl);                                  \
+       return p;                                                       \
+      }                                                                        \
+    virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance()      const \
+      {                                                                        \
+       return Instance();                                              \
+      }                                                                        \
+    static bbtk::AtomicBlackBoxDescriptor::Pointer Instance()          \
+      {                                                                        \
+       static bbtk::AtomicBlackBoxDescriptor::WeakPointer i;           \
+       bbtk::AtomicBlackBoxDescriptor::Pointer j;                      \
+       if (!i.lock()) { j = Self::New(); i = j; }                      \
+       return i.lock();                                                \
+      }                                                                        \
+    bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)       \
     {                                                                  \
-      return CLASS<T>::bbNew(name);                                    \
+      return CLASS<T>::New(name);                                      \
     }                                                                  \
     CLASS ## Descriptor()                                              \
       {                                                                        \
-       bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS   \
-                           <<"Descriptor()"<<std::endl)
+       bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<"       \
+                        <<bbtk::TypeName<T>()<<">::"                   \
+                        <<#CLASS<<"Descriptor()"<<std::endl);          
+
 //============================================================================
 
 //============================================================================
 /// Ends a template AtomicBlackBox of template param T description block
-#define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)    \
-  bbtkDecTab("Kernel",9);                                                      \
+#define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)                    \
+  bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<"            \
+                  <<bbtk::TypeName<T>()<<">::"                         \
+                  <<#CLASS<<"Descriptor()"<<std::endl);                \
   }                                                                    \
-  };                                                                   \
-  template <class T>                                   \
-  void CLASS<T>::bbCreateDescriptorIfNeeded()          \
-  {                                                                    \
-    if ( !bbDescriptorPointer() )                                      \
-      bbDescriptorPointer() = new CLASS ## Descriptor<T>;      \
-  }
+  };                                                                   
+
 //============================================================================
 
 //============================================================================
 
 //============================================================================
 /// Template AtomicBlackBox std implementation of ctor and dtor
-#define BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT)      \
+#define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT)           \
   template <class T>                                                   \
   CLASS<T>::CLASS(const std::string& name, bool alloc)                 \
     : PARENT(name,false)                                               \
   {                                                                    \
-    BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS<T>,alloc);                  \
-    CLASS<T>::bbUserConstructor();                             \
-    BBTK_END_BLACK_BOX_CONSTRUCTOR;                                    \
-  }                            \
+    BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                     \
+    CLASS<T>::bbUserConstructor();                                     \
+    BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS);                             \
+  }                                                                    \
   template <class T>                                                   \
-  CLASS<T>::CLASS(CLASS<T>& from,                                              \
-              const std::string& name, bool allocate_connectors)       \
+  CLASS<T>::CLASS(CLASS<T>& from,                                      \
+                 const std::string& name, bool allocate_connectors)    \
     : PARENT(from,name,false)                                          \
   {                                                                    \
-    BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS<T>,from,allocate_connectors); \
+    BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
     CLASS<T>::bbUserCopyConstructor();                                 \
-    BBTK_END_BLACK_BOX_CONSTRUCTOR;                                    \
-  }            \
+    BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from);                   \
+  }                                                                    \
   template <class T>                                                   \
   CLASS<T>::~CLASS()                                                   \
   {                                                                    \
-    BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS<T>);                         \
+    BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                            \
     CLASS<T>::bbUserDestructor();                                      \
-    BBTK_END_BLACK_BOX_DESTRUCTOR;                                     \
-  }                                                                    
+    BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS);                              \
+  }                                                                    \
+  template <class T>                                                   \
+  void CLASS<T>::bbLockDescriptor()                                    \
+  {                                                                    \
+    bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance();         \
+  }
 //============================================================================
 
+
+
 //============================================================================
 // Two template params user black boxes macros
+//============================================================================
+
+//============================================================================
+#define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
+  public : typedef CLASS<T1,T2> Self;                                  \
+  BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
+//===========================================================================
 
+//============================================================================
 /// Begins a template AtomicBlackBox description block of template param T1 and T2 
-#define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)         \
+#define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT)          \
   template <class T1, class T2>                                                \
-  class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
+  class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
   {                                                                    \
+  public: typedef CLASS ## Descriptor<T1,T2> Self;                     \
+    BBTK_OBJECT_MINIMAL_INTERFACE;                                     \
   public:                                                              \
-    bbtk::BlackBox::Pointer CreateInstance(const std::string& name)    \
+    std::string GetObjectName() const                                  \
+    {                                                                  \
+      return std::string(BBTK_STRINGIFY(CLASS))                                \
+       +std::string("Descriptor<")+bbtk::TypeName<T1>()                \
+       +std::string(",")+bbtk::TypeName<T2>()                          \
+       +std::string("> '")+GetFullTypeName()                           \
+       +std::string("'");                                              \
+    }                                                                  \
+    static Pointer New()                                               \
+      {                                                                        \
+       bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS)       \
+                        <<"Descriptor<"<<bbtk::TypeName<T1>()<<","     \
+                        <<bbtk::TypeName<T2>()<<">::New"<<std::endl);  \
+       Pointer p = MakePointer(new Self());                            \
+       bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS)       \
+                        <<"Descriptor<"<<bbtk::TypeName<T1>()<<","     \
+                        <<bbtk::TypeName<T2>()<<">::New"<<std::endl);  \
+       return p;                                                       \
+      }                                                                        \
+    virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
+      {                                                                        \
+       return Instance();                                              \
+      }                                                                        \
+    static bbtk::AtomicBlackBoxDescriptor::Pointer Instance()          \
+      {                                                                        \
+       static bbtk::AtomicBlackBoxDescriptor::WeakPointer i;           \
+       bbtk::AtomicBlackBoxDescriptor::Pointer j;                      \
+       if (!i.lock()) { j = Self::New(); i = j; }                      \
+       return i.lock();                                                \
+      }                                                                        \
+    bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)       \
     {                                                                  \
-      return CLASS<T1,T2>::bbNew(name);                                        \
+      return CLASS<T1,T2>::New(name);                                  \
     }                                                                  \
     CLASS ## Descriptor()                                              \
       {                                                                        \
-      bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS    \
-                         <<"Descriptor()"<<std::endl)
+       bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<"       \
+                        <<bbtk::TypeName<T1>()<<","                    \
+                        <<bbtk::TypeName<T2>()<<">::"                  \
+                        <<#CLASS<<"Descriptor()"<<std::endl);          
 //============================================================================
 
 //============================================================================
 /// Ends a template AtomicBlackBox description block of template param T1 and T2
-#define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)           \
-  bbtkDecTab("Kernel",9);                                                      \
+#define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)                   \
+  bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<"            \
+                  <<bbtk::TypeName<T1>()<<","                          \
+                  <<bbtk::TypeName<T2>()<<">::"                        \
+                  <<#CLASS<<"Descriptor()"<<std::endl);                \
   }                                                                    \
-  };                                                                   \
-  template <class T1, class T2>                                                \
-  void CLASS<T1,T2>::bbCreateDescriptorIfNeeded()                      \
-  {                                                                    \
-    if ( !bbDescriptorPointer() )                                      \
-      bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>;          \
-  }
+  };                                                                   
+
 //============================================================================
 
+
+
+/*
 //============================================================================
 // Two template params user black boxes macros
 
 /// Begins a template AtomicBlackBox description block of template param T1 and T2 
 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)          \
   template <TYPE1 T1, TYPE2 T2>                                                \
-  class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
+  class  CLASS ## Descriptor : public bbtk::BlackBoxDescriptor         \
   {                                                                    \
   public:                                                              \
-    bbtk::BlackBox::Pointer CreateInstance(const std::string& name)    \
+    virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance()       const   \
+      {                                                                        \
+       return Instance();                                              \
+      }                                                                        \
+    static bbtk:AtomicBlackBoxDescriptor::Pointer Instance()                   \
+      {                                                                        \
+       static bbtk:AtomicBlackBoxDescriptor::WeakPointer i;                    \
+       bbtk:AtomicBlackBoxDescriptor::Pointer j;                               \
+       if (!i.lock()) { j = Self::New(); i = j; }                      \
+       return i.lock();                                                \
+      }                                                                        \
+    bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)       \
     {                                                                  \
       return new CLASS<T1,T2>(name);                                   \
     }                                                                  \
 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)    \
   bbtkDecTab("Kernel",9);                                                      \
   }                                                                    \
-  };                                                                   \
-  template <TYPE1 T1, TYPE2 T2>                                                \
-  void CLASS<T1,T2>::bbCreateDescriptorIfNeeded()                      \
-  {                                                                    \
-    if ( !bbDescriptorPointer() )                                      \
-      bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>;          \
-  }
-//============================================================================
+  };                                                                   
 
+//============================================================================
 
+*/
 
 //============================================================================
 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
 
 //============================================================================
 /// Template AtomicBlackBox std implementation of ctor and dtor
-#define BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT)     \
+#define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT)          \
   template <class T1, class T2>                                                \
   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)             \
     : PARENT(name,false)                                               \
   {                                                                    \
     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                     \
     CLASS<T1,T2>::bbUserConstructor();                                 \
-    BBTK_END_BLACK_BOX_CONSTRUCTOR;                                    \
+    BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS);                             \
   }                                                                    \
-  template <class T1, class T2>                                                        \
-  CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                                              \
-              const std::string& name, bool allocate_connectors)       \
+  template <class T1, class T2>                                                \
+  CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                              \
+                     const std::string& name, bool allocate_connectors) \
     : PARENT(from,name,false)                                          \
   {                                                                    \
     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
     CLASS<T1,T2>::bbUserCopyConstructor();                             \
-    BBTK_END_BLACK_BOX_CONSTRUCTOR;                                    \
+    BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from);                   \
   }                                                                    \
   template <class T1, class T2>                                                \
   CLASS<T1,T2>::~CLASS()                                               \
   {                                                                    \
     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                            \
     CLASS<T1,T2>::bbUserDestructor();                                  \
-    BBTK_END_BLACK_BOX_DESTRUCTOR;                                     \
-  }                                                                    
+    BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS);                              \
+  }                                                                    \
+  template <class T1, class T2>                                                \
+  void CLASS<T1,T2>::bbLockDescriptor()                                        \
+  {                                                                    \
+    bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance();     \
+  }
 //============================================================================
 
 
+/*
 //============================================================================
 /// Template AtomicBlackBox std implementation of ctor and dtor
-#define BBTK_USER_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
+#define BBTK_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
   template <TYPE1 T1, TYPE2 T2>                                                \
   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)             \
     : PARENT(name,false)                                               \
     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                            \
     this->bbUserDestructor();                                          \
     BBTK_END_BLACK_BOX_DESTRUCTOR;                                     \
-  }                                                                    
+  }                                                                    \
+  template <class T1, class T2>                                                \
+  void CLASS<T1,T2>::bbLockDescriptor()                                        \
+  {                                                                    \
+    bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance();     \
+  }
 //============================================================================
 
-
+*/
 
 
 
index 9a62efb37ca3b78c4c57837b31098169cc361366..58ae9594c317d3447ce6112633eeb90dbdec934b 100644 (file)
@@ -3,8 +3,8 @@
 Program:   bbtk
 Module:    $RCSfile: bbtkBlackBox.cxx,v $
 Language:  C++
-Date:      $Date: 2008/04/09 11:16:57 $
-Version:   $Revision: 1.9 $
+Date:      $Date: 2008/04/18 12:59:15 $
+Version:   $Revision: 1.10 $
                                                                                 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
 l'Image). All rights reserved. See doc/license.txt or
@@ -36,21 +36,69 @@ PURPOSE.  See the above copyright notices for more information.
 namespace bbtk
 {
 
-//EED
+
   static bool bbmgSomeBoxExecuting = false;
   static bool bbmgFreezeExecution = false;
-  static std::set<BlackBox*> bbmgExecutionList;
+  static std::set<BlackBox::Pointer> bbmgExecutionList;
 
+  //=========================================================================
+  BlackBox::Deleter::Deleter()
+  {
+  }
+  //=========================================================================
+  
+  //=========================================================================
+  void BlackBox::Deleter::Delete(Object* p)
+  {
+    BlackBox* b = dynamic_cast<BlackBox*>(p);
+    if (!b)
+      {
+       bbtkInternalError("BlackBox::Deleter::Delete("<<p->GetObjectName()
+                         <<"["<<p<<"]) : "
+                         <<"dynamic cast to BlackBox* failed !");
+      }
+    std::string name = p->GetObjectName();//b->bbGetNameWithParent();
+    bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\")"<<std::endl);
+
+
+    BlackBoxDescriptor::WeakPointer desc = b->bbGetDescriptor();
+    bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : deleting black box"<<std::endl);
+    
+    b->bbDelete();
+    
+    bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : releasing descriptor ["<<desc.lock()<<"]"<<std::endl);
+    
+    if (!desc.expired()) 
+      {
+       Package::WeakPointer pack = desc.lock()->GetPackage();
+       if (!pack.expired()) 
+         {
+           Package::ReleaseBlackBoxDescriptor(pack,desc);
+         }
+       else 
+         {
+           bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : descriptor package expired (was not held by a package and the box was the last instance)"<<std::endl);
+         }
+      }
+    else
+      {
+       bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : descriptor expired : nothing to do (was not held by a package or the box is a complex black box prototype)"<<std::endl);
+      }
+    bbtkDebugMessage("object",2,"<## BlackBox::Deleter(\""<<name<<"\")"<<std::endl);
+  }
+  //=========================================================================
 
   //=========================================================================
   BlackBox::BlackBox(const std::string &name) 
     : bbmName(name), 
       bbmStatus(MODIFIED), 
       bbmBoxProcessMode("Pipeline"),
-      bbmParent(NULL),
+      bbmParent(),
       bbmExecuting(false)
   {
-    bbtkDebugMessage("Kernel",7,"BlackBox::BlackBox(\""
+    bbtkDebugMessage("object",4,"==> BlackBox::BlackBox(\""
+                    <<name<<"\")"<<std::endl);
+    bbtkDebugMessage("object",4,"<== BlackBox::BlackBox(\""
                     <<name<<"\")"<<std::endl);
   }
   //=========================================================================
@@ -61,10 +109,13 @@ namespace bbtk
     : bbmName(name), 
       bbmStatus(from.bbmStatus), 
       bbmBoxProcessMode(from.bbmBoxProcessMode),
-      bbmParent(NULL),
+      bbmParent(),
       bbmExecuting(false)
   {
-    bbtkDebugMessage("Kernel",7,"BlackBox::BlackBox("
+    bbtkDebugMessage("object",4,"==> BlackBox::BlackBox("
+                    <<from.bbGetFullName()<<",\""
+                    <<name<<"\")"<<std::endl);
+    bbtkDebugMessage("object",4,"<== BlackBox::BlackBox("
                     <<from.bbGetFullName()<<",\""
                     <<name<<"\")"<<std::endl);
   }
@@ -74,22 +125,11 @@ namespace bbtk
   //=========================================================================
   BlackBox::~BlackBox()
   {
-    //    std::cout << "EED BlackBox::~BlackBox 01 [" << bbGetName()<<"]\n";
-    bbtkDebugMessageInc("Kernel",7,"BlackBox::~BlackBox()"<<std::endl);
+    bbtkDebugMessage("object",4,"==> BlackBox::~BlackBox() ["<<bbmName
+                    <<"]"<<std::endl);
     this->bbDesallocateConnectors();
-    //printf("EED BlackBox::~BlackBox 02 \n");
-    bbtkDebugDecTab("Kernel",7);
-  }
-  //=========================================================================
-
-  //=========================================================================
-  /// Destruction method of a black box
-  void BlackBox::bbDelete()
-  {
-    bbtkDebugMessage("Kernel",1,"BlackBox::bbDelete() ["
-                    <<bbGetFullName()<<"]"<<std::endl);    
-    bbGetDescriptor()->UnReference();
-    this->bbUserDelete();
+    bbtkDebugMessage("object",4,"<== BlackBox::~BlackBox() ["<<bbmName
+                    <<"]"<<std::endl);
   }
   //=========================================================================
 
@@ -115,7 +155,7 @@ namespace bbtk
     if (force) bbSetModifiedStatus();
 
     // Calls the main recursive update method 
-    bbBackwardUpdate(0);
+    bbBackwardUpdate(Connection::Pointer());
 
     Wx::EndBusyCursor();
 
@@ -128,7 +168,7 @@ namespace bbtk
   //=========================================================================
   std::string BlackBox::bbGetFullName() const
   { 
-    return bbGetNameWithParent()+"<"+this->bbGetDescriptor()->GetTypeName()+">";
+    return this->bbGetNameWithParent()+"<"+this->bbGetDescriptor()->GetTypeName()+">";
   }
   //=========================================================================
      
@@ -138,9 +178,9 @@ namespace bbtk
   /// Returns the name with the name of the parent prepended if any
   std::string BlackBox::bbGetNameWithParent() const
   {
-    if (bbmParent) 
+    if (bbmParent.lock()
       {
-       return bbmParent->bbGetNameWithParent() + ":" + bbmName;
+       return bbmParent.lock()->bbGetNameWithParent() + ":" + bbmName;
       }
     else 
       {
@@ -230,7 +270,7 @@ namespace bbtk
       {                                                                        
        bbtkDebugMessage("Kernel",8,"* Allocate \""<<i->first<<"\""<<std::endl);
        bbGetInputConnectorMap()[i->second->GetName()] 
-         = new BlackBoxInputConnector(this);
+         = new BlackBoxInputConnector(GetThisPointer<BlackBox>());
       }                                                                        
     const BlackBoxDescriptor::OutputDescriptorMapType& omap 
       = bbGetDescriptor()->GetOutputDescriptorMap();                  
@@ -399,7 +439,7 @@ namespace bbtk
        bbtkDebugMessage("Process",9,
                         "-> Execution triggered by Reactive mode or BoxExecute input change"<<std::endl);
        this->bbSetStatus(MODIFIED); 
-        bbGlobalAddToExecutionList( this );
+        bbGlobalAddToExecutionList( GetThisPointer<BlackBox>() );
       }
     else if ( bbGetStatus() == MODIFIED ) //! this->bbIsUptodate()) 
       { 
@@ -562,7 +602,7 @@ namespace bbtk
  
   //=========================================================================
   /// Connects the input <name> to the connection c
-  void BlackBox::bbConnectInput( const std::string& name, Connection* c)
+  void BlackBox::bbConnectInput( const std::string& name, Connection::Pointer c)
   {
     bbtkDebugMessageInc("Kernel",7,
                        "BlackBox::bbConnectInput(\""<<name<<"\","<<c<<") ["
@@ -584,7 +624,7 @@ namespace bbtk
 
   //=========================================================================  
   /// Connects the output <name> to the connection c
-  void BlackBox::bbConnectOutput( const std::string& name, Connection* c)
+  void BlackBox::bbConnectOutput( const std::string& name, Connection::Pointer c)
   {
     bbtkDebugMessageInc("Kernel",7,
                        "BlackBox::bbConnectOutput(\""<<name<<"\","<<c<<") ["
@@ -604,8 +644,9 @@ 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::Pointer c)
   {
+    if (!c) return;
     bbtkDebugMessageInc("Kernel",7,
                        "BlackBox::bbDisconnectInput(\""<<name
                        <<"\","<<c<<") ["
@@ -626,8 +667,9 @@ 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::Pointer c)
   {
+    if (!c) return;
     bbtkDebugMessageInc("Kernel",7,
                        "BlackBox::bbDisconnectOutput(\""<<name
                        <<"\","<<c<<") ["
@@ -663,11 +705,11 @@ namespace bbtk
     if (bbGetOutputType(output).name() != typeid(std::string).name() ) 
       {
        // Look for factory 
-       Package* p = bbGetDescriptor()->GetPackage();
+       Package::Pointer p = bbGetDescriptor()->GetPackage();
        if ((p != 0) && ( ! p->GetFactorySet().empty() ) )
          {
-           Factory* f = *p->GetFactorySet().begin();
-           BlackBox* a = 0;
+           Factory::Pointer f = p->GetFactorySet().begin()->lock();
+           BlackBox::Pointer a;
            try
              {
                a = f->NewAdaptor(  
@@ -677,7 +719,7 @@ namespace bbtk
              } catch (bbtk::Exception e) 
              {
              }
-           if (a!=NULL){
+           if (a){
              //                        bbUpdate();
              a->bbSetInput("In",bbGetOutput(output));
              a->bbExecute();
@@ -708,11 +750,11 @@ namespace bbtk
     if (bbGetInputType(input) != typeid(std::string)) 
       {
        // Look for factory 
-       Package* p = bbGetDescriptor()->GetPackage();
+       Package::Pointer p = bbGetDescriptor()->GetPackage();
        if ((p != 0) && ( ! p->GetFactorySet().empty() ) )
          {
-           Factory* f = *p->GetFactorySet().begin();
-           BlackBox* a = 0;
+           Factory::Pointer f = p->GetFactorySet().begin()->lock();
+           BlackBox::Pointer a;
            try
              {
                a = f->NewAdaptor(  
@@ -722,7 +764,7 @@ namespace bbtk
              }catch (bbtk::Exception e) 
              {
              }
-           if (a!=NULL)
+           if (a)
              {
                //                      bbUpdate();
                a->bbSetInput("In",bbGetInput(input));
@@ -788,7 +830,7 @@ namespace bbtk
   //=========================================================================
   /// Write Graphviz-dot description in file
   void BlackBox::bbWriteDotFileBlackBox(FILE *ff,
-                                       BlackBox *parentblackbox, 
+                                       BlackBox::Pointer parentblackbox, 
                                        int detail, int level,
                                        bool instanceOrtype,
                                        bool relative_link )
@@ -871,15 +913,15 @@ namespace bbtk
     //    std::cout  << labelStr << std::endl;
 
     // Relation Input
-    if (this!=parentblackbox){
+    if (GetThisPointer<BlackBox>()!=parentblackbox){
       for ( i = mInputConnectorMap.begin(); i != mInputConnectorMap.end(); ++i ) 
        {
          if (i->second)
            {
-             Connection* con = i->second->GetConnection();
+             Connection::Pointer con = i->second->GetConnection();
              if (con!=NULL){
-               BlackBox *a=con->GetBlackBoxFrom();
-               BlackBox *b=con->GetBlackBoxTo();
+               BlackBox::Pointer a=con->GetBlackBoxFrom();
+               BlackBox::Pointer b=con->GetBlackBoxTo();
                fprintf(ff,"  ");
                a->bbWriteDotInputOutputName(ff,false,detail,level);
                if (detail==1)
@@ -904,7 +946,7 @@ namespace bbtk
 
 
   //=========================================================================
-  void BlackBox::bbShowRelations(BlackBox *parentblackbox, 
+  void BlackBox::bbShowRelations(BlackBox::Pointer parentblackbox, 
                                 int detail, int level
                                 /*,Factory *factory*/ )
   {
@@ -937,7 +979,7 @@ namespace bbtk
        ivalue.push_back(bbGetInputAsString(i->first));
        if (ivalue.back().size()>valuelmax) valuelmax = ivalue.back().size();
        std::string s("");
-       Connection* con = i->second->GetConnection();
+       Connection::Pointer con = i->second->GetConnection();
        if (con!=0){
          s = con->GetBlackBoxFrom()->bbGetName();
          s += ".";
@@ -956,14 +998,15 @@ namespace bbtk
        ovalue.push_back(bbGetOutputAsString(o->first));
        if (ovalue.back().size()>valuelmax) valuelmax = ovalue.back().size();
        std::vector<std::string> ss;
-       const std::vector<Connection*>& con = o->second->GetConnectionVector();
-       std::vector<Connection*>::const_iterator c;
+       const std::vector<Connection::WeakPointer>& con 
+         = o->second->GetConnectionVector();
+       std::vector<Connection::WeakPointer>::const_iterator c;
        for (c=con.begin();c!=con.end();++c) 
          {
            std::string s;
-           s = (*c)->GetBlackBoxTo()->bbGetName();
+           s = (*c).lock()->GetBlackBoxTo()->bbGetName();
            s += ".";
-           s += (*c)->GetBlackBoxToInput();
+           s += (*c).lock()->GetBlackBoxToInput();
            ss.push_back(s);
        }  // if con
        oconn.push_back(ss);
@@ -1032,7 +1075,7 @@ namespace bbtk
                         "=> BlackBox::bbGlobalProcessExecutionList()"
                         <<std::endl);     
      
-     std::set<BlackBox*>::iterator i;
+     std::set<BlackBox::Pointer>::iterator i;
      for (i=bbmgExecutionList.begin();
          i!=bbmgExecutionList.end();
          ++i)
@@ -1071,7 +1114,7 @@ namespace bbtk
                return bbmgFreezeExecution; 
        }
 
-    void BlackBox::bbGlobalAddToExecutionList( BlackBox* b )
+  void BlackBox::bbGlobalAddToExecutionList( BlackBox::Pointer b )
        {  
                bbmgExecutionList.insert(b); 
        } 
@@ -1094,6 +1137,8 @@ namespace bbtk
   }
   //=========================================================================
 
+
+
 }  // EO namespace bbtk
 
 // EOF
index f160dd574031f98133aa0cca4b583028f0b02b2b..04843d24cb5224655b7a433c0cdb9363228f9e3d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See doc/license.txt or
@@ -32,7 +32,6 @@
 
 #include "bbtkSystem.h"
 #include "bbtkBlackBoxDescriptor.h"
-//#include "bbtkConnection.h"
 #include "bbtkBlackBoxInputConnector.h"
 #include "bbtkBlackBoxOutputConnector.h"
 #include <set>
@@ -45,17 +44,14 @@ namespace bbtk
   
   class Factory;
 
-  class BBTK_EXPORT BlackBox 
+  class BBTK_EXPORT BlackBox : public Object
   {
-
-
+    BBTK_ABSTRACT_OBJECT_INTERFACE(BlackBox);
   public: 
     //==================================================================
     // INTERFACE
     //==================================================================
-    /// The type of pointer on a BlackBox
-    typedef BlackBox* Pointer;
-
     /// The type of map of output connector pointers
     typedef std::map<std::string, BlackBoxOutputConnector*> 
     OutputConnectorMapType;
@@ -64,14 +60,13 @@ namespace bbtk
     InputConnectorMapType;
 
     /// Returns the pointer on the descriptor of the box
-    virtual BlackBoxDescriptor* bbGetDescriptor() const = 0;
+    virtual BlackBoxDescriptor::Pointer bbGetDescriptor() const = 0;
 
     /// Returns a pointer on a clone of the box with name <name>
-    virtual BlackBox* bbClone(const std::string& name) = 0;
+    virtual BlackBox::Pointer bbClone(const std::string& name) = 0;
 
-    /// Destruction method of a black box
-    virtual void bbDelete();
     /// User overloadable destruction method of a black box
+    /// UNUSED FOR THE MOMENT
     virtual void bbUserDelete();
 
     /// Returns the Name of the Type of the BlackBox
@@ -86,12 +81,12 @@ namespace bbtk
     virtual std::string bbGetFullName() const;
 
     /// Returns the name with the name of the parent prepended if any
-    std::string bbGetNameWithParent() const;
+    virtual std::string bbGetNameWithParent() const;
     
     /// Sets the parent of the BlackBox
     void bbSetParent(BlackBox::Pointer p) { bbmParent = p; }
     /// Returns the parent of the BlackBox, i.e the BlackBox that contains it (0 if none)
-    BlackBox::Pointer bbGetParent() const { return bbmParent; }
+    BlackBox::Pointer bbGetParent() const { return bbmParent.lock(); }
 
 
     /// Main processing method of the box.
@@ -152,14 +147,17 @@ bool reaction = true);
     virtual void bbSetOutput( const std::string &name, Data data) = 0;
 
     /// Connects the input <name> to the connection c
-    virtual void bbConnectInput( const std::string& name, Connection* c);
+    virtual void bbConnectInput( const std::string& name, 
+                                Connection::Pointer c);
     /// Connects the output <name> to the connection c
-    virtual void bbConnectOutput( const std::string& name, Connection* c);
-
+    virtual void bbConnectOutput( const std::string& name, 
+                                 Connection::Pointer c);
     /// Disconnects the input <name> from the connection c
-    virtual void bbDisconnectInput( const std::string& name, Connection* c);
+    virtual void bbDisconnectInput( const std::string& name, 
+                                   Connection::Pointer c);
     /// Disconnects the output <name> from the connection c
-    virtual void bbDisconnectOutput( const std::string& name, Connection* c);
+    virtual void bbDisconnectOutput( const std::string& name, 
+                                    Connection::Pointer c);
 
     ///  Returns the input connectors map
     InputConnectorMapType&  bbGetInputConnectorMap() 
@@ -232,7 +230,7 @@ bool reaction = true);
     ///  (uses bbGetInputAsString / bbGetOutputAsString which use adaptors)
     /// If relative_link is true then creates relative hrefs
     virtual void bbWriteDotFileBlackBox(FILE *ff,
-                                       BlackBox *parentblackbox, 
+                                       BlackBox::Pointer parentblackbox, 
                                        int detail, int level, 
                                        bool instanceOrtype,
                                        bool relative_link );
@@ -242,13 +240,14 @@ bool reaction = true);
                                           int detail, int level);
     
      
-    virtual void bbShowRelations(BlackBox *parentblackbox, 
+    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 *bbFindBlackBox(const std::string &blackboxname) { return NULL;}
+    virtual BlackBox::Pointer bbFindBlackBox(const std::string &blackboxname) 
+    { return BlackBox::Pointer();}
 
     virtual void Check(bool recursive = true);
 
@@ -260,8 +259,6 @@ bool reaction = true);
     BlackBox(const std::string &name);
     /// Constructor from an existing box (copy) with a new name 
     BlackBox(BlackBox& from, const std::string &name);
-    ///  Destructor
-    virtual ~BlackBox();
     //==================================================================
 
 
@@ -295,7 +292,7 @@ bool reaction = true);
     /// - calls bbUpdateChildren
     /// - calls bbShowWidget which shows the widget associated to the box (if any)
   public:
-    virtual IOStatus bbBackwardUpdate(Connection* caller) = 0;
+    virtual IOStatus bbBackwardUpdate(Connection::Pointer caller) = 0;
     //==================================================================
 
     //==================================================================
@@ -309,7 +306,7 @@ bool reaction = true);
     /// - calls bbCreateWidget
     /// - calls bbProcess which is the user callback which does the actual processing
     /// - calls bbUpdateChildren which recursively calls bbForwardUpdate on connections attached the "Child" output
-    // virtual void bbForwardUpdate(Connection* caller) = 0;
+    // virtual void bbForwardUpdate(Connection::Pointer caller) = 0;
     //==================================================================
   protected:
     //==================================================================
@@ -322,7 +319,7 @@ bool reaction = true);
     //==================================================================
     /// Updates the pipeline in upstream-downstream direction along the "Child"-"Parent" connections only.
     /// Does nothing here. Overloaded in WxContainerBlackbox
-    //virtual void bbUpdateChildren( Connection* caller ) { }
+    //virtual void bbUpdateChildren( Connection::Pointer caller ) { }
     //==================================================================
 
     //==================================================================
@@ -333,7 +330,7 @@ bool reaction = true);
     /// Shows the window associated to the box 
     /// (called after bbProcess during bbExecute)
     /// Does nothing here but overloaded in WxBlackBox and WxContainerBlackBox
-    virtual void bbShowWindow(Connection* caller) { }
+    virtual void bbShowWindow(Connection::Pointer caller) { }
  
     virtual void bbHideWindow() {}
    //==================================================================
@@ -352,7 +349,7 @@ bool reaction = true);
     virtual bool bbCanReact() const;
     
     
-    static void bbGlobalAddToExecutionList( BlackBox* b );
+    static void bbGlobalAddToExecutionList( BlackBox::Pointer b );
     static void bbGlobalProcessExecutionList();
 
     //==================================================================
@@ -369,14 +366,31 @@ bool reaction = true);
     bool bbGetExecuting() const { return bbmExecuting; }
     void bbSetExecuting(bool b) { bbmExecuting = b; }
 
+    // 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
+    struct Deleter : public Object::Deleter
+    { 
+      Deleter();
+      void Delete(Object* p);
+    };
+
+    template <class U>
+    static boost::shared_ptr<U> MakeBlackBoxPointer(U* s, bool lock = false)
+    {
+      return MakePointer(s,BlackBox::Deleter(),lock);
+    }
+
+    virtual void bbDelete() { delete this; }
   private:
     
  
     //==================================================================
     // PRIVATE PART 
-    /// Default constructor is private : derived classes must use the constructor with the BlackBox's name
-    BlackBox() {}
-    BlackBox(const BlackBox&) {}
     /// The status of the box
     IOStatus bbmStatus;
     /// The name of the black-box
@@ -390,7 +404,7 @@ bool reaction = true);
     std::string bbmBoxProcessMode;
 
     /// The parent of the black box in the ComplexBlackBox hierarchy
-    BlackBox::Pointer bbmParent;
+    BlackBox::WeakPointer bbmParent;
     //==================================================================
 
     //==================================================================
index 68ba2439d61b71fd5303191ec0b751cb1ed490a8..e0156087f0b80dcf6622b09b72a16ea4ba2bfdcf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxDescriptor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 namespace bbtk
 {
-  
+
+  typedef Package::Pointer PackagePointer;
+
+
+
   //=========================================================================
   /// Default ctor
   BlackBoxDescriptor::BlackBoxDescriptor()  
@@ -38,11 +42,12 @@ namespace bbtk
       mAuthor(""),
       mCategory(""),
       mKind(STANDARD),
-      mPackage(NULL),
-      mRefCount(0)
+      mPackage()
   {
-    bbtkDebugMessage("Kernel",9,
-                    "BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
+    bbtkDebugMessage("object",4,
+                    "==> BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
+   bbtkDebugMessage("object",4,
+                    "<== BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
   }
   //=========================================================================
 
@@ -50,9 +55,9 @@ namespace bbtk
   /// Dtor
   BlackBoxDescriptor::~BlackBoxDescriptor()
   {
-    bbtkDebugMessageInc("Kernel",9,
-                       "BlackBoxDescriptor::~BlackBoxDescriptor() ["
-                       <<mTypeName<<"]"<<std::endl);
+    bbtkDebugMessage("object",4,
+                    "==> BlackBoxDescriptor::~BlackBoxDescriptor() ["
+                    <<mTypeName<<"]"<<std::endl);
 
     // deletes all I/O descriptors
     InputDescriptorMapType::iterator i;
@@ -60,10 +65,41 @@ namespace bbtk
     OutputDescriptorMapType::iterator o;
     for (o=mOutput.begin(); o!=mOutput.end(); ++o) delete o->second;
 
-    bbtkDebugDecTab("Kernel",9);
+    bbtkDebugMessage("object",4,
+                    "<== BlackBoxDescriptor::~BlackBoxDescriptor() ["
+                    <<mTypeName<<"]"<<std::endl);
   }
   //=========================================================================
 
+  /*
+  //=======================================================================
+  /// Release
+  void BlackBoxDescriptor::Release(BlackBoxDescriptor::WeakPointer desc)
+  {
+    bbtkMessage("object",2,"==> BlackBoxDescriptor::Release('"
+               <<desc.lock()->GetTypeName()<<"')"<<std::endl);
+    long c = desc.use_count();
+    bbtkMessage("object",3," - ref count = "<<c<<std::endl);
+    // If only one ref 
+    if ((c == 1) && (desc.lock()->mPackage))
+      {
+       bbtkMessage("object",2," --> No more instance alive = releasing from package"<<std::endl);
+       
+       Package::WeakPointer pack = desc.lock()->mPackage;
+       Package::ReleaseBlackBoxDescriptor(pack,desc);
+      }
+    else 
+      {
+       bbtkMessage("object",2," --> Still some instances alive = Keeping it alive"<<std::endl);
+      }    
+    bbtkMessage("object",2,"<== BlackBoxDescriptor::Release('"
+               <<desc.lock()->GetTypeName()<<"')"<<std::endl);
+  }
+  //=========================================================================
+  */
+
+  /*
   //=========================================================================
   /// Dtor
   void BlackBoxDescriptor::UnReference()
@@ -79,7 +115,7 @@ namespace bbtk
       }
   }
   //=========================================================================
-
+  */
   //=========================================================================
   /// Check
   void BlackBoxDescriptor::Check(bool) const
@@ -244,7 +280,7 @@ namespace bbtk
   /// Returns the full name of the **TYPE** of the black box (+package name)
   std::string BlackBoxDescriptor::GetFullTypeName() const
   {
-    if (mPackage!=0) return mPackage->GetName() + "::" + mTypeName;
+    if (GetPackage()!=0) return GetPackage()->GetName() + "::" + mTypeName;
     return "::" + mTypeName;
   }
   //=========================================================================
index a680b54f81124bbcd195085ee69ec4ddedef4168..4d047c6ef106dd9819bdbb7b5e30005a3f428938 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxDescriptor.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,6 +28,7 @@
 #ifndef __bbtkBlackBoxDescriptor_h__
 #define __bbtkBlackBoxDescriptor_h__
 
+#include "bbtkObject.h"
 #include "bbtkBlackBoxInputDescriptor.h"
 #include "bbtkBlackBoxOutputDescriptor.h"
 #include <map>
@@ -38,10 +39,13 @@ namespace bbtk
 
   class BlackBox;
   class Package;
+  BBTK_FORWARD_DECLARE_POINTER(BlackBox);
+  BBTK_FORWARD_DECLARE_POINTER(Package);
 
   //==========================================================================
-  class BBTK_EXPORT BlackBoxDescriptor
+  class BBTK_EXPORT BlackBoxDescriptor : public Object
   {
+    BBTK_ABSTRACT_OBJECT_INTERFACE(BlackBoxDescriptor);
   public:
     /// The type of descriptor of inputs 
     typedef BlackBoxInputDescriptor InputDescriptor;
@@ -62,11 +66,12 @@ namespace bbtk
     }
     Kind;
 
-    /// Default ctor
-    BlackBoxDescriptor(); 
-    /// Creates an instance with name boxname of the BlackBox
+    /// Releases a descriptor
+    //    static void Release(BlackBoxDescriptor::WeakPointer);
+
+     /// Creates an instance with name boxname of the BlackBox
     /// of which this is the descriptor 
-    virtual BlackBox* CreateInstance(const std::string& boxname) = 0;
+    virtual BlackBoxPointer NewBlackBox(const std::string& boxname) = 0;
 
     /// Returns the name of the **TYPE** of the black box
     const std::string& GetTypeName() const { return mTypeName; }
@@ -83,11 +88,8 @@ namespace bbtk
     /// Returns the category(s) of the BlackBox
     const std::string& GetCategory() const { return mCategory; }
     
-    /// Returns the Package to which the box belongs
-    Package* GetPackage() { return mPackage; }
-    
     /// Returns the Package to which the box belongs (const pointer)
-    const Package* GetPackage() const { return mPackage; }
+    PackagePointer GetPackage() const { return mPackage; }
     
     /// Returns the kind of box 
     Kind GetKind() const { return mKind; }
@@ -122,7 +124,7 @@ namespace bbtk
     void AddToCategory( const std::string&, bool clear = false );
     
     /// Sets the Package to which the box belongs
-    void SetPackage(Package *package) { mPackage = package; }
+    void SetPackage(PackagePointer package) { mPackage = package; }
     
     /// Sets the kind of box 
     void SetKind(Kind kind) { mKind = kind; }
@@ -140,19 +142,10 @@ namespace bbtk
                                  int detail, int level,
                                  const std::string& output_dir = "",
                                  bool relative_link = false );
-
-    /// Increase ref count
-    void Reference() { mRefCount++; }
-    /// Decrease ref count and delete if no more used
-    void UnReference();
-
     ///
     virtual void Check(bool recursive=true) const;
 
   protected:
-    /// Default dtor is protected : use UnRegister to destroy (ref counting)
-    virtual ~BlackBoxDescriptor();
-
     /// Adds an input descriptor
     void AddInputDescriptor( BlackBoxInputDescriptor *d ) 
     { mInput[d->GetName()] = d; }
@@ -172,17 +165,12 @@ namespace bbtk
     /// The kind of box (standard / adaptor)
     Kind mKind;
     /// The Package to which the box belongs
-    Package *mPackage;
+    PackagePointer mPackage;
     /// The inputs 
     InputDescriptorMapType mInput;
     /// The outputs 
     OutputDescriptorMapType mOutput;
 
-    /// Reference counting
-    int mRefCount;
-    
-  private:
-    BlackBoxDescriptor(const BlackBoxDescriptor&) {}
   };
   // class BlackBoxDescriptor
   //==========================================================================
index 9269ec1d1f235767faca011893777a6847fded88..1bbde7331d0a0d202ed8821a029a4b9e2cb8d5df 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxInputConnector.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/05 13:23:46 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
  */
 #include "bbtkBlackBoxInputConnector.h"
 #include "bbtkMessageManager.h"
+#include "bbtkBlackBox.h"
 
 namespace bbtk
 {
-  BlackBoxInputConnector::BlackBoxInputConnector(BlackBox* b)  
-    : mBox(b), mConnection(0), mStatus(MODIFIED)
+  BlackBoxInputConnector::BlackBoxInputConnector(BlackBox::Pointer b)  
+    : mBox(b), mConnection(), mStatus(MODIFIED)
   {
     bbtkDebugMessage("Kernel",9,"BlackBoxInputConnector::BlackBoxInputConnector()"<<std::endl);
   }
@@ -35,21 +36,20 @@ namespace bbtk
   BlackBoxInputConnector::~BlackBoxInputConnector() 
   {
     bbtkDebugMessageInc("Kernel",9,"BlackBoxInputConnector::~BlackBoxInputConnector()"<<std::endl);
-    if (mConnection) delete mConnection;
     bbtkDebugDecTab("Kernel",9);
   }
   
-  void BlackBoxInputConnector::SetConnection(Connection* c) 
+  void BlackBoxInputConnector::SetConnection(Connection::Pointer c) 
   { 
     bbtkDebugMessage("Kernel",9,"BlackBoxInputConnector::SetConnection("<<c<<")"<<std::endl);
     mConnection = c; 
   }
   
-  void BlackBoxInputConnector::UnsetConnection(Connection* c) 
+  void BlackBoxInputConnector::UnsetConnection(Connection::Pointer c) 
   { 
     bbtkDebugMessage("Kernel",9,"BlackBoxInputConnector::UnsetConnection("
                     <<c<<")"<<std::endl);
-    mConnection = 0; 
+    mConnection.reset();
   }
   
   IOStatus BlackBoxInputConnector::BackwardUpdate()
@@ -57,9 +57,9 @@ namespace bbtk
     bbtkDebugMessageInc("Process",4,"BlackBoxInputConnector::BackwardUpdate()"
                        <<std::endl);
 
-    if (mConnection) 
+    if (mConnection.lock()
       {
-       IOStatus s = mConnection->BackwardUpdate();
+       IOStatus s = mConnection.lock()->BackwardUpdate();
        mStatus = s;
       }
     else 
index 6575a8aa3282be442aa175bf0af2a5c98a5eaaa2..788fb4a12cd64d8240a42f2a81ebbcf2f3b3c670 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxInputConnector.h,v $
   Language:  C++
-  Date:      $Date: 2008/01/22 15:02:00 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 namespace bbtk
 {
 
+  class BlackBox;
+  BBTK_FORWARD_DECLARE_POINTER(BlackBox);
 
   class BBTK_EXPORT BlackBoxInputConnector 
   {
   public:
      
     /// Ctor
-    BlackBoxInputConnector(BlackBox* b);
+    BlackBoxInputConnector(BlackBoxPointer b);
     /// Dtor
     ~BlackBoxInputConnector();    
     /// Sets a connection
-    void SetConnection(Connection* c);
+    void SetConnection(Connection::Pointer c);
     /// Unsets the connection 
     /// The parameter is USELESS today but would be useful if we allow multiple connections on inputs
-    void UnsetConnection(Connection* c);
+    void UnsetConnection(Connection::Pointer c);
   
     IOStatus BackwardUpdate();
 
     /// Returns the connection plugged into this input (const)
-    const Connection* GetConnection() const { return mConnection; }
-    /// Returns the connection plugged into this input
-    Connection* GetConnection() { return mConnection; }
+    Connection::Pointer GetConnection() const { return mConnection.lock(); }
     /// Returns true iff a connection is connected to it
-    bool IsConnected() const { return (mConnection != 0); }
+    bool IsConnected() const { return (mConnection.lock() != 0); }
     /// Returns the status of the input (UPTODATE | MODIFIED)
     const IOStatus& GetStatus() const { return mStatus; }
     ///
-    BlackBox* GetBlackBox() const { return mBox; } 
+    BlackBoxPointer GetBlackBox() const { return mBox.lock(); } 
   private:
     /// 
-    BlackBox* mBox;
+    BlackBoxWeakPointer mBox;
     /// The connection plugged into the input
-    Connection* mConnection;
+    Connection::WeakPointer mConnection;
     /// The status of the input (UPTODATE | MODIFIED)
     IOStatus mStatus;
   };
index d2ee80e74dec872efd777472318e9f46e7dcf3ae..af6bf5f21ed88febf007ea7e523d198dcf525aa7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -37,19 +37,21 @@ namespace bbtk
 
   BlackBoxOutputConnector::~BlackBoxOutputConnector() 
   {
-    bbtkDebugMessageInc("Kernel",9,
-                       "BlackBoxOutputConnector::~BlackBoxOutputConnector()"
-                       <<std::endl);
-    std::vector<Connection*>::iterator i;
-    for (i=mConnection.begin();i!=mConnection.end();++i) 
-      {
-       delete *i;
-      }
-    bbtkDebugDecTab("Kernel",9);
+    bbtkDebugMessage("Kernel",9,
+                    "==> BlackBoxOutputConnector::~BlackBoxOutputConnector()"
+                    <<std::endl);
+    ConnectionVector::iterator i;
+    for (i=mConnection.begin();
+        i!=mConnection.end();
+        ++i)
+      (*i) = Connection::WeakPointer();
+    bbtkDebugMessage("Kernel",9,
+                    "<== BlackBoxOutputConnector::~BlackBoxOutputConnector()"
+                    <<std::endl);
   }
 
   ///
-  void BlackBoxOutputConnector::SetConnection(Connection* c)
+  void BlackBoxOutputConnector::SetConnection(Connection::Pointer c)
   {
     bbtkDebugMessage("Kernel",9,"BlackBoxOutputConnector::SetConnection("
                     <<c<<")"<<std::endl);
@@ -59,14 +61,26 @@ namespace bbtk
 
 
   ///
-  void BlackBoxOutputConnector::UnsetConnection(Connection* c)
+  void BlackBoxOutputConnector::UnsetConnection(Connection::Pointer c)
   {
     bbtkDebugMessageInc("Kernel",9,"BlackBoxOutputConnector::UnsetConnection("
                     <<c<<")"<<std::endl);
 
-    c->Check();
-    std::vector<Connection*>::iterator i
-      = find(mConnection.begin(),mConnection.end(),c);
+    if (!c) 
+      {
+       bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : invalid connection");
+
+      }
+    //    c->Check();
+    //Connection::WeakPointer w(c);
+    ConnectionVector::iterator i;
+    //      = find(mConnection.begin(),mConnection.end(),c);
+    for (i=mConnection.begin();
+        i!=mConnection.end();
+        ++i)
+      {
+       if (i->lock()==c) break;
+      }
     if (i==mConnection.end())
       {
        bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : connection is absent from connections list");
@@ -83,10 +97,10 @@ namespace bbtk
     bbtkDebugMessageInc("Process",5,
                        "BlackBoxOutputConnector::SetModifiedStatus()"
                        <<std::endl);
-    std::vector<Connection*>::iterator i;
+    ConnectionVector::iterator i;
     for (i=mConnection.begin();i!=mConnection.end();++i) 
       {
-       (*i)->SetModifiedStatus();
+       (*i).lock()->SetModifiedStatus();
       }
     
     bbtkDebugDecTab("Process",5);
index dab12742c24cece2d395837a7b46d92bb99e3fd6..1ec2c361aa2f68236660423c18fcb733d6b2e43a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxOutputConnector.h,v $
   Language:  C++
-  Date:      $Date: 2008/01/22 15:02:00 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -42,15 +42,16 @@ namespace bbtk
      
     BlackBoxOutputConnector();
     ~BlackBoxOutputConnector();
-    void SetConnection(Connection* c);
-    void UnsetConnection(Connection* c);
+    void SetConnection(Connection::Pointer c);
+    void UnsetConnection(Connection::Pointer c);
     //IOStatus Update();
     void SetModifiedStatus();
-    const std::vector<Connection*>& GetConnectionVector() const { return mConnection; }
+    typedef std::vector<Connection::WeakPointer> ConnectionVector;
+    const ConnectionVector& GetConnectionVector() const { return mConnection; }
     
   private:
     /// The vector of output connections
-    std::vector<Connection*> mConnection;
+    ConnectionVector mConnection;
     /// The status of the output 
     //IOStatus mStatus;
   };
index dbd76efd197b83a0a697152a58ce75743c09934e..c494d6555c6a4cd0bfdf1df7e47fda954ab3603c 100644 (file)
@@ -3,8 +3,8 @@
 Program:   bbtk
 Module:    $RCSfile: bbtkComplexBlackBox.cxx,v $
 Language:  C++
-Date:      $Date: 2008/04/09 11:16:57 $
-Version:   $Revision: 1.9 $
+Date:      $Date: 2008/04/18 12:59:15 $
+Version:   $Revision: 1.10 $
                                                                                 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
 l'Image). All rights reserved. See Doc/License.txt or
@@ -29,19 +29,37 @@ PURPOSE.  See the above copyright notices for more information.
 namespace bbtk
 {
 
+  //==========================================================================
+  /// Creates a new complex black box
+  ComplexBlackBox::Pointer ComplexBlackBox::New(const std::string& name,
+                                               ComplexBlackBoxDescriptor::Pointer desc)
+  {
+    bbtkDebugMessage("object",1,"##> ComplexBlackBox::New('"<<name<<"','"<<
+                    desc->GetTypeName()<<"')" <<bbtkendl);
+    ComplexBlackBox::Pointer p = 
+      MakeBlackBoxPointer(new ComplexBlackBox(name,desc));
+    bbtkDebugMessage("object",2,"<## ComplexBlackBox::New('"<<name<<"','"<<
+                    desc->GetTypeName()<<"')" <<bbtkendl);
+    return p;
+  }
+  //==========================================================================
 
   //=======================================================================
   /// Usefull constructor 
   ComplexBlackBox::ComplexBlackBox(const std::string &name,
-                                  ComplexBlackBoxDescriptor* desc)
-    : BlackBox(name),
-      mDescriptor(desc)
+                                  ComplexBlackBoxDescriptor::Pointer desc)
+    : 
+    BlackBox(name),
+    mLockedDescriptor(desc),
+    mDescriptor(desc)
   {
-    bbtkDebugMessageInc("Kernel",9,
-                       "ComplexBlackBox::ComplexBlackBox(\""
-                       <<name<<"\")"<<std::endl);
+    bbtkDebugMessage("object",3,
+                    "##> ComplexBlackBox::ComplexBlackBox(\""
+                    <<name<<"\")"<<std::endl);
     bbAllocateConnectors();
-    bbtkDebugDecTab("Kernel",9);
+    bbtkDebugMessage("object",3,
+                    "<## ComplexBlackBox::ComplexBlackBox(\""
+                    <<name<<"\")"<<std::endl);
   }
   //=======================================================================
 
@@ -50,50 +68,52 @@ namespace bbtk
   ComplexBlackBox::ComplexBlackBox(ComplexBlackBox& from, 
                                   const std::string &name)
     : BlackBox(from,name),
+      // The locked descriptor is copied from the unlocked one 
+      // to make the box a non-prototype !!
+      mLockedDescriptor(from.mDescriptor),
       mDescriptor(from.mDescriptor),
      mExecutionList(from.mExecutionList)    
   {
-    bbtkDebugMessageInc("Kernel",9,
-                       "ComplexBlackBox::ComplexBlackBox(\""
+    bbtkDebugMessage("object",3,
+                       "##> ComplexBlackBox::ComplexBlackBox(\""
                        <<from.bbGetName()<<"\",\""
                        <<name<<"\")"<<std::endl);
-
-    bbtkDebugMessageInc("Kernel",9,"* Cloning Black Boxes"<<std::endl);
+    bbtkDebugMessage("object",4,"  * Cloning Black Boxes"<<std::endl);
     BlackBoxMapType::const_iterator i;
     for ( i = from.mBlackBoxMap.begin(); i != from.mBlackBoxMap.end(); ++i ) 
       {
-       bbtkDebugMessageInc("Kernel",9,"* Cloning \""<<i->first<<"\""<<std::endl);
-       BlackBox* B = i->second->bbClone(i->second->bbGetName());
+       bbtkDebugMessageInc("object",5,"    * Cloning \""<<i->first<<"\""<<std::endl);
+       BlackBox::Pointer B = i->second->bbClone(i->second->bbGetName());
        bbUnsafeAddBlackBox(B);
        
-       bbtkDebugDecTab("Kernel",9);
       }
-    bbtkDebugDecTab("Kernel",9);
    
-    bbtkDebugMessageInc("Kernel",9,"* Cloning Connections"<<std::endl);
+    bbtkDebugMessage("object",4,"  * Cloning Connections"<<std::endl);
     ConnectionListType::const_iterator j;
     for ( j = from.mConnectionList.begin(); j != from.mConnectionList.end(); ++j ) 
       {
-       bbtkDebugMessageInc("Kernel",9,"* Cloning \""<<
-                           (*j)->GetFullName()<<"\""<<std::endl);
+       bbtkDebugMessage("object",5,"    * Cloning \""<<
+                        (*j)->GetFullName()<<"\""<<std::endl);
+
+       BlackBox::Pointer bbfrom = bbGetBlackBox( (*j)->GetOriginalBlackBoxFrom()->bbGetName() );
+       BlackBox::Pointer bbto = bbGetBlackBox( (*j)->GetOriginalBlackBoxTo()->bbGetName() );
 
-       BlackBox* bbfrom = bbGetBlackBox( (*j)->GetOriginalBlackBoxFrom()->bbGetName() );
-       BlackBox* bbto = bbGetBlackBox( (*j)->GetOriginalBlackBoxTo()->bbGetName() );
-       Connection* c = mDescriptor->GetFactory()-> 
+       Connection::Pointer c = mDescriptor.lock()->GetFactory()-> 
          NewConnection( bbfrom, 
                         (*j)->GetOriginalBlackBoxFromOutput(), 
                         bbto, 
                         (*j)->GetOriginalBlackBoxToInput() );
        
-
+       //c->Check();
        bbAddConnection(c);
 
-       bbtkDebugDecTab("Kernel",9);
       }
-    bbtkDebugDecTab("Kernel",9);
 
     bbAllocateConnectors();
-    bbtkDebugDecTab("Kernel",9);    
+    bbtkDebugMessage("object",3,
+                       "<## ComplexBlackBox::ComplexBlackBox(\""
+                       <<from.bbGetName()<<"\",\""
+                       <<name<<"\")"<<std::endl);
   }
   //=======================================================================
 
@@ -101,39 +121,33 @@ namespace bbtk
   ///  Destructor
   ComplexBlackBox::~ComplexBlackBox()
   {
-    bbtkDebugMessageInc("Kernel",1,
-                       "ComplexBlackBox::~ComplexBlackBox() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-    
-    bbtkDebugMessageInc("Kernel",1,"* Delete Connections"<<std::endl);
-    ConnectionListType::iterator j;
-    for ( j = mConnectionList.begin(); j != mConnectionList.end(); ++j ) 
-      {
-       bbtkDebugMessageInc("Kernel",1,"* Delete \""<<
-                           (*j)->GetFullName()<<"\""<<std::endl);
-       delete *j;
-       bbtkDebugDecTab("Kernel",9);
-      }
-    bbtkDebugDecTab("Kernel",9);
-
-    
-    bbtkDebugMessageInc("Kernel",1,"* Delete Black Boxes"<<std::endl);
-    BlackBoxMapType::iterator i;
-    for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i ) 
+    bbtkDebugMessage("object",3,
+                    "==> ComplexBlackBox::~ComplexBlackBox() ["
+                    <<bbGetName()<<"]"<<std::endl);
+
+    bbtkDebugMessage("object",4,
+                    " -> Releasing connections"<<std::endl);
+    mConnectionList.clear();
+    bbtkDebugMessage("object",4,
+                    " -> Releasing boxes"<<std::endl);
+    mBlackBoxMap.clear();
+
+    /*    
+    //    Clear();
+    this->bbDesallocateConnectors();
+    if (mLockedDescriptor) 
       {
-       bbtkDebugMessageInc("Kernel",1,"* Delete \""<<i->first<<"\""<<std::endl);
-       i->second->bbDelete();
-       bbtkDebugDecTab("Kernel",1);
+       bbtkMessage("object",3," --> Releasing descriptor"<<std::endl);
+       mLockedDescriptor.reset();                                      
+       if (!mDescriptor.expired()) BlackBoxDescriptor::Release(mDescriptor);
       }
-    bbtkDebugDecTab("Kernel",1);
-    
-    bbtkDebugMessage("Kernel",1,"EO ComplexBlackBox::~ComplexBlackBox  ["
-                    <<bbGetFullName()<<"]"<<std::endl);
-    
-    this->bbDesallocateConnectors();
-    bbtkDebugDecTab("Kernel",1);   
+    */
+    bbtkDebugMessage("object",3,
+                    "<== ComplexBlackBox::~ComplexBlackBox() ["
+                    <<bbGetName()<<"]"<<std::endl);
   } 
   //=======================================================================
 
   //=========================================================================
   /// Allocates the i/o connectors of the black box
@@ -143,7 +157,7 @@ namespace bbtk
                        "ComplexBlackBox::bbAllocateConnectors() ["
                        <<bbGetFullName()<<"]"
                        <<std::endl);   
-
+    /*
     // Input connectors
     const BlackBoxDescriptor::InputDescriptorMapType& imap 
       = bbGetDescriptor()->GetInputDescriptorMap(); 
@@ -183,6 +197,9 @@ namespace bbtk
        bbGetOutputConnectorMap()[o->second->GetName()] = c;
        //new BlackBoxOutputConnector();
       }
+
+*/
+
     bbtkDebugDecTab("Kernel",8);  
   }
   //=========================================================================
@@ -200,27 +217,25 @@ namespace bbtk
     // but by the internal boxes. Hence **DO NOT** desallocate !
     // just clear the maps to avoid that 
     // BlackBox::bbDesallocateConnectors delete the connectors
-    bbGetInputConnectorMap().clear();
+    /*
+   bbGetInputConnectorMap().clear();
     bbGetOutputConnectorMap().clear();
-
+    */
     bbtkDebugDecTab("Kernel",8);  
 
   }
   //=========================================================================
 
   //=======================================================================
-  BlackBox* ComplexBlackBox::bbClone(const std::string& name)
+  BlackBox::Pointer ComplexBlackBox::bbClone(const std::string& name)
   {
     bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::bbClone(\""<<name<<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);
     
     ComplexBlackBox* CBB = new ComplexBlackBox(*this,name);
-    bbGetDescriptor()->Reference();           
-
-    bbtkDebugDecTab("Kernel",9);   
-
-    return CBB;
+    return MakeBlackBoxPointer(CBB);
   }
   //=======================================================================
 
@@ -250,7 +265,7 @@ namespace bbtk
       }
     else 
       {
-       std::map<std::string, BlackBox*>::iterator i;
+       std::map<std::string, BlackBox::Pointer>::iterator i;
        for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i)
          {
            i->second->bbExecute(force);
@@ -296,7 +311,7 @@ namespace bbtk
   //==================================================================
 
   //==================================================================
-  IOStatus ComplexBlackBox::bbBackwardUpdate(Connection* caller)
+  IOStatus ComplexBlackBox::bbBackwardUpdate(Connection::Pointer caller)
   {
     bbtkDebugMessageInc("Process",1,
                        "ComplexBlackBox::bbBackwardUpdate("
@@ -466,7 +481,7 @@ namespace bbtk
 
   //=========================================================================
   /// Connects the input <name> to the connection c
-  void ComplexBlackBox::bbConnectInput( const std::string& name, Connection* c)
+  void ComplexBlackBox::bbConnectInput( const std::string& name, Connection::Pointer c)
   {
     bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::bbConnectInput(\""
@@ -477,7 +492,7 @@ namespace bbtk
    ComplexBlackBoxInputDescriptor* d = (ComplexBlackBoxInputDescriptor*)
       bbGetDescriptor()->GetInputDescriptor(name);
 
-   BlackBox* t = bbGetBlackBox(d->GetTarget());
+   BlackBox::Pointer t = bbGetBlackBox(d->GetTarget());
    c->SetBlackBoxTo(t);
    c->SetBlackBoxToInput(d->GetInput());
    t->bbConnectInput(d->GetInput(),c);
@@ -492,7 +507,7 @@ namespace bbtk
 
   //=========================================================================  
   /// Connects the output <name> to the connection c
-  void ComplexBlackBox::bbConnectOutput( const std::string& name, Connection* c)
+  void ComplexBlackBox::bbConnectOutput( const std::string& name, Connection::Pointer c)
   {
     bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::bbConnectOutput(\""
@@ -502,12 +517,13 @@ namespace bbtk
    ComplexBlackBoxOutputDescriptor* d = (ComplexBlackBoxOutputDescriptor*)
       bbGetDescriptor()->GetOutputDescriptor(name);
 
-   BlackBox* t = bbGetBlackBox(d->GetTarget());
+   BlackBox::Pointer t = bbGetBlackBox(d->GetTarget());
+
    c->SetBlackBoxFrom(t);
    c->SetBlackBoxFromOutput(d->GetOutput());
    t->bbConnectOutput(d->GetOutput(),c);
   
-   bbtkMessage("Debug",1,"ComplexBlackBox["<<bbGetFullName()<<"]::bbConnectOutput : "
+   bbtkMessage("Debug",5,"ComplexBlackBox["<<bbGetFullName()<<"]::bbConnectOutput : "
               <<c->GetFullName()<<std::endl);
 
     bbtkDebugDecTab("Kernel",7);
@@ -517,7 +533,7 @@ namespace bbtk
 
   //==================================================================
   /// Adds the black box to the complex box
-  void ComplexBlackBox::bbAddBlackBox( BlackBox* b)
+  void ComplexBlackBox::bbAddBlackBox( BlackBox::Pointer b)
   {
     bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::AddBlackBox(\""<<b->bbGetName()
@@ -529,7 +545,7 @@ namespace bbtk
        bbtkError("a black box called \""<<b->bbGetName()
                  <<"\" already exists");
       }
-    b->bbSetParent(this);
+    b->bbSetParent(GetThisPointer<ComplexBlackBox>());
     mBlackBoxMap[b->bbGetName()] = b;
 
     bbtkDebugDecTab("Kernel",7);
@@ -538,14 +554,14 @@ namespace bbtk
 
   //==================================================================
   /// Adds the black box to the complex box (unsafe)
-  void ComplexBlackBox::bbUnsafeAddBlackBox( BlackBox* b)
+  void ComplexBlackBox::bbUnsafeAddBlackBox( BlackBox::Pointer b)
   {
     bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::UnsafeAddBlackBox(\""<<b->bbGetName()
                        <<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);  
     
-    b->bbSetParent(this);
+    b->bbSetParent(GetThisPointer<ComplexBlackBox>());
     mBlackBoxMap[b->bbGetName()] = b;
 
     bbtkDebugDecTab("Kernel",7);
@@ -554,13 +570,39 @@ namespace bbtk
 
   //==================================================================
   /// Removes the black box from the complex box
-  void ComplexBlackBox::bbRemoveBlackBox( const std::string& name )
+  void ComplexBlackBox::bbRemoveBlackBox( const std::string& name, 
+                                         bool remove_connections )
   {
     bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::RemoveBlackBox(\""<<name<<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);  
 
-    bbtkError("ComplexBlackBox::RemoveBlackBox not implemented");
+    BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
+    if ( i == mBlackBoxMap.end() ) 
+      {
+       bbtkError("the black box \""<<name<<"\" does not exist");
+      }
+    BlackBox::WeakPointer p = i->second;
+    
+    if (remove_connections)
+      {
+       ConnectionListType::const_iterator j;
+       for ( j = mConnectionList.begin(); 
+             j != mConnectionList.end(); ++j ) 
+         {
+           //(*j)->Check();
+         }
+      }
+    if (p.use_count()!=1) 
+      {
+       bbtkError("the black box \""<<name<<"\" is still connected");
+      }
+    
+    mBlackBoxMap.erase(i);
+    
+
+    // Unload orphan dl packages 
+    Package::UnLoadReleasedDynamicallyLoadedPackages();
 
     bbtkDebugDecTab("Kernel",7);
   }
@@ -568,7 +610,7 @@ namespace bbtk
 
   //==================================================================
   /// Adds the connection to the complex box
-  void ComplexBlackBox::bbAddConnection( Connection* c)
+  void ComplexBlackBox::bbAddConnection( Connection::Pointer c)
   {
     bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::AddConnection(\""<<"..."<<"\") ["
@@ -583,7 +625,7 @@ namespace bbtk
 
   //==================================================================
   /// Returns the black box with name <name>
-  BlackBox* ComplexBlackBox::bbGetBlackBox( const std::string& name )
+  BlackBox::Pointer ComplexBlackBox::bbGetBlackBox( const std::string& name )
   {
     bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::GetBlackBox(\""<<name<<"\") ["
@@ -603,7 +645,7 @@ namespace bbtk
   //==================================================================
   /// Returns the black box with name <name> : does not throw an exception 
   /// if it does not exist but return a null pointer
-  BlackBox* ComplexBlackBox::bbUnsafeGetBlackBox( const std::string& name )
+  BlackBox::Pointer ComplexBlackBox::bbUnsafeGetBlackBox( const std::string& name )
   {
     bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::UnsafeGetBlackBox(\""<<name<<"\") ["
@@ -614,7 +656,7 @@ namespace bbtk
     if ( i == mBlackBoxMap.end() ) 
       {
        bbtkDebugDecTab("Kernel",9);
-       return 0;
+       return BlackBox::Pointer();
       }
 
     bbtkDebugDecTab("Kernel",9);
@@ -658,9 +700,9 @@ namespace bbtk
 
 
   //=========================================================================
-  BlackBox *ComplexBlackBox::bbFindBlackBox(const std::string &blackboxname)
+  BlackBox::Pointer ComplexBlackBox::bbFindBlackBox(const std::string &blackboxname)
   {
-    BlackBox *blackbox=NULL;
+    BlackBox::Pointer blackbox;
     std::string subname="";
     std::string restname="";
     std::string delimiters(">");
@@ -679,11 +721,7 @@ namespace bbtk
     }
 
     BlackBoxMapType::iterator i = mBlackBoxMap.find(subname);
-    if ( i == mBlackBoxMap.end() ) 
-    {
-          blackbox = NULL;
-    } 
-    else 
+    if ( i != mBlackBoxMap.end() ) 
     {
        blackbox = i->second;
        if (restname!="")
@@ -737,7 +775,9 @@ namespace bbtk
     fprintf(ff,"rankdir=LR%s\n",";");
     fprintf(ff,"node [shape=record]%s\n",";");
 
-    this->bbWriteDotFileBlackBox(ff,this,detail,level,
+    this->bbWriteDotFileBlackBox(ff,
+                                GetThisPointer<ComplexBlackBox>(),
+                                detail,level,
                                 instanceOrtype,
                                 relative_link );
 
@@ -778,14 +818,14 @@ namespace bbtk
   //=========================================================================
   /// Write Graphviz-dot description in file 
   void ComplexBlackBox::bbWriteDotFileBlackBox(FILE *ff,
-                                              BlackBox *parentblackbox, 
+                                              BlackBox::Pointer parentblackbox, 
                                               int detail, int level,
                                               bool instanceOrtype,
                                               bool relative_link )   
   {
     std::string tmp1;
     std::string valueStr("");
-    Package *package = this->bbGetDescriptor()->GetPackage(); 
+    Package::Pointer package = this->bbGetDescriptor()->GetPackage(); 
 
     if (package!=NULL)
     {
@@ -809,7 +849,7 @@ namespace bbtk
     }
 
     std::string boxname="["+bbGetTypeName()+"]";
-    if (this!=parentblackbox)
+    if (GetThisPointer<ComplexBlackBox>()!=parentblackbox)
     {
        if (detail==0)
            {
@@ -916,7 +956,9 @@ namespace bbtk
       {
        if (level>-1)
          {
-           j->second->bbWriteDotFileBlackBox(ff,parentblackbox,detail,
+           j->second->bbWriteDotFileBlackBox(ff,
+                                             parentblackbox,
+                                             detail,
                                              level-1,
                                              instanceOrtype,
                                              relative_link);
@@ -943,7 +985,7 @@ namespace bbtk
                fprintf(ff,":%s",cbbid->GetName().c_str() );
              }
            fprintf(ff,"->" );
-           BlackBox *bb = bbGetBlackBox( cbbid->GetTarget() ); 
+           BlackBox::Pointer bb = bbGetBlackBox( cbbid->GetTarget() ); 
            bb->bbWriteDotInputOutputName(ff,true,detail,level);
            if (detail==1)
              {
@@ -964,7 +1006,7 @@ namespace bbtk
          {
            ComplexBlackBoxOutputDescriptor *cbbod = (ComplexBlackBoxOutputDescriptor*)yy->second;
            fprintf(ff,"  ");
-           BlackBox *bb = bbGetBlackBox( cbbod->GetTarget() ); 
+           BlackBox::Pointer bb = bbGetBlackBox( cbbod->GetTarget() ); 
            bb->bbWriteDotInputOutputName(ff,false,detail,level);
            if (detail==1)
              {
@@ -984,16 +1026,16 @@ namespace bbtk
 
 
        // Relation from the out side of this ComplexBlackBox with its Inputs
-    if (this!=parentblackbox) {
+    if (GetThisPointer<ComplexBlackBox>()!=parentblackbox) {
       for ( ii = bbGetInputConnectorMap().begin(); 
            ii != bbGetInputConnectorMap().end(); ++ii ) 
        {
          if (ii->second)
            {
-             Connection* con = ii->second->GetConnection();
+             Connection::Pointer con = ii->second->GetConnection();
              if (con!=NULL){
-               BlackBox *a=con->GetBlackBoxFrom();
-               BlackBox *b=con->GetBlackBoxTo();
+               BlackBox::Pointer a=con->GetBlackBoxFrom();
+               BlackBox::Pointer b=con->GetBlackBoxTo();
                fprintf(ff,"  ");
                a->bbWriteDotInputOutputName(ff,false,detail,level);
                if (detail==1)
@@ -1050,7 +1092,7 @@ namespace bbtk
      for ( j = mConnectionList.begin(); 
           j != mConnectionList.end(); ++j ) 
        {
-        (*j)->Check();
+        //(*j)->Check();
        }
      bbtkMessage("Debug",1,"**** Checking Complex Black Box "<<(void*)this
                 <<" ["<<bbGetFullName()<<"] ... OK"<<std::endl);
@@ -1058,4 +1100,73 @@ namespace bbtk
   }
   //=======================================================================
 
+  //=========================================================================
+  /// Returns the name with the name of the parent prepended if any
+  std::string ComplexBlackBox::bbGetNameWithParent() const
+  {
+    if (!IsAPrototype()) return BlackBox::bbGetNameWithParent();
+    if (bbGetDescriptor()) 
+      {
+       return bbGetDescriptor()->GetFullTypeName() + ":" + bbGetName();
+      }
+    else 
+      {
+       return std::string(":") + bbGetName();
+      }
+  } 
+  //=========================================================================
+
+  //==========================================================================
+  std::string ComplexBlackBox::GetObjectName() const
+  {
+    return std::string("ComplexBlackBox '")+bbGetNameWithParent()
+      +std::string("'");
+  }
+  //==========================================================================
+  
+  //==========================================================================
+  std::string ComplexBlackBox::GetObjectInfo() const 
+  {
+    std::stringstream i;
+    i << "  - "<<mBlackBoxMap.size() << " boxes / "
+      <<mConnectionList.size() << " connections" << std::endl;
+    return i.str();
+  }
+  //==========================================================================
+
+  //==========================================================================
+  size_t  ComplexBlackBox::GetObjectSize() const 
+  {
+    size_t s = Superclass::GetObjectSize();
+    s += ComplexBlackBox::GetObjectInternalSize();
+    return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  ComplexBlackBox::GetObjectInternalSize() const 
+  {
+    size_t s = sizeof(ComplexBlackBox);
+    return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  ComplexBlackBox::GetObjectRecursiveSize() const 
+  {
+    size_t s = Superclass::GetObjectRecursiveSize();
+    s += ComplexBlackBox::GetObjectInternalSize();
+    BlackBoxMapType::const_iterator i;
+    for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i ) 
+      {
+       s += i->second->GetObjectRecursiveSize();
+      }
+    ConnectionListType::const_iterator j;
+    for ( j = mConnectionList.begin(); 
+         j != mConnectionList.end(); ++j ) 
+      {
+       s += (*j)->GetObjectRecursiveSize();
+      }
+    return s;
+  }
+  //==========================================================================
+
 }
index 6c041f4b117065eda8a9f2d9f105d3bdd145f517..3a5d8fb7c5ccbfdddd83c1eaa89ed9e336b21cf6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkComplexBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -44,16 +44,27 @@ namespace bbtk
   //==================================================================
   class BBTK_EXPORT ComplexBlackBox : public bbtk::BlackBox
   {
+    BBTK_OBJECT_INTERFACE(ComplexBlackBox);
     friend class ComplexBlackBoxDescriptor;
+    typedef BlackBox Superclass;
   public: 
     //==================================================================
     // PUBLIC PART : ACCESSIBLE TO THE END-USER
     /// Returns the pointer on the box' descriptor
-    BlackBoxDescriptor* bbGetDescriptor() const { return mDescriptor; }
+    BlackBoxDescriptor::Pointer bbGetDescriptor() const { return mDescriptor.lock(); }
     /// Returns a pointer on a new instance with name <name>
     //BlackBox* bbNew(const std::string& name);
     /// Returns a pointer on a clone of the box with name <name>
-    BlackBox* bbClone(const std::string& name);
+    BlackBox::Pointer bbClone(const std::string& name);
+
+    /// Clear
+    void Clear();
+    /// Set as prototype
+    void SetAsPrototype() { mLockedDescriptor.reset(); }
+    /// Returns true if it is a prototype 
+    bool IsAPrototype() const { return (!mLockedDescriptor); }
+
+    std::string bbGetNameWithParent() const;
 
     void bbExecute(bool force = false);
   
@@ -67,16 +78,18 @@ namespace bbtk
                                      bool setModified = true);
 
      /// Connects the input <name> to the connection c
-    virtual void bbConnectInput( const std::string& name, Connection* c);
+    virtual void bbConnectInput( const std::string& name, 
+                                Connection::Pointer c);
     /// Connects the output <name> to the connection c
-    virtual void bbConnectOutput( const std::string& name, Connection* c);
+    virtual void bbConnectOutput( const std::string& name, 
+                                 Connection::Pointer c);
 
-    BlackBox* bbGetBlackBox( const std::string& name );
+    BlackBox::Pointer bbGetBlackBox( const std::string& name );
+
+    /// The type of map of black boxes
+    typedef std::map<std::string, BlackBox::Pointer> BlackBoxMapType;
 
-    const std::map<std::string, BlackBox*>& bbGetBlackBoxMap() 
-    { 
-      return mBlackBoxMap;
-    }
+    const BlackBoxMapType& bbGetBlackBoxMap() { return mBlackBoxMap; }
 
     void bbPrintBlackBoxes();
 
@@ -98,7 +111,7 @@ namespace bbtk
     /// Generates own description and recursively calls itself 
     /// on internal boxes with level-1 
     virtual void bbWriteDotFileBlackBox(FILE *ff,
-                                       BlackBox *parentblackbox, 
+                                       BlackBox::Pointer parentblackbox, 
                                        int detail, int level,
                                        bool instanceOrtype,
                                        bool relative_link );
@@ -107,24 +120,29 @@ namespace bbtk
                                           bool inputoutput, 
                                           int detail, int level);
     
-    virtual BlackBox *bbFindBlackBox(const std::string &blackboxname);
+    virtual BlackBox::Pointer bbFindBlackBox(const std::string &blackboxname);
     
 
     void Check(bool recursive=true);
 
+       
+
   protected:
     //==================================================================
     // PROTECTED PART : ACCESSIBLE TO ComplexBlackBoxDescriptor
+    static ComplexBlackBox::Pointer 
+    New(const std::string &name,
+       ComplexBlackBoxDescriptor::Pointer desc);
+                                
+  private:                      
     ///  Constructor that takes the ComplexBlackBox name
-    ComplexBlackBox(const std::string &name, ComplexBlackBoxDescriptor* desc);
+    ComplexBlackBox(const std::string &name,
+                   ComplexBlackBoxDescriptor::Pointer desc);
     /// Constructor from an existing box (copy) with a new name 
     ComplexBlackBox(ComplexBlackBox& from, const std::string &name);
-    // 
-   ~ComplexBlackBox();
-
     
   public:
-    IOStatus bbBackwardUpdate(Connection* caller);
+    IOStatus bbBackwardUpdate(Connection::Pointer caller);
     //  void bbForwardUpdate(Connection* caller);
     void bbSetModifiedStatus(BlackBoxInputConnector* c);
 
@@ -132,15 +150,16 @@ namespace bbtk
   
 
 
-    void bbAddBlackBox( BlackBox* );
+    void bbAddBlackBox( BlackBox::Pointer );
     void bbAddToExecutionList( const std::string& name );
-    void bbUnsafeAddBlackBox( BlackBox* );
-    void bbRemoveBlackBox( const std::string& name );
-    void bbAddConnection( Connection* );
+    void bbUnsafeAddBlackBox( BlackBox::Pointer );
+    void bbRemoveBlackBox( const std::string& name, 
+                          bool remove_connections = true);
+    void bbAddConnection( Connection::Pointer );
     
     //    void RemoveConnection( );
 
-    BlackBox* bbUnsafeGetBlackBox( const std::string& name );
+    BlackBox::Pointer bbUnsafeGetBlackBox( const std::string& name );
 
     /// 
     void bbAllocateConnectors();
@@ -151,19 +170,22 @@ namespace bbtk
     // PRIVATE PART : MEMBERS AND USEFULL INTERNAL METHODS
 
     /// Default constructor : derived classes must use the constructor with the ComplexBlackBox's name
-    ComplexBlackBox() : BlackBox("") {}
+    //ComplexBlackBox() : BlackBox("") {}
     
+    // true if the box is a prototype of a ComplexBlackBoxDescriptor
+    //    bool mIsAPrototype;
+
+    /// The descriptor pointer : is 0 if the box is a prototype 
+    ComplexBlackBoxDescriptor::Pointer mLockedDescriptor;
     /// The descriptor pointer
-    ComplexBlackBoxDescriptor* mDescriptor;
+    ComplexBlackBoxDescriptor::WeakPointer mDescriptor;
     
-    /// The type of map of black boxes
-    typedef std::map<std::string, BlackBox*> BlackBoxMapType;
     /// The map of black boxes
     BlackBoxMapType mBlackBoxMap;
     
     
     /// The type of list of connections
-    typedef std::list<Connection*> ConnectionListType;
+    typedef std::list<Connection::Pointer> ConnectionListType;
     /// The list of connections
     ConnectionListType mConnectionList;
 
index 679557533a763c58d095c50de67622675c931cf8..efe06f170e8444cc9ee7105576d1b5a4d5a66887 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkComplexBlackBoxDescriptor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.15 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 namespace bbtk
 {
-  
+   //=======================================================================
+  /// 
+  ComplexBlackBoxDescriptor::Pointer 
+  ComplexBlackBoxDescriptor::New(const std::string& name)
+  {
+    bbtkDebugMessage("object",1,"##> ComplexBlackBoxDescriptor::New(\""<<name<<"\")"<<std::endl);
+    ComplexBlackBoxDescriptor::Pointer p = 
+      MakePointer(new ComplexBlackBoxDescriptor(name));
+    bbtkDebugMessage("object",1,"<## ComplexBlackBoxDescriptor::New(\""<<name<<"\")"<<std::endl);
+    return p;
+  }
+  //=======================================================================
 
   //=======================================================================
   /// Default ctor
   ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(const std::string& name)
-    : BlackBoxDescriptor(),
-      mFactory(0)
   {
-    bbtkDebugMessageInc("Kernel",9,"ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
+    bbtkDebugMessage("object",2,"==> ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
     SetTypeName(name);
     AddToCategory("complex box");
-    mPrototype = new ComplexBlackBox(name+std::string("Prototype"),this);
-    // this->Reference();
-    bbtkDebugDecTab("Kernel",9);
+    mPrototype = ComplexBlackBox::New(name+std::string("Prototype"),
+                                     MakePointer(this,true));
+    mPrototype->SetAsPrototype();
+    bbtkDebugMessage("object",2,"<== ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
   }
   //=======================================================================
 
@@ -51,12 +61,10 @@ namespace bbtk
   /// Default dtor
   ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor()
   {
-    bbtkDebugMessageInc("Kernel",1,"ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
-
-    delete mPrototype;
-
-    bbtkDebugMessage("Kernel",1,"EO ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
-   bbtkDebugDecTab("Kernel",1);
+    bbtkDebugMessage("object",2,"==> ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
+    //    mPrototype->Delete();
+    mPrototype.reset();
+    bbtkDebugMessage("object",2,"<== ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
   }
   //=======================================================================
 
@@ -70,11 +78,11 @@ namespace bbtk
 
   //=======================================================================
   /// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor 
-  BlackBox* ComplexBlackBoxDescriptor::CreateInstance(const std::string& name)
+  BlackBox::Pointer 
+  ComplexBlackBoxDescriptor::NewBlackBox(const std::string& name)
   {
-    //bbtkError("ComplexBlackBoxDescriptor::CreateInstance not implemented");
     bbtkDebugMessageInc("Kernel",5,
-                       "ComplexBlackBoxDescriptor::CreateInstance(\""
+                       "ComplexBlackBoxDescriptor::NewBlackBox(\""
                        <<name<<"\") ["
                        <<GetTypeName()<<"]"<<std::endl);
     
@@ -84,7 +92,14 @@ namespace bbtk
   }
   //=======================================================================
 
-
+  /*
+  //=======================================================================
+  /// Release
+  void ComplexBlackBoxDescriptor::Release(bool release_package)
+  {
+  }
+  //=======================================================================
+  */
 
   //=======================================================================
   /// Adds a black box to the complex box
@@ -98,7 +113,7 @@ namespace bbtk
                        <<GetTypeName()<<"]"<<std::endl);
     
     // 
-    if (mFactory == 0
+    if (!GetFactory()
       { 
        bbtkError("ComplexBlackBoxDescriptor::Add : no factory set");
       }
@@ -109,13 +124,23 @@ namespace bbtk
        bbtkError("a black box \""<<name<<"\" already exists");
       }
     // ok : create new one
-    mPrototype->bbAddBlackBox ( mFactory->NewBlackBox(type,name) );
+    mPrototype->bbAddBlackBox ( GetFactory()->NewBlackBox(type,name) );
 
     bbtkDebugDecTab("Kernel",5);
   }
   //=======================================================================
+  
+  //=======================================================================
+  /// Removes a black box from the complex box
+  void ComplexBlackBoxDescriptor::Remove( const std::string& name, 
+                                         bool remove_connections)
+  {    
+    mPrototype->bbRemoveBlackBox(name,remove_connections);
+  }
+  //=======================================================================
 
- //=======================================================================
+
+  //=======================================================================
   /// Adds a black box to the execution list 
   void ComplexBlackBoxDescriptor::AddToExecutionList ( const std::string& box)
   {
@@ -124,7 +149,7 @@ namespace bbtk
                        <<box<<"\" ["
                        <<GetTypeName()<<"]"<<std::endl);
     // Verify that the box exists
-    BlackBox* b = mPrototype->bbUnsafeGetBlackBox( box ); 
+    BlackBox::Pointer b = mPrototype->bbUnsafeGetBlackBox( box ); 
     if ( !b ) 
       {
        bbtkError("the black box \""<<box<<"\" does not exist");
@@ -151,25 +176,26 @@ namespace bbtk
                        <<"\") ["
                        <<GetTypeName()<<"]"<<std::endl);
   // 
-    if (mFactory == 0
+    if (!GetFactory()
       { 
        bbtkError("ComplexBlackBoxDescriptor::Connect : no factory set");
       }
     
 
   // Verify that a box with the same name does not exist already
-    BlackBox* bbfrom = mPrototype->bbGetBlackBox( from );
+    BlackBox::Pointer bbfrom = mPrototype->bbGetBlackBox( from );
     if ( !bbfrom ) 
       {
        bbtkError("the black box \""<<from<<"\" does not exist");
       }
-    BlackBox* bbto = mPrototype->bbGetBlackBox( to );
+    BlackBox::Pointer bbto = mPrototype->bbGetBlackBox( to );
     if ( !bbto ) 
       {
        bbtkError("the black box \""<<to<<"\" does not exist");
       }
     
-    Connection* c = mFactory->NewConnection( bbfrom, output, bbto, input );
+    Connection::Pointer c 
+      = GetFactory()->NewConnection( bbfrom, output, bbto, input );
 
     mPrototype->bbAddConnection(c);
 
@@ -192,7 +218,7 @@ namespace bbtk
                        <<"\") ["
                        <<GetTypeName()<<"]"<<std::endl);
 
-    BlackBox* bb = mPrototype->bbGetBlackBox( box );
+    BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box );
     if ( !bb ) 
       {
        bbtkError("the black box \""<<box<<"\" does not exist");
@@ -234,7 +260,7 @@ namespace bbtk
                        <<"\") ["
                        <<GetTypeName()<<"]"<<std::endl);
 
-    BlackBox* bb = mPrototype->bbGetBlackBox( box );
+    BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box );
     if ( !bb ) 
       {
        bbtkError("the black box \""<<box<<"\" does not exist");
@@ -351,16 +377,16 @@ namespace bbtk
     {
           (s) << "<TR><TD style='vertical-align: top;'><b> Uses </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'>  ";
 
-          std::set<BlackBoxDescriptor*> pdeps;
+          std::set<BlackBoxDescriptor::Pointer> pdeps;
           ComplexBlackBox::BlackBoxMapType::const_iterator b;
           for ( b = B.begin(); b != B.end(); ++b ) 
           {
-             BlackBoxDescriptor* d = b->second->bbGetDescriptor();
+            BlackBoxDescriptor::Pointer d = b->second->bbGetDescriptor();
              if (pdeps.find(d) != pdeps.end()) 
             continue;
              pdeps.insert(d);
 
-             Package* p = d->GetPackage();
+             Package::Pointer p = d->GetPackage();
            
              std::string name = b->second->bbGetTypeName();
 
@@ -564,7 +590,43 @@ namespace bbtk
   }   
   //=======================================================================
 
-
-
+  //==========================================================================
+  std::string ComplexBlackBoxDescriptor::GetObjectName() const
+  {
+    return std::string("ComplexBlackBoxDescriptor '")+GetFullTypeName()
+      +std::string("'");
+  }
+  //==========================================================================
+  //=======================================================================
+  std::string ComplexBlackBoxDescriptor::GetObjectInfo() const
+  {
+    std::string i;
+    return i;     
+  }
+  //=======================================================================
+ //==========================================================================
+size_t  ComplexBlackBoxDescriptor::GetObjectSize() const 
+{
+  size_t s = Superclass::GetObjectSize();
+  s += ComplexBlackBoxDescriptor::GetObjectInternalSize();
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+size_t  ComplexBlackBoxDescriptor::GetObjectInternalSize() const 
+{
+  size_t s = sizeof(ComplexBlackBoxDescriptor);
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  ComplexBlackBoxDescriptor::GetObjectRecursiveSize() const 
+  {
+    size_t s = Superclass::GetObjectRecursiveSize();
+    s += ComplexBlackBoxDescriptor::GetObjectInternalSize();
+    s += mPrototype->GetObjectRecursiveSize();
+    return s;
+  }
+  //==========================================================================
 
 }
index a3c2d70ea854736a40a633ec09fa6fce198a859c..d359b2d9f0c5bba7f656e1c846b43fec9886b424 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkComplexBlackBoxDescriptor.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -38,33 +38,41 @@ namespace bbtk
 {
 
   class ComplexBlackBox;
-  
+  typedef boost::shared_ptr<ComplexBlackBox> ComplexBlackBoxPointer;
+
   //==========================================================================
-  class BBTK_EXPORT ComplexBlackBoxDescriptor : public bbtk::BlackBoxDescriptor
+  class BBTK_EXPORT ComplexBlackBoxDescriptor : 
+    public bbtk::BlackBoxDescriptor
   {
+    BBTK_OBJECT_INTERFACE(ComplexBlackBoxDescriptor);
+    typedef BlackBoxDescriptor Superclass;
   public:
     friend class ComplexBlackBox;
-    /// Default ctor with name 
-    ComplexBlackBoxDescriptor(const std::string& name); 
-  protected:
-   /// Default dtor
-    ~ComplexBlackBoxDescriptor();
-  public:
+
+    static Pointer New(const std::string& name); 
     /// Sets the factory used 
-    void SetFactory(Factory* f) { mFactory = f; }
+    void SetFactory(Factory::Pointer f) { mFactory = f; }
     /// Gets the factory used
-    Factory* GetFactory() { return mFactory; }
+    Factory::Pointer GetFactory() const { return mFactory.lock(); }
+
+    /// Releases the descriptor
+    //    void Release(bool release_package = true);
+
     /// Gets the factory used (const)
-    const Factory* GetFactory() const { return mFactory; }
+    //    const Factory* GetFactory() const { return mFactory; }
 
     /// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor 
-    virtual BlackBox* CreateInstance(const std::string& name);
+    virtual BlackBoxPointer NewBlackBox(const std::string& name);
 
     /// Adds a black box to the complex box
     /// Needs a factory set !
     void Add ( const std::string& type,
               const std::string& name
               ); 
+
+    /// Removes a black box from the complex box
+    void Remove( const std::string& name, bool remove_connections = true);
+
     /// Connects two black boxes of the complex box
     /// Needs a factory set !
      void Connect ( const std::string& from,
@@ -92,7 +100,7 @@ namespace bbtk
     /// 
     void AddToExecutionList( const std::string& box );
 
-    ComplexBlackBox* GetPrototype() { return mPrototype; }
+    ComplexBlackBoxPointer GetPrototype() { return mPrototype; }
     void PrintBlackBoxes(); 
    
     /// Prints help on the black box
@@ -124,14 +132,18 @@ namespace bbtk
 
    ///
     virtual void Check(bool recursive=true) const;
+       
+
+
+  protected:
+    /// Default ctor with name is protected
+    ComplexBlackBoxDescriptor(const std::string& name); 
 
   private:
-    /// Default ctor is private (must have name and factory)
-    ComplexBlackBoxDescriptor() {}
     /// The factory used
-    Factory* mFactory;
+    Factory::WeakPointer mFactory;
     /// The complex box in which boxes and connections are stored
-    ComplexBlackBox* mPrototype;
+    ComplexBlackBoxPointer mPrototype;
     /// The name of the script file from which it was created
     std::string mScriptFileName;
     
index 29bab6cc40a63308c6c3fca425e676403cd1ce3a..1e84edfa3d0395e3afa7da5b930913703c8d0ecf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkConnection.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See doc/license.txt or
 
 namespace bbtk
 {
-  
+  Connection::Pointer Connection::New(BlackBox::Pointer from, 
+                                     const std::string& output,
+                                     BlackBox::Pointer to, 
+                                     const std::string& input ,
+                                     const Factory::Pointer f  )
+  {
+    bbtkDebugMessage("object",1,"##> Connection::Connection(\""
+                    <<from->bbGetName()<<"\",\""<<output<<"\",\""
+                    <<to->bbGetName()<<"\",\""<<input<<"\")"
+                    <<std::endl);
+    Connection::Pointer p = 
+      MakePointer(new Connection(from,output,to,input,f));
+    bbtkDebugMessage("object",1,"<## Connection::Connection(\""
+                    <<from->bbGetName()<<"\",\""<<output<<"\",\""
+                    <<to->bbGetName()<<"\",\""<<input<<"\")"
+                    <<std::endl);
+    return p;
+  }
+
   //==================================================================
   /// Ctor with the black box from and to and their input and output.
 /// Check the input and output compatibility
-  Connection::Connection(BlackBox* from, const std::string& output,
-                        BlackBox* to, const std::string& input ,
-                        const Factory* f  )
-    : mAdaptor(0),
+Connection::Connection(BlackBox::Pointer from, const std::string& output,
+                      BlackBox::Pointer to, const std::string& input ,
+                      const Factory::Pointer f  )
+    : mAdaptor(),
       mFactory(f),
       mFromAny(false),
       mToAny(false)
   {
-    bbtkDebugMessageInc("Kernel",7,"Connection::Connection(\""
-                       <<from->bbGetName()<<"\",\""<<output<<"\",\""
-                       <<to->bbGetName()<<"\",\""<<input<<"\")"
-                       <<std::endl);    
+    bbtkDebugMessage("object",2,"==> Connection::Connection(\""
+                    <<from->bbGetName()<<"\",\""<<output<<"\",\""
+                    <<to->bbGetName()<<"\",\""<<input<<"\")"
+                    <<std::endl);    
 
-    mFrom = mOriginalFrom = from;
-    mTo = mOriginalTo = to;
-    mInput = mOriginalInput = input;
-    mOutput = mOriginalOutput = output;
     
 
     if (! from->bbHasOutput(output) )
@@ -99,9 +113,10 @@ namespace bbtk
            std::string name;
            name = from->bbGetName() + "." + output + "-" 
              + to->bbGetName() + "." + input; 
-           mAdaptor = mFactory->NewAdaptor(from->bbGetOutputType(output),
-                                 to->bbGetInputType(input),
-                                 name);
+           mAdaptor = mFactory.lock()
+             ->NewAdaptor(from->bbGetOutputType(output),
+                          to->bbGetInputType(input),
+                          name);
            if (!mAdaptor)  
              {  
                bbtkError("did not find any <"
@@ -113,36 +128,60 @@ namespace bbtk
          }
       }
 
-     // 
-    from->bbConnectOutput(output,this);
-    to->bbConnectInput(input,this);
-    
-    bbtkDebugDecTab("Kernel",7);
-  }
+     // Lock this pointer !!!
+    Pointer p = MakePointer(this,true);
+    from->bbConnectOutput(output,p);
+    to->bbConnectInput(input,p);
+    mFrom = from;
+    mOriginalFrom = from;
+    mTo = to;
+    mOriginalTo = to;
+    mInput = mOriginalInput = input;
+    mOutput = mOriginalOutput = output;
 
-  //==================================================================
-  
-  void Connection::Clear()
-  {
-    mFrom = mOriginalFrom = 0;
-    mTo = mOriginalTo = 0;
-    mAdaptor = 0;
+    
+    bbtkDebugMessage("object",2,"==> Connection::Connection(\""
+                    <<from->bbGetName()<<"\",\""<<output<<"\",\""
+                    <<to->bbGetName()<<"\",\""<<input<<"\")"
+                    <<std::endl);    
   }
-
+ //==================================================================
   //==================================================================
   /// Dtor 
   Connection::~Connection()
   {
-    bbtkDebugMessageInc("Kernel",7,
-                       "Connection::~Connection() ["
-                       <<GetFullName()<<"]"<<std::endl);
-    std::cout << "~Connection() " << GetFullName() << std::endl;
-
-    if (mFrom!=0) mFrom->bbDisconnectOutput(mOutput,this);
-    if (mTo!=0) mTo->bbDisconnectInput(mInput,this);
-    if (mAdaptor!=0) mAdaptor->bbDelete();
+    bbtkDebugMessage("object",2,
+                    "==> Connection::~Connection() ["
+                    <<GetFullName()<<"]"<<std::endl);
+
+    if (mAdaptor) mAdaptor.reset();
+    mOriginalFrom.reset();
+    mOriginalTo.reset();
+    if (mFrom!=0) 
+      {
+       mFrom->bbDisconnectOutput(mOutput,
+                                 GetThisPointer<Connection>());
+      }
+    else 
+      {
+       bbtkInternalError("Connection::~Connection() : invalid initial box pointer");
+      }
+    if (mTo!=0) 
+      {
+       mTo->bbDisconnectInput(mInput,
+                              GetThisPointer<Connection>());
+      }
+    else 
+      {
+       bbtkInternalError("Connection::~Connection() : invalid final box pointer");
+      }
+   mFrom.reset();
+    mTo.reset();
 
-    bbtkDebugDecTab("Kernel",7);
+    bbtkDebugMessage("object",2,
+                    "<== Connection::~Connection() ["
+                    <<GetFullName()<<"]"<<std::endl);
   }
   //==================================================================
   
@@ -155,7 +194,7 @@ namespace bbtk
                        <<GetFullName()<<"]"<<std::endl);
 
     IOStatus s = UPTODATE;
-    s = mFrom->bbBackwardUpdate(this);
+    s = mFrom->bbBackwardUpdate(GetThisPointer<Connection>());
 
     TransferData();
 
@@ -235,12 +274,13 @@ namespace bbtk
        else 
          {
            // 2) Look for an adaptor
-           bbtk::BlackBox* adaptor = 0;
+           bbtk::BlackBox::Pointer adaptor;
            try 
              {
-               adaptor = mFactory->NewAdaptor(mFrom->bbGetOutput(mOutput).type(),
-                                    mTo->bbGetInputType(mInput),
-                                    "");
+               adaptor = mFactory.lock()
+                 ->NewAdaptor(mFrom->bbGetOutput(mOutput).type(),
+                              mTo->bbGetInputType(mInput),
+                              "");
              }
            catch (...)
              {
@@ -253,7 +293,7 @@ namespace bbtk
                adaptor->bbExecute();
                // LG : Connection Update does not set mTo as modified
                mTo->bbSetInput(mInput, adaptor->bbGetOutput("Out"),false);
-               adaptor->bbDelete();
+               //      adaptor->bbDelete();
              }
            // 3) If no adaptor found but the any content is a pointer
            //    and target type is also a pointer : we try run-time cast
@@ -325,10 +365,12 @@ namespace bbtk
       {
        std::string res = mFrom->bbGetName()+"."+mOutput+"--"
          +mTo->bbGetName()+"."+mInput;
-       if ((mFrom!=mOriginalFrom)||(mTo!=mOriginalTo))
+       if ((!mOriginalFrom.expired()) && (!mOriginalTo.expired()) &&
+           ((mFrom!=mOriginalFrom.lock())||(mTo!=mOriginalTo.lock())))
          {
-           res += "("+mOriginalFrom->bbGetName()+"."+mOriginalOutput+"--"
-             + mOriginalTo->bbGetName()+"."+mOriginalInput+")";
+           res += "("+mOriginalFrom.lock()->bbGetName()
+             +"."+mOriginalOutput+"--"
+             + mOriginalTo.lock()->bbGetName()+"."+mOriginalInput+")";
          }
        return res;
       }
@@ -350,7 +392,9 @@ namespace bbtk
        bbtkMessage("Debug",2," - From : "<<mFrom->bbGetFullName()<<std::endl);
        if (!mFrom->bbHasOutput(mOutput))
          {
-           bbtkError(mFrom->bbGetFullName()<<" does not have output '"
+           bbtkError("** Checking Connection "<<(void*)this
+                      <<" ["<<GetFullName()<<"] : "
+                     << mFrom->bbGetFullName()<<" does not have output '"
                      <<mOutput<<"'");
          }     
        bbtkMessage("Debug",2," - From : Output '"<<mOutput<<"' exists"<<std::endl);
@@ -358,19 +402,31 @@ namespace bbtk
          = mFrom->bbGetOutputConnectorMap().find(mOutput);
        if (i== mFrom->bbGetOutputConnectorMap().end())
          {
-            bbtkError(mFrom->bbGetFullName()<<" output '"
+            bbtkError("** Checking Connection "<<(void*)this
+                      <<" ["<<GetFullName()<<"] : "
+                      <<mFrom->bbGetFullName()<<" output '"
                       <<mOutput<<"' is not in OutputConnectorMap");
          }
        bbtkMessage("Debug",2," - From : Output '"<<mOutput
                    <<"' is in OutputConnectorMap"<<std::endl);
 
-        std::vector< Connection * >::const_iterator j;
+        std::vector< Connection::WeakPointer >::const_iterator j;
+       for (j  = i->second->GetConnectionVector().begin();
+            j != i->second->GetConnectionVector().end();
+            ++j)
+         {
+           if ((*j).lock()==GetThisPointer<Connection>()) break;
+         }
+       /*
        j = find(i->second->GetConnectionVector().begin(),
                 i->second->GetConnectionVector().end(),
-                this);
+                GetThisPointer<Connection>());
+       */
        if (j==i->second->GetConnectionVector().end())
          {
-           bbtkError("Connection ["<<GetFullName()<<"] : "
+           bbtkError("** Checking Connection "<<(void*)this
+                     <<" ["<<GetFullName()<<"] : "
+                     << "Connection ["<<GetFullName()<<"] : "
                      <<" OutputConnector '"
                      <<mOutput<<"' of "<<mFrom->bbGetFullName()
                      <<" does not point to this connection");
@@ -388,14 +444,16 @@ namespace bbtk
     else
       {
        bbtkMessage("Debug",2," - To   : "<<mTo->bbGetName()<<std::endl);
-       std::cout << mTo << std::endl;
-       std::cout << mTo->bbGetDescriptor() << std::endl;
-       std::cout << mTo->bbGetDescriptor()->GetTypeName() << std::endl;
-       mTo->bbGetFullName();
+       //      std::cout << mTo << std::endl;
+       //      std::cout << mTo->bbGetDescriptor() << std::endl;
+       //      std::cout << mTo->bbGetDescriptor()->GetTypeName() << std::endl;
+       //      mTo->bbGetFullName();
        bbtkMessage("Debug",2," - To   : "<<mTo->bbGetFullName()<<std::endl);
        if (!mTo->bbHasInput(mInput))
          {
-           bbtkError(mTo->bbGetFullName()<<" does not have input '"
+           bbtkError("** Checking Connection "<<(void*)this
+                     <<" ["<<GetFullName()<<"] : "
+                     <<mTo->bbGetFullName()<<" does not have input '"
                      <<mInput<<"'");
          }     
        bbtkMessage("Debug",2," - To   : Input '"<<mInput<<"' exists"<<std::endl);
@@ -403,7 +461,9 @@ namespace bbtk
          = mTo->bbGetInputConnectorMap().find(mInput);
        if (i== mTo->bbGetInputConnectorMap().end())
          {
-            bbtkError(mTo->bbGetFullName()<<" input '"
+            bbtkError("** Checking Connection "<<(void*)this
+                      <<" ["<<GetFullName()<<"] : "
+                      <<mTo->bbGetFullName()<<" input '"
                       <<mInput<<"' is not in InputConnectorMap");
          }
        bbtkMessage("Debug",2," - To   : Input '"<<mInput
@@ -411,7 +471,9 @@ namespace bbtk
 
        if (i->second->GetConnection()==0)
          {
-           bbtkError("Connection "<<GetFullName()<<" : "
+           bbtkError("** Checking Connection "<<(void*)this
+                     <<" ["<<GetFullName()<<"] : "
+                     <<"Connection "<<GetFullName()<<" : "
                      <<" InputConnector '"
                      <<mInput<<"' of "<<mTo->bbGetFullName()
                      <<" does not point to this connection");
@@ -423,6 +485,47 @@ namespace bbtk
       }
   }
   //==================================================================
+ //==========================================================================
+  std::string Connection::GetObjectName() const
+  {
+    std::string s("Connection '");
+    s += GetFullName();
+    s += "'";
+    return s;
+  }
+  //==========================================================================
+  
+  //==========================================================================
+  std::string  Connection::GetObjectInfo() const 
+  {
+    std::stringstream i;
+    return i.str();
+  }
+  //==========================================================================
+
+ //==========================================================================
+size_t  Connection::GetObjectSize() const 
+{
+  size_t s = Superclass::GetObjectSize();
+  s += Connection::GetObjectInternalSize();
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+size_t  Connection::GetObjectInternalSize() const 
+{
+  size_t s = sizeof(Connection);
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  Connection::GetObjectRecursiveSize() const 
+  {
+    size_t s = Superclass::GetObjectRecursiveSize();
+    s += Connection::GetObjectInternalSize();
+    return s;
+  }
+  //==========================================================================
 
 }// namespace bbtk
 
index f69695f112cb749bb4725909af89a3b75e5fdd77..f1494f01397346cbdda5a6a6c77918efabcbdc86 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkConnection.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See doc/license.txt or
@@ -29,6 +29,7 @@
 #define __bbtkConnection_h__
 
 #include "bbtkSystem.h"
+#include "bbtkObject.h"
 
 #include <string>
 
@@ -36,6 +37,11 @@ namespace bbtk
 {
 
   class Factory;
+  BBTK_FORWARD_DECLARE_POINTER(Factory);
+  class BlackBox;
+  BBTK_FORWARD_DECLARE_POINTER(BlackBox);
+  class BlackBoxInputConnector;
+  class BlackBoxOutputConnector;
 
   /// 
   typedef int IOStatus;
@@ -46,21 +52,20 @@ namespace bbtk
   /// 
   const int UPDATING = 2;
 
-  class BlackBox;
-  class BlackBoxInputConnector;
-  class BlackBoxOutputConnector;
 
-  class BBTK_EXPORT Connection
+  class BBTK_EXPORT Connection : public Object
   {
+     BBTK_OBJECT_INTERFACE(Connection);
+    typedef Object Superclass;
   public:
-    /// Ctor 
-    Connection(BlackBox* from, const std::string& output,
-              BlackBox* to, const std::string& input,
-              const Factory* f);
+
+    static Pointer New(BlackBoxPointer from, const std::string& output,
+                      BlackBoxPointer to, const std::string& input,
+                      const FactoryPointer f);
     /// Dtor
-    ~Connection();
+    //    ~Connection();
 
-    void Clear();
+    // void Delete();
     
     /// Amont direction pipeline processing
     /// 1) call bbBackwardUpdate(this) on the upstream box
@@ -76,27 +81,27 @@ namespace bbtk
     std::string GetFullName() const; 
 
     /// Returns the original initial black box of the connection
-    BlackBox* GetOriginalBlackBoxFrom() const { return mOriginalFrom; }
+    BlackBoxPointer GetOriginalBlackBoxFrom() const { return mOriginalFrom.lock(); }
     /// Returns the origianl final black box of the connection
-    BlackBox* GetOriginalBlackBoxTo() const { return mOriginalTo; }
+    BlackBoxPointer GetOriginalBlackBoxTo() const { return mOriginalTo.lock(); }
     /// Returns the original output of the initial black box of the connection
     const std::string& GetOriginalBlackBoxFromOutput() const { return mOriginalOutput; }
     /// Returns the original input of the final black box of the connection
     const std::string& GetOriginalBlackBoxToInput() const { return mOriginalInput; }
-
+    
     /// Returns the initial black box of the connection
-    BlackBox* GetBlackBoxFrom() const { return mFrom; }
+    BlackBoxPointer GetBlackBoxFrom() const { return mFrom; }
     /// Returns the final black box of the connection
-    BlackBox* GetBlackBoxTo() const { return mTo; }
+    BlackBoxPointer GetBlackBoxTo() const { return mTo; }
     /// Returns the output of the initial black box of the connection
     const std::string& GetBlackBoxFromOutput() const { return mOutput; }
     /// Returns the input of the final black box of the connection
     const std::string& GetBlackBoxToInput() const { return mInput; }
 
     /// Sets the initial black box of the connection
-    void SetBlackBoxFrom(BlackBox* b) { mFrom = b; }
+    void SetBlackBoxFrom(BlackBoxPointer b) { mFrom = b; }
     /// Sets the final black box of the connection
-    void SetBlackBoxTo(BlackBox* b) { mTo = b; }
+    void SetBlackBoxTo(BlackBoxPointer b) { mTo = b; }
     /// Sets the output of the initial black box of the connection
     void SetBlackBoxFromOutput(const std::string& o) { mOutput = o; }
     /// Sets the input of the final black box of the connection
@@ -107,26 +112,26 @@ namespace bbtk
     
   protected:
     /// Black box origin of the connection
-    BlackBox* mFrom;
-    BlackBox* mOriginalFrom;
+    BlackBoxPointer mFrom;
+    BlackBoxWeakPointer mOriginalFrom;
     /// Output of mFrom which is connected
     std::string mOutput;
     std::string mOriginalOutput;
     /// Output connector of mFrom which is connected
     //  BlackBoxOutputConnector* mOutputConnector;
     /// Black box destination of the connection
-    BlackBox* mTo;
-    BlackBox* mOriginalTo;
+    BlackBoxPointer mTo;
+    BlackBoxWeakPointer mOriginalTo;
     /// Input of mTo which is connected
     std::string mInput;
     std::string mOriginalInput;
     /// Input connector of mTo which is connected
     //  BlackBoxInputConnector* mInputConnector;
     /// Adaptor black box if needed
-    BlackBox* mAdaptor;
+    BlackBoxPointer mAdaptor;
 
     /// The factory used to create adaptors
-    const Factory* mFactory;
+    const FactoryWeakPointer mFactory;
 
     /// Is the connection input type is any<thing> ?
     bool mFromAny;
@@ -145,6 +150,13 @@ namespace bbtk
     //        BlackBox* to, const std::string& input, int   );
     
     void TransferData(); 
+
+  private:
+    /// Ctor 
+    Connection(BlackBoxPointer from, const std::string& output,
+              BlackBoxPointer to, const std::string& input,
+              const FactoryPointer f);
+
   };
 
 }// namespace bbtk
index 9b93b57bbc5b9b94f9b6330f864c62e3eaadb110..0bc85ccfcb503dfc76bb5ea26878098e58ce38e1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkData.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See doc/license.txt or
@@ -49,7 +49,6 @@ namespace bbtk
     TypeInfo GetType() const { return mType; }
     const std::string& GetNature() const { return mNature; }
 
     /// Equality
     bool operator== ( const DataInfo& k ) const
       {
index cbb82eb059299bc981eba938cc0553101d42fb3a..67e4788268b216a4975a899b7403ee8b49d52e44 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkExecuter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.18 $
 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 namespace bbtk
 {
+  //=======================================================================
+  Executer::Pointer Executer::New()
+  {
+    bbtkDebugMessage("Kernel",9,"Executer::New()"<<std::endl);
+    return MakePointer(new Executer());
+  }
+  //=======================================================================
+
   //=======================================================================
   Executer::Executer()
     : 
-    mFactory(0),
-    mRootPackage(0),
-    mRootCBB(0),
+    mFactory(),
+    mRootPackage(),
+    mRootCBB(),
     mNoExecMode(false),
     mDialogMode(NoDialog)
   {
     bbtkDebugMessageInc("Kernel",9,"Executer::Executer()" <<std::endl);
-    mFactory = new Factory;
-    mFactory->SetExecuter(this);
+    mFactory = Factory::New();
+    // The smart pointer on this is not made yet (is made by New) 
+    // -> create it to pass it to the factory
+    // We have to "lock" the smart pointer because the factory
+    // only keeps a weak pointer on the executer
+    // -> this would auto-destroy !!
+    mFactory->SetExecuter(MakePointer(this,true));
     Reset();
     bbtkDebugDecTab("Kernel",9);
   }
@@ -56,18 +69,11 @@ namespace bbtk
   //=======================================================================
   Executer::~Executer()
   {
-     bbtkDebugMessageInc("Kernel",9,"Executer::~Executer()" <<std::endl);
-     if (mRootCBB) 
-     {
-        mRootPackage->UnRegisterBlackBox("workspace");
-        mRootCBB->UnReference();
-     }
-     if (mRootPackage)
-     {
-        GetFactory()->UnLoadPackage("user");
-     }
-     delete mFactory;
-
+     bbtkDebugMessageInc("Kernel",9,"==> Executer::~Executer()" <<std::endl);
+     mOpenDefinition.clear();
+     mOpenPackage.clear();
+     mFactory->Reset();
+     mFactory.reset();
      bbtkDebugDecTab("Kernel",9);
   }
   //=======================================================================
@@ -94,45 +100,37 @@ namespace bbtk
     bbtkDebugMessageInc("Kernel",9,"Executer::Reset()" <<std::endl);
 
     GetFactory()->CheckPackages();
-
-    // The 'user' package must be closed before all other 
-    // because box destructors must not be unloaded when bb are deleted!
-    // Similarly, the 'workspace' CBB must be destroyed before 
-    // all user defined CBB otherwise any instance 
-    // of a user CBB that is in the 'workspace' would try to 
-    // access a user CBB descriptor which has been previously freed
-    if (mRootCBB)
-    {
-      mRootPackage->UnRegisterBlackBox(mRootCBB->GetTypeName());
-      mRootCBB->UnReference();
-    }
-    if (mRootPackage)
-    {
-       GetFactory()->UnLoadPackage("user");
-    }
+    mOpenDefinition.clear();
+    mOpenPackage.clear();
     GetFactory()->Reset();
 
     // Create user package
-    mRootPackage = new Package("user","internal to bbi",
-                           "User defined black boxes",
-                           "",
-                           BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
-    // Create user workspace
-    mRootCBB = new ComplexBlackBoxDescriptor("workspace"); //,f);
-    mRootCBB->Reference();
-    mRootCBB->SetFactory(GetFactory());
-    mRootCBB->AddToAuthor("bbi (internal)");
-    mRootCBB->AddToDescription("User's workspace");
-    mOpenDefinition.push_back(CBBDefinition(mRootCBB,"user"));
-    // Register it into the user package
-    mRootPackage->RegisterBlackBox(mRootCBB);
+    Package::Pointer p =
+      Package::New("user","internal to bbi",
+                  "User defined black boxes",
+                  "",
+                  BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
     // Insert the user package in the factory
-    GetFactory()->InsertPackage(mRootPackage);
+    GetFactory()->InsertPackage(p);
     // And in the list of open packages
-    mOpenPackage.push_back(mRootPackage);
+    mOpenPackage.push_back(p);
+    mRootPackage = p;
 
+    // Create user workspace
+    ComplexBlackBoxDescriptor::Pointer r = 
+      ComplexBlackBoxDescriptor::New("workspace"); 
+    //    mRootCBB->Reference();
+    r->SetFactory(GetFactory());
+    r->AddToAuthor("bbi (internal)");
+    r->AddToDescription("User's workspace");
+    mOpenDefinition.push_back(CBBDefinition(r,"user"));
+    // Register it into the user package
+    p->RegisterBlackBox(r);
+    mRootCBB = r;
 
-    GetFactory()->CheckPackages();
+    //    Object::PrintObjectListInfo();
+    //  GetFactory()->CheckPackages();
 
     bbtkDebugDecTab("Kernel",9);
   }
@@ -142,7 +140,7 @@ namespace bbtk
   /// changes the workspace name
   void Executer::SetWorkspaceName( const std::string& n )
   {
-    mRootPackage->ChangeBlackBoxName( mRootCBB->GetTypeName(), n );
+    GetUserPackage()->ChangeBlackBoxName( GetWorkspace()->GetTypeName(), n );
   }
   //=======================================================================
 
@@ -151,19 +149,19 @@ namespace bbtk
   {
      bbtkDebugMessageInc("Kernel",9,"Executer::BeginPackage(\""<<name<<"\")"
                         <<std::endl);
-     Package* p;
+     Package::Pointer p;
      try 
       {
          p = GetFactory()->GetPackage(name);
       }
     catch (Exception e)
       {
-         p = new Package(name,
+       p = Package::New(name,
                          "",
                          "",
                          "",
                          BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
-         GetFactory()->InsertPackage(p);
+       GetFactory()->InsertPackage(p);
       }
      mOpenPackage.push_back(p);
   }
@@ -185,7 +183,8 @@ namespace bbtk
                         ","<<pack<<"\")"
                         <<std::endl);
 
-    ComplexBlackBoxDescriptor* b = new ComplexBlackBoxDescriptor(name);
+    ComplexBlackBoxDescriptor::Pointer b 
+      = ComplexBlackBoxDescriptor::New(name);
     b->SetFactory(GetFactory());
     b->SetScriptFileName(scriptfilename);
     mOpenDefinition.push_back( CBBDefinition( b, pack ) );
@@ -210,7 +209,7 @@ namespace bbtk
                         <<Current()->GetTypeName()<<"\")" 
                         <<std::endl);
     // Does current package exist ?
-    Package* p;
+    Package::Pointer p;
     std::string pname(mOpenDefinition.back().package);
     if (pname.size()>0)
       {
@@ -220,17 +219,17 @@ namespace bbtk
          }
        catch (Exception e)
          {
-           p = new Package(pname,
-                           "",
-                           "",
-                           "",
-                           BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
+           p = Package::New(pname,
+                            "",
+                            "",
+                            "",
+                            BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
            GetFactory()->InsertPackage(p);
          }
       }
     else
       {
-       p = mOpenPackage.back();
+       p = mOpenPackage.back().lock();
       }
     p->RegisterBlackBox(Current());
     
@@ -281,7 +280,7 @@ namespace bbtk
   //=======================================================================
   void Executer::Destroy(const std::string &boxName)
   {
-    bbtkError("Executer::Destroy : NOT IMPLEMENTED !");
+    Current()->Remove(boxName,true);
   }
   //=======================================================================
 
@@ -299,7 +298,7 @@ namespace bbtk
   void Executer::Execute (const std::string &nodeName) 
   {
     // if in root
-     if (Current()==mRootCBB
+    if (Current()==GetWorkspace()
      {
         if (!mNoExecMode) 
         {
@@ -320,7 +319,7 @@ namespace bbtk
                                const std::string& help)
   {
     // If the input is defined in the Root box
-    if (Current()==mRootCBB
+    if (Current()==GetWorkspace()
       {
       // If the dialog mode is set to NoDialog
       // and the user passed the name in the Inputs map 
@@ -382,12 +381,12 @@ namespace bbtk
                       const std::string &input,
                       const std::string &value)
   {
-    BlackBox* b = Current()->GetPrototype()->bbGetBlackBox(box);
+    BlackBox::Pointer b = Current()->GetPrototype()->bbGetBlackBox(box);
     // Looks for the adaptor
 
     if ( b->bbGetInputType(input) !=  typeid(std::string) ) 
       {
-         BlackBox* a =
+       BlackBox::Pointer a =
           GetFactory()->NewAdaptor(typeid(std::string),
                                    b->bbGetInputType(input),
                                    "tmp");
@@ -401,7 +400,7 @@ namespace bbtk
          a->bbSetInput("In",v);
          a->bbExecute();
          b->bbSetInput(input,a->bbGetOutput("Out"));
-         a->bbDelete();
+        //         a->Delete();
       }
     else 
       {
@@ -415,11 +414,11 @@ namespace bbtk
   std::string Executer::Get(const std::string &box,
                             const std::string &output)
   {
-    BlackBox* b = Current()->GetPrototype()->bbGetBlackBox(box);
+    BlackBox::Pointer b = Current()->GetPrototype()->bbGetBlackBox(box);
     // Looks for the adaptor
     if (b->bbGetOutputType(output) != typeid(std::string)) 
       {
-       BlackBox* a =
+       BlackBox::Pointer a =
           GetFactory()->NewAdaptor(
                                   b->bbGetOutputType(output),
                                   typeid(std::string),
@@ -440,7 +439,7 @@ namespace bbtk
        //             << std::endl;
        //std::string v(value);
        //b->bbSetInput(input,a->bbGetOutput("Out"));
-        a->bbDelete();
+       //        a->bbDelete();
         return r;
       }
     else
@@ -458,21 +457,21 @@ namespace bbtk
   //=======================================================================
   void Executer::Author(const std::string &authorName)
   {
-    Current()->AddToAuthor(authorName,Current()==mRootCBB);
+    Current()->AddToAuthor(authorName,Current()==GetWorkspace());
   }
   //=======================================================================
 
   //=======================================================================
   void Executer::Category(const std::string &category)
   {
-    Current()->AddToCategory(category,Current()==mRootCBB);
+    Current()->AddToCategory(category,Current()==GetWorkspace());
   }
   //=======================================================================
 
   //=======================================================================
   void Executer::Description(const std::string &d)
   {
-    Current()->AddToDescription(d,Current()==mRootCBB);
+    Current()->AddToDescription(d,Current()==GetWorkspace());
   }
   //=======================================================================
 
@@ -526,14 +525,14 @@ namespace bbtk
        relative_link = false;
       }
 
-    Package* p;
+    Package::Pointer p;
     try
     {
        p = GetFactory()->GetPackage(nameblackbox);
     }
     catch (Exception e)
     {
-       p = mRootPackage;
+      p = GetUserPackage();
     }
     // Generating documentation-help of workspace
     p->SetDocURL(filename_rootHtml);
@@ -563,10 +562,10 @@ namespace bbtk
                                            bool system_display)
   {
 
-    BlackBox* blackbox=NULL;
+    BlackBox::Pointer blackbox;
     if (nameblackbox==".")
     {
-       blackbox=Current()->GetPrototype();
+       blackbox = Current()->GetPrototype();
     }
     else
     {
@@ -638,7 +637,7 @@ namespace bbtk
     
     int detail = atoi(detailStr.c_str());
     int level  = atoi(levelStr.c_str());
-    BlackBox* blackbox=NULL;
+    BlackBox::Pointer blackbox;
     if (nameblackbox.compare(".")==0)
       {
        blackbox=Current()->GetPrototype();
@@ -682,8 +681,8 @@ namespace bbtk
   ///
   void Executer::Print(const std::string &str)
   {  
-    if (GetNoExecMode() &&  (Current()==mRootCBB) ) return;
-    if (Current()!=mRootCBB) return;
+    if (GetNoExecMode() &&  (Current()==GetWorkspace()) ) return;
+    if (Current()!=GetWorkspace()) return;
 
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
 
@@ -748,5 +747,44 @@ namespace bbtk
       }
     bbtkMessage("Output",1,std::endl);
   }
+  //==========================================================================
 
+  //==========================================================================
+  std::string Executer::GetObjectName() const
+  {
+    return std::string("Executer");
+  }
+  //==========================================================================
+  
+  //==========================================================================
+  std::string  Executer::GetObjectInfo() const 
+  {
+    std::stringstream i;
+    return i.str();
+  }
+  //==========================================================================
+  //==========================================================================
+size_t  Executer::GetObjectSize() const 
+{
+  size_t s = Superclass::GetObjectSize();
+  s += Executer::GetObjectInternalSize();
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+size_t  Executer::GetObjectInternalSize() const 
+{
+  size_t s = sizeof(Executer);
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  Executer::GetObjectRecursiveSize() const 
+  {
+    size_t s = Superclass::GetObjectRecursiveSize();
+    s += Executer::GetObjectInternalSize();
+    s += mFactory->GetObjectRecursiveSize();
+    return s;
+  }
+  //==========================================================================
 }//namespace
index 5f8b8a4ff25ed2dda5b7a74e78ee68a2bcdbb89d..1e59b2c488e8e248d53676084726f8f3765ccf22 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkExecuter.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -43,19 +43,16 @@ namespace bbtk
 
   class /*BBTK_EXPORT*/ Executer : public VirtualExec
   {
-
+    BBTK_OBJECT_INTERFACE(Executer);
+    typedef VirtualExec Superclass;
   public:
-
-    /// Constructor
-    Executer();
-    /// Destructor
-    ~Executer();
+    static Pointer New();
     
 
     /// Gets the factory used by the executer
-    Factory* GetFactory() { return mFactory; }
+    Factory::Pointer GetFactory() { return mFactory; }
     /// Gets the factory used by the executer (const)
-    const Factory* GetFactory() const { return mFactory; }
+    //    const Factory::Pointer GetFactory() const { return mFactory; }
 
 
     /// Sets the inputs of the workspace : 
@@ -183,13 +180,19 @@ namespace bbtk
   //  static const std::string& GetObjectDescription();
   //  { static std::string s("Executer"); return s; }
 
+
+    ComplexBlackBoxDescriptor::Pointer GetWorkspace() 
+    { return mRootCBB.lock(); }
+    Package::Pointer GetUserPackage() 
+    { return mRootPackage.lock(); }
+
   protected:
 
   private:
 
     /// Gets the current working black box 
-    ComplexBlackBoxDescriptor* Current() 
-       { return mOpenDefinition.back().box; }
+    ComplexBlackBoxDescriptor::Pointer Current() 
+    { return mOpenDefinition.back().box; }
     
     /// Returns true when we are inside a define/endefine block
     //    bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
@@ -198,26 +201,27 @@ namespace bbtk
     // ATTRIBUTES
      
     /// The factory used
-    Factory* mFactory;
+    Factory::Pointer mFactory;
     
  
     /// The Root Package 
     /// Contains the root ComplexBlabkBox
     /// In which ComplexBlackBoxes are put by default
     /// Its name in bbi is 'user'
-    Package* mRootPackage;
+    Package::WeakPointer mRootPackage;
     
     /// The root ComplexBlackBox
     /// in which operations are done when outside a define/endefine block
     /// Its name in bbi is 'workspace'  
-    ComplexBlackBoxDescriptor* mRootCBB;
+    ComplexBlackBoxDescriptor::WeakPointer mRootCBB;
 
     /// Struct that stores info on user defined complex black boxes
     struct CBBDefinition
     {
-      ComplexBlackBoxDescriptor* box;
+      ComplexBlackBoxDescriptor::Pointer box;
       std::string package;
-      CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
+      CBBDefinition(ComplexBlackBoxDescriptor::Pointer d, 
+                   const std::string& p )
         : box(d), package(p) {}
     };
 
@@ -228,7 +232,7 @@ namespace bbtk
 
     /// The stack of current working package
     /// (is a stack for nested definitions)
-    std::deque<Package*> mOpenPackage;
+    std::deque<Package::WeakPointer> mOpenPackage;
 
     /// The input values of the Root ComplexBlackBox
     std::map<std::string,std::string> mInputs;
index 82bf038f842dfe7ae2c1ed2eec16dd1cc9d94982..c024617d59d01416250563110db678ffe8f2855b 100644 (file)
@@ -4,8 +4,8 @@ Program:   bbtk
 Module:    $RCSfile: bbtkFactory.cxx,v $
 Language:  C++
 
-Date:      $Date: 2008/04/09 11:16:57 $
-Version:   $Revision: 1.32 $
+Date:      $Date: 2008/04/18 12:59:15 $
+Version:   $Revision: 1.33 $
                                                                                 
 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
@@ -40,14 +40,20 @@ PURPOSE.  See the above copyright notices for more information.
 
 namespace bbtk
 {
-  typedef Package* (*PackageAccessor)();
-  typedef void (*PackageDeleteFunction)();
 
+  //===================================================================
+  /// Default ctor
+  Factory::Pointer Factory::New()
+  {
+    bbtkDebugMessage("Kernel",9,"Factory::New()"<<std::endl);
+    return MakePointer(new Factory());
+  }
+  //===================================================================
 
   //===================================================================
   /// Default ctor
   Factory::Factory()
-    : mExecuter(0)
+    : mExecuter()
   {
     bbtkDebugMessage("Kernel",7,"Factory::Factory()"<<std::endl);
   }
@@ -64,18 +70,6 @@ namespace bbtk
   //===================================================================
 
 
-  //===================================================================
-  void Factory::CloseAllPackages()
-  {
-    bbtkDebugMessageInc("Kernel",7,"Factory::CloseAllPackages()"<<std::endl);
-    while (mPackageMap.begin() != mPackageMap.end())
-      {
-        PackageMapType::iterator i = mPackageMap.begin();
-        ClosePackage(i);
-      }
-    bbtkDebugDecTab("Kernel",7);
-  }
-  //===================================================================
 
   //===================================================================
   void Factory::Reset()
@@ -93,144 +87,26 @@ namespace bbtk
                               std::string path)
   {
     
-#if defined(__GNUC__)
-    
-    void *handler;
-    handler = dlopen(libname.c_str(),
-                    BBTK_RTLD_TIME | BBTK_RTLD_SCOPE );
-    if (!handler)
-      {
-        // The following is *NOT* a debug time message :
-        // It's a user intended message.
-        // Please don't remove it.
-       bbtkError("Could not open shared library [" <<libname<<"] : "
-                 <<dlerror() << std::endl);
-       
-       return false; // try next path
-      }
-    
-    // The following is *NOT* a debug time message :
-    // It's a user intended message.
-    // Please don't remove it.
-    bbtkMessage("Output",2,"   -->[" <<libname<<"] found" << std::endl);
-    
-    // Loads the Package accessor
-    
-    std::string getpackname(pkgname);
-    getpackname += "GetPackage";
-    void *getpack = dlsym(handler, getpackname.c_str());
-    if (!getpack)
+    Package::Pointer p = Package::CreateFromDynamicLibrary(libname,
+                                                          pkgname,
+                                                          path);
+    if (p!=0)
       {
-       dlclose(handler);
-       bbtkError("Shared library ["<<libname<<"] is not a valid bbtk package."
-                 <<" Symbol ["<<getpackname<<"] :"<<dlerror());
+       //===================================================================
+       bbtkMessage("Output",2,p->GetName()<<" "
+                   <<p->GetVersion()
+                   <<" "
+                   <<p->GetAuthor() << " Category(s) :"
+                   <<p->GetCategory()
+                   <<std::endl);
+       bbtkMessage("Output",2,p->GetDescription()<<std::endl);
+       //===================================================================
+       p->AddFactory(GetThisPointer<Factory>());
+       mPackageMap[pkgname] = p;
+       return true;
       }
+    return false;
     
-    // Verifies that the Package delete function is present
-    std::string delfname(pkgname);
-    delfname += "DeletePackage";
-    void *delf = dlsym(handler, delfname.c_str());
-    if (!delf)
-      {
-       dlclose(handler);
-       bbtkError("Shared library ["<<libname<<"] is not a valid bbtk package."
-                 <<" Symbol ["<<delfname<<"] :"<<dlerror());
-      }
-    
-#elif defined(_WIN32)
-    
-    HINSTANCE handler;
-    
-    SetErrorMode(0);
-    handler = LoadLibrary(libname.c_str());
-    if (!handler)
-      {
-       // The following is *NOT* a debug time message :
-       // It's a user intended message.
-       // Please don't remove it.
-       bbtkError("Error loading library [" <<libname<<"]" << std::endl);
-       return false;// Problem with the found library
-      }
-    
-    bbtkMessage("Output",2,"   --->[" <<libname<<"] found" << std::endl);
-    
-    // Loads the Package accessor
-    
-    std::string getpackname(pkgname);
-    getpackname += "GetPackage";
-    void *getpack = GetProcAddress(handler, getpackname.c_str());
-    if (!getpack)
-      {
-       FreeLibrary(handler);
-       bbtkError("[1] Could not load package \""<<pkgname
-                 <<"\" : "<<getpackname<<" symbol not found (is it a bbtk package lib ?)");
-       // look how to get the error message on win
-       //<<dlerror());
-      }
-    // Verifies that the Package delete function is present
-    std::string delfname(pkgname);
-    delfname += "DeletePackage";
-    void *delf = GetProcAddress(handler, delfname.c_str());
-    if (!delf)
-      {
-       FreeLibrary(handler);
-       bbtkError("[2] Could not load package \""<<pkgname
-                 <<"\" : "<<delfname<<" symbol not found (is it a bbtk package lib ?)");
-       // look how to get the error message on win
-       //<<dlerror());
-      }
-#else
-    bbtkError("neither __GNUC__ nor _WIN32 ?!? How did you compile ?");
-#endif
-    
-    // Stores the package
-    PackageInfoType pack;
-    pack.mDynamicLibraryHandler = handler;
-    // Invokes the accessor to the PackageUnit pointer
-    pack.mPackage = ((PackageAccessor)getpack)();
-    
-    // Test bbtk build version ok
-    if ( pack.mPackage->GetBBTKVersion() != bbtk::GetVersion() )
-      {
-       std::string v(pack.mPackage->GetBBTKVersion());
-       UnLoadPackage(pkgname);
-       bbtkError("Cannot load package ["<<libname<<"]. "
-                 <<"Package build with bbtk version "
-                 << v
-                 << " whereas application build with version "
-                 << bbtk::GetVersion());
-      }
-
-    pack.mPackage->AddFactory(this);
-    mPackageMap[pkgname] = pack;
-    
-    std::string separator =
-      ConfigurationFile::GetInstance().Get_file_separator ();
-    //BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
-    std::string docreldoc = 
-      separator + "bbdoc" + separator + pkgname + separator + "index.html";
-    std::string reldoc = 
-      ".." + separator + ".." + docreldoc;
-    std::string doc = path + separator + ".." + separator
-      + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
-      + docreldoc;
-    
-    pack.mPackage->SetDocURL(doc);
-    pack.mPackage->SetDocRelativeURL(reldoc);
-    
-    //===================================================================
-    bbtkMessage("Output",2,pack.mPackage->GetName()<<" "
-               <<pack.mPackage->GetVersion()
-               <<" (bbtk "
-               <<pack.mPackage->GetBBTKVersion()<<") "
-               <<pack.mPackage->GetAuthor() << " Category(s) :"
-               <<pack.mPackage->GetCategory()
-               <<std::endl);
-    bbtkMessage("Output",2,pack.mPackage->GetDescription()<<std::endl);
-    //===================================================================
-    
-    bbtkDebugDecTab("Kernel",7);
-    return true;
   }
   
   //===================================================================
@@ -430,6 +306,19 @@ namespace bbtk
   //===================================================================
 
 
+  //===================================================================
+  void Factory::CloseAllPackages()
+  {
+    bbtkDebugMessageInc("Kernel",7,"Factory::CloseAllPackages()"<<std::endl);
+    while (mPackageMap.begin() != mPackageMap.end())
+      {
+        PackageMapType::iterator i = mPackageMap.begin();
+        ClosePackage(i);
+      }
+    bbtkDebugDecTab("Kernel",7);
+  }
+  //===================================================================
+
   //===================================================================
   /// \brief Close the package referenced by the iterator 
  ///
@@ -445,67 +334,18 @@ namespace bbtk
  void Factory::ClosePackage(PackageMapType::iterator& i) 
   {   
      bbtkDebugMessageInc("Kernel",7,"Factory::ClosePackage(\""
-                         <<i->second.mPackage->GetName()
+                         <<i->second->GetName()
                         <<"\")"<<std::endl);
 
      
      // Removes this from the set of factories which use the package
-     i->second.mPackage->RemoveFactory(this);
-     
-     // If no more factory which use it 
-     if (i->second.mPackage->GetFactorySet().empty())
-       {
-        // If it is a dynamically loaded package       
-        if (i->second.mDynamicLibraryHandler) 
-          {
-            
-            
-            // Loads the Package delete function
-            
-            std::string delfname(i->second.mPackage->GetName());
-            delfname += "DeletePackage";
-#if defined(__GNUC__)     
-            void *delf = dlsym(i->second.mDynamicLibraryHandler, delfname.c_str());
-            if (!delf)
-              {
-                bbtkError("could not close package \""
-                          <<i->second.mPackage->GetName()
-                          <<"\" :"<<dlerror());
-              }    
-#elif defined(_WIN32)
-            void *delf = GetProcAddress(i->second.mDynamicLibraryHandler, 
-                                        delfname.c_str());
-            if (!delf)
-              {  
-                bbtkError("could not close package \""
-                          <<i->second.mPackage->GetName()
-                          <<"\" : "<<delfname
-                          <<" symbol not found (how did you open it ???");
-                //<<"\" :"<<dlerror());
-              }    
-#endif     
-            
-            // deletes the package
-            ((PackageDeleteFunction)delf)();
-            
-            // closes the dl handler
-#if defined(__GNUC__)  
-            dlclose(i->second.mDynamicLibraryHandler);  
-#elif defined(_WIN32)
-            
-            FreeLibrary(i->second.mDynamicLibraryHandler);
-#endif
-          }
-
-        else 
-          {  
-            // If it is a manually inserted package : delete it normally
-            delete i->second.mPackage;
-          }
-       }
-     
-     // in any cases remove the entry in the map
+     i->second->RemoveFactory(GetThisPointer<Factory>());
+     Package::WeakPointer p = i->second;
+     // remove the entry in the map
      mPackageMap.erase(i);
+     // Release the package if not already destroyed
+     if (p.lock()) Package::Release(p);
+
 
      bbtkDebugDecTab("Kernel",7);
   }
@@ -524,7 +364,7 @@ namespace bbtk
     {
       bbtkMessage("Help",1, i->first << std::endl);
       if (details) {
-         i->second.mPackage->PrintBlackBoxes(false,adaptors);
+         i->second->PrintBlackBoxes(false,adaptors);
       }
     }
 
@@ -544,22 +384,22 @@ namespace bbtk
       {
       bbtkMessage("Help",1, "Package "<<i->first<<" ");
       
-      if (i->second.mPackage->GetVersion().length()>0)
-        bbtkMessageCont("Help",1,"v" <<i->second.mPackage->GetVersion());
+      if (i->second->GetVersion().length()>0)
+        bbtkMessageCont("Help",1,"v" <<i->second->GetVersion());
         
-      if (i->second.mPackage->GetAuthor().length()>0)
-        bbtkMessageCont("Help",1,"- "<<i->second.mPackage->GetAuthor());
+      if (i->second->GetAuthor().length()>0)
+        bbtkMessageCont("Help",1,"- "<<i->second->GetAuthor());
         
-      if (i->second.mPackage->GetCategory().length()>0)
-        bbtkMessageCont("Help",1,"- "<<i->second.mPackage->GetCategory());        
+      if (i->second->GetCategory().length()>0)
+        bbtkMessageCont("Help",1,"- "<<i->second->GetCategory());        
         
       bbtkMessageCont("Help",1,std::endl);
       bbtkIncTab("Help",1);
-      bbtkMessage("Help",1,i->second.mPackage->GetDescription()<<std::endl);
-      if (i->second.mPackage->GetNumberOfBlackBoxes()>0) 
+      bbtkMessage("Help",1,i->second->GetDescription()<<std::endl);
+      if (i->second->GetNumberOfBlackBoxes()>0) 
         {
           bbtkMessage("Help",1, "Black boxes : "<<std::endl);
-          i->second.mPackage->PrintBlackBoxes(true,adaptors);
+          i->second->PrintBlackBoxes(true,adaptors);
         }
       else 
         {
@@ -591,10 +431,10 @@ namespace bbtk
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-      if (i->second.mPackage->ContainsBlackBox(name)) 
+      if (i->second->ContainsBlackBox(name)) 
         {
-          i->second.mPackage->HelpBlackBox(name,full);
-             package = i->second.mPackage->GetName();
+          i->second->HelpBlackBox(name,full);
+             package = i->second->GetName();
           found = true;
         }
       }
@@ -611,16 +451,17 @@ namespace bbtk
 
   //=================================================================== 
   /// Inserts a package in the factory
-  void Factory::InsertPackage( Package* p )
+  void Factory::InsertPackage( Package::Pointer p )
   {
     bbtkDebugMessageInc("Kernel",9,"Factory::InsertPackage(\""<<
                         p->GetName()<<"\")"<<std::endl);
 
-    p->AddFactory(this);
-    PackageInfoType pack;
-    pack.mDynamicLibraryHandler = 0;
-    pack.mPackage = p;
-    mPackageMap[p->GetName()] = pack;
+    std::cout << p.use_count() <<std::endl;
+
+    p->AddFactory(GetThisPointer<Factory>());
+    mPackageMap[p->GetName()] = p;
+
+    std::cout << p.use_count() <<std::endl;
 
     bbtkDebugDecTab("Kernel",9);
   }
@@ -628,7 +469,7 @@ namespace bbtk
   
   //=================================================================== 
   /// Removes a package from the factory (and deletes it)
-  void Factory::RemovePackage( Package* p )
+  void Factory::RemovePackage( Package::Pointer p )
   {
     bbtkDebugMessageInc("Kernel",9,"Factory::RemovePackage(\""<<
                         p->GetName()<<"\")"<<std::endl);
@@ -636,7 +477,7 @@ namespace bbtk
     PackageMapType::iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-         if (i->second.mPackage == p) break;
+         if (i->second == p) break;
       };
     
     if (i!=mPackageMap.end())
@@ -656,17 +497,17 @@ namespace bbtk
 
   //===================================================================
   /// Creates an instance of a black box of type <type> with name <name>
-  BlackBox* Factory::NewBlackBox(const std::string& type, 
+  BlackBox::Pointer Factory::NewBlackBox(const std::string& type, 
                                  const std::string& name) const
   {
     bbtkDebugMessageInc("Kernel",7,"Factory::NewBlackBox(\""
                         <<type<<"\",\""<<name<<"\")"<<std::endl);
 
-    BlackBox* b = 0
+    BlackBox::Pointer b
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-      b = i->second.mPackage->NewBlackBox(type,name);
+      b = i->second->NewBlackBox(type,name);
       if (b) break; 
       }
     if (!b) 
@@ -681,7 +522,7 @@ namespace bbtk
 
   //===================================================================
   /// Creates an instance of a black box of type <type> with name <name>
-  BlackBox* Factory::NewAdaptor(const DataInfo& typein,
+  BlackBox::Pointer Factory::NewAdaptor(const DataInfo& typein,
                                const DataInfo& typeout,
                                const std::string& name) const
   {
@@ -691,11 +532,11 @@ namespace bbtk
                         <<name<<"\")"<<bbtkendl);
 
 
-    BlackBox* b = 0
+    BlackBox::Pointer b
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-      b = i->second.mPackage->NewAdaptor(typein,typeout,name);
+      b = i->second->NewAdaptor(typein,typeout,name);
       if (b) break; 
       }
     if (!b) 
@@ -712,7 +553,7 @@ namespace bbtk
 
   //===================================================================
   /// Creates an instance of a black box of type <type> with name <name>
-  BlackBox* Factory::NewWidgetAdaptor(const DataInfo& typein,
+  BlackBox::Pointer Factory::NewWidgetAdaptor(const DataInfo& typein,
                                      const DataInfo& typeout,
                                      const std::string& name) const
   {
@@ -722,11 +563,11 @@ namespace bbtk
                         <<name<<"\")"<<bbtkendl);
 
 
-    BlackBox* b = 0
+    BlackBox::Pointer b
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-       b = i->second.mPackage->NewWidgetAdaptor(typein,
+       b = i->second->NewWidgetAdaptor(typein,
                                                 typeout,
                                                 name);
       if (b) break; 
@@ -756,7 +597,7 @@ namespace bbtk
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-       b = i->second.mPackage->FindAdaptor(typein,
+       b = i->second->FindAdaptor(typein,
                                            typeout,
                                            adaptor);
        if (b) break; 
@@ -788,7 +629,7 @@ namespace bbtk
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-       b = i->second.mPackage->FindWidgetAdaptor(typein,
+       b = i->second->FindWidgetAdaptor(typein,
                                                  typeout,
                                                  adaptor);
        if (b) break; 
@@ -814,7 +655,7 @@ namespace bbtk
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-       b = i->second.mPackage->FindWidgetAdaptor(typein,
+       b = i->second->FindWidgetAdaptor(typein,
                                                  typeout,
                                                  widget);
        if (b) break; 
@@ -828,8 +669,8 @@ namespace bbtk
        for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
          {
            Package::AdaptorMapType::const_iterator j;
-           for (j=i->second.mPackage->GetAdaptorMap().begin();
-                j!=i->second.mPackage->GetAdaptorMap().end();
+           for (j=i->second->GetAdaptorMap().begin();
+                j!=i->second->GetAdaptorMap().end();
                 ++j)
              {
                if ( ( j->first.mKind ==  
@@ -838,7 +679,7 @@ namespace bbtk
                     (j->first.mTypeOut.GetNature() == typeout.GetNature() ) 
                     )
                  {
-                   widget = j->second->GetTypeName();
+                   widget = j->second.lock()->GetTypeName();
                    bbtkMessage("Kernel",5,
                                "===> Found first part : "<<widget
                                << " "<<j->first.mTypeIn<<"->"
@@ -870,24 +711,25 @@ namespace bbtk
 
   //===================================================================
   /// Creates an instance of a connection
-  Connection* Factory::NewConnection(BlackBox* from,
-                                     const std::string& output,
-                                     BlackBox* to,
-                                     const std::string& input) const
+  Connection::Pointer Factory::NewConnection(BlackBox::Pointer from,
+                                            const std::string& output,
+                                            BlackBox::Pointer to,
+                                            const std::string& input) const
   {
     bbtkDebugMessage("Kernel",7,"Factory::NewConnection(\""
                       <<from->bbGetName()<<"\",\""<<output<<"\",\""
                       <<to->bbGetName()<<"\",\""<<input
                       <<"\")"<<std::endl);
     
-    return new Connection(from,output,to,input,this);
+    return Connection::New(from,output,to,input,
+                          GetThisPointer<Factory>());
   }
   //===================================================================
 
 
 
   //===================================================================
-  const Package* Factory::GetPackage(const std::string& name) const
+  Package::Pointer Factory::GetPackage(const std::string& name) const
   {
     bbtkDebugMessageInc("Kernel",9,"Factory::GetPackage(\""<<name<<"\")"
                          <<std::endl);
@@ -896,7 +738,7 @@ namespace bbtk
     if ( i != mPackageMap.end() ) 
     {
       bbtkDebugDecTab("Kernel",9); 
-      return i->second.mPackage;
+      return i->second;
     }
     else 
     {
@@ -908,27 +750,6 @@ namespace bbtk
   }
   //===================================================================
   
-  //===================================================================
-  Package* Factory::GetPackage(const std::string& name) 
-  {
-    bbtkDebugMessageInc("Kernel",9,"Factory::GetPackage(\""<<name<<"\")"
-                         <<std::endl);
-
-    PackageMapType::const_iterator i = mPackageMap.find(name);
-    if ( i != mPackageMap.end() ) 
-    {
-      bbtkDebugDecTab("Kernel",9); 
-      return i->second.mPackage;
-    }
-    else 
-    {
-       bbtkDebugDecTab("Kernel",9);
-       bbtkError("package \""<<name<<"\" unknown");
-    }
-    
-    bbtkDebugDecTab("Kernel",9);  
-  }
-  //===================================================================
 
   //===================================================================
   void Factory::CheckPackages() const
@@ -938,7 +759,7 @@ namespace bbtk
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-       i->second.mPackage->CheckBoxes();
+       i->second->CheckBoxes();
       }
     bbtkMessage("Debug",1,"****** Checking Factory "<<(void*)this
                <<" ... OK"<<std::endl);
@@ -979,7 +800,7 @@ namespace bbtk
    PackageMapType::const_iterator i;
    for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
    {
-      if (i->second.mPackage->ContainsBlackBox(name)) 
+      if (i->second->ContainsBlackBox(name)) 
       {
          std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
 
@@ -998,11 +819,11 @@ namespace bbtk
         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.mPackage->GetDocURL().c_str(),name.c_str() );
+        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.mPackage->GetDocURL().c_str(),name.c_str() );
+        //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;
@@ -1028,13 +849,14 @@ namespace bbtk
     
     std::string title;
 
-    typedef std::map<std::string, std::vector<BlackBoxDescriptor*> > IndexType;
+    typedef std::map<std::string, 
+      std::vector<BlackBoxDescriptor::Pointer> > IndexType;
     IndexType index;
     // Builds the index map
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
       {
-       Package* pack = i->second.mPackage;
+       Package::Pointer pack = i->second;
        if (pack->GetName()=="user") continue;
        Package::BlackBoxMapType::const_iterator j;
        for (j = pack->GetBlackBoxMap().begin(); 
@@ -1090,7 +912,7 @@ namespace bbtk
                  }
                else 
                  {
-                   std::vector<BlackBoxDescriptor*> v;
+                   std::vector<BlackBoxDescriptor::Pointer> v;
                    v.push_back(j->second);
                    index[*k] = v;
                  }
@@ -1169,7 +991,7 @@ namespace bbtk
 
        s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
 
-       std::vector<BlackBoxDescriptor*>::iterator di;
+       std::vector<BlackBoxDescriptor::Pointer>::iterator di;
        for (di=ii->second.begin();di!=ii->second.end();++di)
          {
            std::string pack = (*di)->GetPackage()->GetName();
@@ -1209,6 +1031,50 @@ namespace bbtk
     bbtkDebugDecTab("Kernel",9);
   }
 
+ //==========================================================================
+  std::string Factory::GetObjectName() const
+  {
+    return std::string("Factory");
+  }
+  //==========================================================================
+  
+  //==========================================================================
+  std::string  Factory::GetObjectInfo() const 
+  {
+    std::stringstream i;
+    return i.str();
+  }
+  //==========================================================================
+
+  //==========================================================================
+size_t  Factory::GetObjectSize() const 
+{
+  size_t s = Superclass::GetObjectSize();
+  s += Factory::GetObjectInternalSize();
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+size_t  Factory::GetObjectInternalSize() const 
+{
+  size_t s = sizeof(Factory);
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  Factory::GetObjectRecursiveSize() const 
+  {
+    size_t s = Superclass::GetObjectRecursiveSize();
+    s += Factory::GetObjectInternalSize();
+
+    PackageMapType::const_iterator i;
+    for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+    {
+      s += i->second->GetObjectRecursiveSize();
+    }
+    return s;
+  }
+  //==========================================================================
 
 }
   
index 73b23c45db71efcde3bab8af1e421aaad695649d..0d0560ac7d4eabf750c5393ed00218b068115958 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkFactory.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.14 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See doc/license.txt or
 #ifndef __bbtkFactory_h__
 #define __bbtkFactory_h__
 
-//#include "bbtkBlackBox.h"
 #include "bbtkPackage.h"
-#include "bbtkDynamicLibraryHandling.h"
 
 namespace bbtk
 {
 
   class Executer;
+  BBTK_FORWARD_DECLARE_POINTER(Executer);
 
-  class BBTK_EXPORT Factory
+  class BBTK_EXPORT Factory : public Object
   {
-
+    BBTK_OBJECT_INTERFACE(Factory);
+    typedef Object Superclass;
   public:
+    static Pointer New();
 
-    Factory();
-    ~Factory();
     
     void GetPackagesList(std::vector<std::string>&);
     void LoadPackage( const std::string& name );
@@ -54,20 +53,20 @@ namespace bbtk
     void HelpBlackBox(const std::string& name, std::string& package,
                      bool full=true ) const;
     void ShowGraphTypes(const std::string& name) const;
-    void InsertPackage( Package* );
-    void RemovePackage( Package* );
+    void InsertPackage( Package::Pointer );
+    void RemovePackage( Package::Pointer );
+
+    Package::Pointer GetPackage(const std::string& name) const;
 
-    const Package* GetPackage(const std::string& name) const;
-    Package* GetPackage(const std::string& name);
     
-    BlackBox* NewBlackBox(const std::string& type, 
+    BlackBox::Pointer NewBlackBox(const std::string& type, 
                           const std::string& name) const;
     
-    BlackBox* NewAdaptor(const DataInfo& typein,
+    BlackBox::Pointer NewAdaptor(const DataInfo& typein,
                         const DataInfo& typeout,
                          const std::string& name) const;
 
-    BlackBox* NewWidgetAdaptor(const DataInfo& typein,
+    BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein,
                               const DataInfo& typeout,
                               const std::string& name) const;
 
@@ -84,10 +83,10 @@ namespace bbtk
                            std::string& widget,
                            std::string& adaptor) const;
 
-    Connection* NewConnection(BlackBox* from,
-                              const std::string& output,
-                              BlackBox* to,
-                              const std::string& input) const;
+    Connection::Pointer NewConnection(BlackBox::Pointer from,
+                                     const std::string& output,
+                                     BlackBox::Pointer to,
+                                     const std::string& input) const;
 
     void WriteDotFilePackagesList(FILE *ff);
 
@@ -106,11 +105,11 @@ namespace bbtk
     void CreateHtmlIndex(IndexEntryType type, const std::string& filename);
 
     /// Sets the executer who created the factory (if any)
-    void SetExecuter(Executer *e) { mExecuter = e; }
+    void SetExecuter(ExecuterPointer e) { mExecuter = e; }
     /// Gets the executer who created the factory (if any)
-    Executer* GetExecuter() { return mExecuter; }
+    ExecuterPointer GetExecuter();// { return mExecuter.lock(); }
     /// Gets the executer who created the factory (if any) - const
-    const Executer* GetExecuter() const { return mExecuter; }
+    //    const Executer::Pointer GetExecuter() const { return mExecuter.lock(); }
 
 
   private:
@@ -120,21 +119,9 @@ namespace bbtk
                       std::string path);
 
   public:
-    /// The structure storing info on a package
-    class PackageInfoType
-    {
-    public :
-      /// Ctor
-      PackageInfoType() {}
-      /// Dtor
-      ~PackageInfoType() {}
-      /// The pointer on the package
-      Package* mPackage;
-      /// The handler of the dynamic library 
-      DynamicLibraryHandler mDynamicLibraryHandler;
-    };
+
     /// The type of map of packages
-    typedef std::map< std::string, PackageInfoType > PackageMapType;
+    typedef std::map< std::string, Package::Pointer > PackageMapType;
 
     const PackageMapType& GetPackageMap() const { return mPackageMap; }
 
@@ -143,7 +130,7 @@ namespace bbtk
     PackageMapType mPackageMap;
 
     /// The executer which created the factory (if any)
-    Executer* mExecuter;
+    ExecuterWeakPointer mExecuter;
 
     void CloseAllPackages();
     void ClosePackage(PackageMapType::iterator& i);
@@ -153,113 +140,6 @@ namespace bbtk
 
 
 
-  /*
-  /// SYSTEM METHOD : Global method returning the global factory object pointer
-  inline Factory*& GlobalFactoryPointer() 
-  {
-    static Factory* f = 0;
-    return f;
-  }
-
-  /// SYSTEM METHOD : Global method returning the global factory object 
-  inline Factory* GetGlobalFactory() 
-  {
-    if (!GlobalFactoryPointer()) 
-    {
-       GlobalFactoryPointer() = new Factory;
-    }
-    return GlobalFactoryPointer();
-  }
-
-  /// SYSTEM METHOD : Deletes the global factory pointer
-  inline void DeleteGlobalFactory() 
-  {
-    if (GlobalFactoryPointer()) 
-    {
-      delete GlobalFactoryPointer();
-    }
-  }
-
-  inline void LoadPackage( const std::string& name )
-  {
-    GetGlobalFactory()->LoadPackage(name);
-  }
-
-  inline void UnLoadPackage( const std::string& name )
-  { 
-    GetGlobalFactory()->UnLoadPackage(name);
-  }
-
-  inline void PrintPackages(bool details = true, bool adaptors = false)
-  {
-    GetGlobalFactory()->PrintPackages(details,adaptors);
-  }
-
-  inline void HelpPackage(const std::string& name, bool adaptors = false) 
-  {
-    GetGlobalFactory()->HelpPackage(name,adaptors);
-  }
-  
-  inline void HelpBlackBox(const std::string& name, bool full=true) 
-  {
-    std::string package; 
-    GetGlobalFactory()->HelpBlackBox(name, package, full);
-  }
-
-  inline void HelpBlackBox(const std::string& name, std::string& package,
-                          bool full=true
-                          )
-  {
-    GetGlobalFactory()->HelpBlackBox(name, package, full);
-  }
-
-
-  inline void ShowGraphTypes(const std::string& name)
-  {
-    GetGlobalFactory()->ShowGraphTypes(name);
-  }
-
-  inline void InsertPackage( Package* p)
-  {
-    GetGlobalFactory()->InsertPackage(p);
-  }
-
-  inline void RemovePackage( Package* p)
-  {
-    GetGlobalFactory()->RemovePackage(p);
-  }
-  
-  inline const Package* GetPackage(const std::string& name) 
-  {
-    return GetGlobalFactory()->GetPackage(name);
-  }
-    
-  inline BlackBox* NewBlackBox(const std::string& type, 
-                               const std::string& name) 
-  {
-    return GetGlobalFactory()->NewBlackBox(type,name);
-  }
-    
-  inline BlackBox* NewAdaptor(TypeInfo typein,
-                              TypeInfo typeout,
-                              const std::string& name) 
-  {
-    return GetGlobalFactory()->NewAdaptor(typein,typeout,name);
-  }
-  
-  inline Connection* NewConnection(BlackBox* from,
-                                   const std::string& output,
-                                   BlackBox* to,
-                                   const std::string& input) 
-  {
-    return GetGlobalFactory()->NewConnection(from,output,to,input);
-  }
-  
-  inline void WriteDotFilePackagesList(FILE *ff)
-  {
-    GetGlobalFactory()->WriteDotFilePackagesList(ff);
-  }
-  */
 }// namespace bbtk
 
 
index febbd934840929bd6dc0002b8ca00ab0d83bd772..ede613aae17a55c7142de17f212c98ed20d9a02e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.59 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.60 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 namespace bbtk
 {
 
-  //Interpreter* Interpreter::mGlobalInterpreter = NULL;
+ //=======================================================================
+  Interpreter::Pointer Interpreter::New(const std::string& cpp_file) 
+  {
+    bbtkDebugMessage("Kernel",9,"Interpreter::New()"<<std::endl);
+    return MakePointer(new Interpreter(cpp_file));
+  }
+ //=======================================================================
 
  //=======================================================================
- /**
-   *
-   */
   Interpreter::Interpreter(const std::string& cpp_file) 
     :
     mUser(0),
     mCommandLine(false),
     mThrow(false)
   {
-bufferNb =0;  
+
+    bufferNb =0;  
     bbtk::MessageManager::RegisterMessageType("Echo","Level>0 : Prints the 'echo' commands of the user.\n\tLevel>1 : Prints the command being interpreted",1);
     bbtk::MessageManager::RegisterMessageType("Interpreter","Messages of the interpreter",0);
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::Interpreter()" <<std::endl);
  
     if (cpp_file.size()!=0)
       {
-       mExecuter = new bbtk::Transcriptor(cpp_file);
+       mExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
       }
     else 
       {
-       mExecuter = new bbtk::Executer();
+       mExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Executer::New());
       }
-    mExecuter->SetInterpreter(this);
+
+    // Lock this pointer or will auto-destruct !!
+    mExecuter->SetInterpreter(MakePointer(this,true));
     
     // For the time being, comment out previous line, and
     // uncomment next line to check Transcriptor
@@ -291,6 +297,14 @@ bufferNb =0;
     info.help = "Shows a graphical view of a bbtk pipeline.\n- BlackBoxName : name of the box to view. Default '.' : current box.\n- BlackBoxNameType : name of the type of box to view, ex : 'workspace')";
     mCommandDict[info.keyword] = info;
 
+    info.keyword = "object";
+    info.argmin = 0;
+    info.argmax = 1;
+    info.code = cObject;
+    info.syntax = "object <object name>";
+    info.help = "Provides debug info on object <object name>";
+    mCommandDict[info.keyword] = info;
+
     /*
     info.keyword = "workspace";
     info.argmin = 1;
@@ -314,10 +328,9 @@ bufferNb =0;
    */
   Interpreter::~Interpreter()
   {
-    bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <<std::endl);
-    delete mExecuter;
-
-    bbtkDebugDecTab("Interpreter",9);
+    bbtkDebugMessageInc("Interpreter",9,"==> Interpreter::~Interpreter()" <<std::endl);
+    mExecuter = VirtualExec::Pointer();
+    bbtkDebugMessageInc("Interpreter",9,"<== Interpreter::~Interpreter()" <<std::endl);
   }
   //=======================================================================
 
@@ -828,9 +841,13 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
         break;
 
       case cQuit :
-        delete mExecuter;
         throw QuitException();
         break;
+
+      case cObject :
+       if (words.size()==2) ObjectInfo(words[1]);
+       else ObjectInfo("");
+        break;
        /* obsolete
       case cWorkspace :
         if (words.size() == 2) 
@@ -1881,17 +1898,25 @@ void  Interpreter::NewGUI(const std::string& boxname,
   // connected and can be adapted from a widget adaptor
   // vector which stores the list of inputs of the box which must be connected
   std::vector<std::string> in;
-  Factory* F = mExecuter->GetFactory();
-  if (F==0)
+  Factory::Pointer F = mExecuter->GetFactory();
+  /*
+  Package::Pointer user = F->GetPackage("user");
+  */
+  ComplexBlackBoxDescriptor::Pointer workspace = mExecuter->GetWorkspace();
+
+  if (workspace==0)
     {
       delete s;
-      bbtkError("Interpreter::CreateGUI : could not access the executer factory");
+      bbtkError("Interpreter::CreateGUI : could not access the executer workspace");
     }
-  Package* user = F->GetPackage("user");
-  ComplexBlackBoxDescriptor* workspace 
-    = (ComplexBlackBoxDescriptor*)user->GetBlackBoxMap().find("workspace")->second;
-  
-  BlackBox* box = workspace->GetPrototype()->bbGetBlackBox(boxname);
+
+  /*
+    (ComplexBlackBoxDescriptor::Pointer)(user->GetBlackBoxMap().find("workspace")->second.get());
+  */
+
+  BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname);
   //  BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap();
   int nb = 0;
   BlackBox::InputConnectorMapType::iterator i;
@@ -1919,7 +1944,7 @@ void  Interpreter::NewGUI(const std::string& boxname,
          // Sets the label of the widget adaptor to the name of the input
          (*s) << "  set "<<i->first<<".Label "<<i->first<<std::endl;
          // Sets the initial value of the widget to the value of the input
-         (*s) << "  set "<<i->first<<".In \""
+         (*s) << "  set "<<i->first<<".In \" "
               <<box->bbGetInputAsString(i->first)<<"\""
               << std::endl;
          // store the input name
@@ -1943,7 +1968,7 @@ void  Interpreter::NewGUI(const std::string& boxname,
          // Sets the label of the widget adaptor to the name of the input
          (*s) << "  set "<<i->first<<"Widget.Label "<<i->first<<std::endl;
          // Sets the initial value of the widget to the value of the input
-         (*s) << "  set "<<i->first<<"Widget.In \""
+         (*s) << "  set "<<i->first<<"Widget.In \" "
               <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
          // store the input name
          in.push_back(i->first);
@@ -1964,7 +1989,7 @@ void  Interpreter::NewGUI(const std::string& boxname,
          // Sets the label of the widget adaptor to the name of the input
          (*s) << "  set "<<i->first<<".Title "<<i->first<<std::endl;
          // Sets the initial value of the widget to the value of the input
-         (*s) << "  set "<<i->first<<".In \""
+         (*s) << "  set "<<i->first<<".In \" "
               <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
          // store the input name
          in.push_back(i->first);
@@ -2014,6 +2039,53 @@ void  Interpreter::NewGUI(const std::string& boxname,
 }
 //=======================================================================
 
+
+
+ //==========================================================================
+  void Interpreter::ObjectInfo(const std::string& name)
+  {
+    Object:: PrintObjectInfo(name);
+  }
+ //==========================================================================
+ //==========================================================================
+  std::string Interpreter::GetObjectName() const
+  {
+    return std::string("Interpreter");
+  }
+  //==========================================================================
+  
+  //==========================================================================
+  std::string  Interpreter::GetObjectInfo() const 
+  {
+    std::stringstream i;
+    return i.str();
+  }
+  //==========================================================================
+
+  //==========================================================================
+size_t  Interpreter::GetObjectSize() const 
+{
+  size_t s = Superclass::GetObjectSize();
+  s += Interpreter::GetObjectInternalSize();
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+size_t  Interpreter::GetObjectInternalSize() const 
+{
+  size_t s = sizeof(Interpreter);
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  Interpreter::GetObjectRecursiveSize() const 
+  {
+    size_t s = Superclass::GetObjectRecursiveSize();
+    s += Interpreter::GetObjectInternalSize();
+    s += mExecuter->GetObjectRecursiveSize();
+    return s;
+  }
+  //==========================================================================
 }//namespace
 
 
index 48bd0ae2c22cd492ce927a5faf544a458cbb2807..b5ca18f3d168b349e071155f4eb53a76c83d8b41 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.25 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.26 $
 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,6 +39,7 @@ namespace bbtk
   class WxConsole;
 #endif
   
+  //=======================================================================
   class BBTK_EXPORT InterpreterUser
   {
   public: 
@@ -50,8 +51,11 @@ namespace bbtk
 
 
   };
+  //=======================================================================
 
-  ///
+
+
+  //=======================================================================
   class BBTK_EXPORT InterpreterError : public Exception
   {
   public:
@@ -75,67 +79,16 @@ namespace bbtk
     std::string mScriptFile;
     int mScriptLine;
   };
+  //=======================================================================
 
 
-  //
-  class BBTK_EXPORT Interpreter
+  //=======================================================================
+  class BBTK_EXPORT Interpreter : public Object
   {
-
-  private:
-
-    /// The enumeration of command codes == Command name
-    typedef enum
-    {
-      cNew,
-      cDelete,
-      cConnect,
-      cExec,
-      cPackage,
-      cEndPackage,
-      cDefine,
-      cEndDefine,
-      cInput,
-      cOutput,
-      cSet,
-      cConfig,  // JPR
-      cReset,   // EED
-      cAuthor, 
-      cCategory, // JPR
-      cDescription,
-      cHelp,
-      cMessage,
-      cInclude,
-      cQuit,
-      cLoad,
-      cUnload,
-      cGraph,
-      cPrint,
-      cIndex,
-      cKind, // LG
-      cNewGUI, // LG
-      cWorkspace // LG
-    } CommandCodeType;
-
-    /// The structure storing the informations on a command 
-    typedef struct 
-    {
-      std::string keyword;
-      int argmin, argmax;
-      CommandCodeType code;
-      std::string syntax;
-      std::string help;
-    } CommandInfoType;
-
-    /// The type of dictionnary of commands 
-    typedef std::map<std::string,CommandInfoType> CommandDictType;
-
+    BBTK_OBJECT_INTERFACE(Interpreter);
+    typedef Object Superclass;
   public:
-    /// Constructor
-    Interpreter(const std::string& cpp_file = "");
-
-    /// Destructor
-    ~Interpreter();
-
+    static Pointer New(const std::string& cpp_file = "");
 
     typedef enum 
       {
@@ -191,12 +144,59 @@ namespace bbtk
 #endif
 
     /// Gets the Executer 
-    VirtualExec* GetExecuter() { return mExecuter; }
-    /// Gets the Executer (const)
-    const VirtualExec* GetExecuter() const { return mExecuter; }
+    VirtualExec::Pointer GetExecuter() const { return mExecuter; }
 
 
   protected:
+
+    /// The enumeration of command codes == Command name
+    typedef enum
+    {
+      cNew,
+      cDelete,
+      cConnect,
+      cExec,
+      cPackage,
+      cEndPackage,
+      cDefine,
+      cEndDefine,
+      cInput,
+      cOutput,
+      cSet,
+      cConfig,  // JPR
+      cReset,   // EED
+      cAuthor, 
+      cCategory, // JPR
+      cDescription,
+      cHelp,
+      cMessage,
+      cInclude,
+      cQuit,
+      cLoad,
+      cUnload,
+      cGraph,
+      cPrint,
+      cIndex,
+      cKind, // LG
+      cNewGUI, // LG
+      cWorkspace, // LG
+      cObject
+    } CommandCodeType;
+
+    /// The structure storing the informations on a command 
+    typedef struct 
+    {
+      std::string keyword;
+      int argmin, argmax;
+      CommandCodeType code;
+      std::string syntax;
+      std::string help;
+    } CommandInfoType;
+
+    /// The type of dictionnary of commands 
+    typedef std::map<std::string,CommandInfoType> CommandDictType;
+
+
     /// Interprets a line 
     void InterpretLine( const std::string& line, bool &insideComment );
 
@@ -255,8 +255,13 @@ namespace bbtk
     void NewGUI(const std::string& box, 
                const std::string& instanceName);
 
+    void ObjectInfo(const std::string& name);
+
   private:
 
+    /// Constructor
+    Interpreter(const std::string& cpp_file = "");
+
     /// Opens the file fullPathScriptName 
     /// includeScriptName is the name as given to the include command 
     void LoadScript( std::string fullPathScriptName,
@@ -267,13 +272,13 @@ namespace bbtk
     void CatchStdException( const std::exception& e );
     void CatchUnknownException();
 
-  private:
 
+  
     //==================================================================
     // ATTRIBUTES
 
     /// The command executer used
-    bbtk::VirtualExec* mExecuter;
+    bbtk::VirtualExec::Pointer mExecuter;
 
     /// The user of  the interpreter (0 if none)
     bbtk::InterpreterUser* mUser;
index 21b0e5332015914f74b3597bac089c611cec90ab..6812de0f7d87a5dd528160c5f8ee85871b0d7218 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkMessageManager.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/20 09:51:28 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -73,6 +73,14 @@ namespace bbtk
     mMessageLevel[key] = 0;
     mMessageHelp[key] = "Graphical user interface related messages";
     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+    key = "object";
+    mMessageLevel[key] = 0;
+    mMessageHelp[key] = "object memory related messages";
+    if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+    key = "package";
+    mMessageLevel[key] = 0;
+    mMessageHelp[key] = "Packages related messages";
+    if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
    }
 
 
diff --git a/kernel/src/bbtkObject.cxx b/kernel/src/bbtkObject.cxx
new file mode 100644 (file)
index 0000000..6f42564
--- /dev/null
@@ -0,0 +1,192 @@
+#include "bbtkObject.h"
+#include "bbtkMessageManager.h"
+
+namespace bbtk
+{ 
+  
+
+  //=======================================================================
+  Object::ObjectListType Object::mgObjectList;
+  //=======================================================================
+
+  //=======================================================================
+  Object::Object()
+  { 
+  }
+  //=======================================================================
+
+
+  //=======================================================================
+  Object::~Object()
+  { 
+  }
+  //=======================================================================
+
+  //=======================================================================
+  void Object::InsertInObjectList(Pointer p)
+  { 
+    bbtkDebugMessage("object",9,"##> Object::InsertInObjectList(\""
+                    <<p->GetObjectName()<<"\" ["<<p<<"])"<<std::endl);
+    boost::weak_ptr<Object> w(p);
+    mgObjectList.insert(w); 
+  }
+  //=======================================================================
+
+
+  //=======================================================================
+  void Object::RemoveFromObjectList(WeakPointer p)
+  { 
+    bbtkDebugMessage("object",9,"##> Object::RemoveFromObjectList()"
+                    <<std::endl);
+    mgObjectList.erase(p);
+
+  }
+  //=======================================================================
+
+
+  //=======================================================================
+  std::string Object::GetObjectName() const
+  {
+    return std::string("**Unknown object**");
+  }
+  //=======================================================================
+
+  //=======================================================================
+  std::string Object::GetObjectInfo() const
+  {
+    return std::string("");
+  }
+  //=======================================================================
+  
+  //=======================================================================
+  void Object::PrintObjectListInfo()
+  {
+    
+    std::cout 
+      << "=============== Living bbtk::Object pointers ========="<<std::endl;
+
+    long n = 0;
+    long u = 0;
+    size_t m = 0;
+    ObjectListType::iterator i;
+    for (i = mgObjectList.begin();
+        i!=mgObjectList.end();
+        ++i)
+      {
+       if (i->use_count() == 0) 
+         {
+           u++;
+         }
+       else 
+         { 
+           Object::Pointer p(i->lock());
+           PrintObjectInfo(p);
+           n++;
+           m += p->GetObjectSize();
+         }
+      }
+    std::cout 
+      << "------------------------------------------------------"<<std::endl; 
+
+    std::cout << " Total : "<<n<<" objects - "<<m<<" b"<<std::endl;
+    if (u==1)
+      {
+       std::cout<<"* Note : "<<u
+                <<" object in list has 0 ref count, "
+                <<"i.e. destroyed without removing itself from the living objects list ! (this is just an implementation error not a memory leak)"<<std::endl;
+      }
+    else if (u>1)
+      {
+       std::cout<<"* Note : "<<u
+                <<" objects in list have 0 ref count, "
+                <<"i.e. destroyed without removing themselves from the living objects list ! (this is just an implementation error not a memory leak)"<<std::endl;
+      }
+    std::cout
+      << "============ EO Living bbtk::Object pointers ========="<<std::endl;
+       
+  }
+  //=======================================================================
+
+  //=======================================================================
+  void Object::PrintObjectInfo(const std::string& name)
+  {
+    long n = 0;
+    ObjectListType::iterator i;
+    for (i = mgObjectList.begin();
+        i!=mgObjectList.end();
+        ++i)
+      {
+       n++;
+       if (i->use_count() == 0) continue;
+       Object::Pointer p(i->lock());   
+       if (p->GetObjectName().find(name) != std::string::npos ) 
+         {
+           std::cout << n << "/" << mgObjectList.size() << " ";
+           PrintObjectInfo(p);
+         }
+      }
+  }
+  //=======================================================================
+
+  //=======================================================================
+  void Object::PrintObjectInfo(const Object::Pointer& p)
+  {
+    std::cout << "* [" << p << "] \t" 
+             << p.use_count()-1 << " r \t"
+             << p->GetObjectRecursiveSize() << " ("
+             << p->GetObjectSize() << ") b \t"
+             << p->GetObjectName() 
+             << std::endl;
+    std::cout << p->GetObjectInfo();
+  }
+  //=======================================================================
+
+  //=======================================================================
+  /// Objects deleter
+  void Object::Deleter::operator() (Object* p)
+  {
+    std::string name = p->GetObjectName();
+    void* adr = (void*)p;
+    bbtkDebugMessage("object",1,"##> Object::Deleter : deleting \""
+                    <<name<<"\" ["<<adr<<"]"<<std::endl);
+    Object::RemoveFromObjectList(mPointer);
+    this->Delete(p);
+    bbtkDebugMessage("object",2,"<## Object::Deleter : \""<<name<<"\" ["
+                    <<adr<<"] deleted"<<std::endl);
+  }
+  //=======================================================================
+
+
+
+
+
+
+
+
+
+  //=======================================================================
+  bool StaticInitTime::PrintObjectListInfo = false;
+  //=======================================================================
+  //=======================================================================
+  StaticInitTime::StaticInitTime() 
+  {
+  }
+  //=======================================================================
+  //=======================================================================
+  StaticInitTime::~StaticInitTime()
+  {
+    if (PrintObjectListInfo) 
+      {
+       std::cout << std::endl
+                 << "***************** main ended *******************"
+                 << std::endl << std::endl;
+       Object::PrintObjectListInfo();
+      }
+  }
+  //=======================================================================
+  //=======================================================================
+  //  The static instance
+  static StaticInitTime i;
+  //=======================================================================
+
+}
diff --git a/kernel/src/bbtkObject.h b/kernel/src/bbtkObject.h
new file mode 100644 (file)
index 0000000..21109d3
--- /dev/null
@@ -0,0 +1,193 @@
+/*=========================================================================
+                                                                                
+  Program:   bbtk
+  Module:    $RCSfile: bbtkObject.h,v $
+  Language:  C++
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See doc/license.txt or
+  http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+/**
+ *\file
+ *\brief  Object : the top class of bbtk class hierarchy 
+ * 
+ */
+
+#ifndef __bbtkObject_h__
+#define __bbtkObject_h__
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <set>
+
+namespace bbtk
+{
+
+  // The top class of bbtk class hierarchy 
+  class Object 
+  {
+  public:
+    typedef boost::shared_ptr<Object> Pointer;
+    typedef boost::weak_ptr<Object> WeakPointer;
+
+    Object();
+    virtual ~Object(); 
+    
+    virtual std::string GetObjectName() const;
+    virtual std::string GetObjectInfo() const;
+    virtual size_t GetObjectSize() const { return sizeof(Object); }
+    virtual size_t GetObjectInternalSize() const { return sizeof(Object); }
+    virtual size_t GetObjectRecursiveSize() const { return sizeof(Object); }
+    long GetUseCount() { return mThisPointer.use_count(); }
+    
+    static void InsertInObjectList(Pointer);
+    static void RemoveFromObjectList(WeakPointer);
+
+    static void PrintObjectListInfo();
+    static void PrintObjectInfo(const std::string& name);
+    static void PrintObjectInfo(const Pointer& o); 
+    /// Default objects deleter : removes object from list on deletion
+    struct Deleter 
+    { 
+      Deleter() : mPointer() {}
+      virtual void operator() (Object* p); 
+      virtual void Delete(Object* p) { delete p; }
+      WeakPointer mPointer;
+    };
+
+  protected:
+    void LockThis() { mThisPointerLocked = mThisPointer.lock(); }      
+    void UnLockThis() { mThisPointerLocked = Pointer(); }
+    //    Object::Pointer GetThis() const { return mThisPointer.lock(); } 
+    template <class U>
+    boost::shared_ptr<U> GetThisPointer() const 
+    {
+      return boost::dynamic_pointer_cast<U>(mThisPointer.lock());
+    }
+    template <class U>
+    static boost::shared_ptr<U> MakePointer(U* s, bool lock = false)
+    {                                                                  
+      if (s->mThisPointer.lock())                                      
+       {                                                               
+         boost::shared_ptr<U> p = s->GetThisPointer<U>();
+         if (!lock) s->mThisPointerLocked.reset();
+         return p;
+       }                                                               
+      boost::shared_ptr<U> p = boost::shared_ptr<U>(s,Object::Deleter());
+      static_cast<Object::Deleter*>                                    
+       (p._internal_get_deleter(typeid(Object::Deleter)))              
+       ->mPointer = p;                                                 
+      s->mThisPointer = p;                                             
+      Object::InsertInObjectList(p);                                   
+      if (lock) s->LockThis();                                         
+      return p;                                                        
+    }                                                                  
+    template <class U, class D>
+     static boost::shared_ptr<U> MakePointer(U* s, 
+                                            const D& del,
+                                            bool lock = false)
+    {                                                                  
+      if (s->mThisPointer.lock())                                      
+       {                                                               
+         boost::shared_ptr<U> p = s->GetThisPointer<U>();
+         if (!lock) s->mThisPointerLocked.reset();
+         return p;
+       }                                                               
+      boost::shared_ptr<U> p = boost::shared_ptr<U>(s,del);
+      static_cast<D*>                                  
+       (p._internal_get_deleter(typeid(D)))            
+       ->mPointer = p;                                                 
+      s->mThisPointer = p;                                             
+      Object::InsertInObjectList(p);                                   
+      if (lock) s->LockThis();                                         
+      return p;                                                        
+    }                                                                  
+     
+
+  private:
+    typedef std::set<boost::weak_ptr<Object> > ObjectListType;
+    static ObjectListType mgObjectList;
+    WeakPointer mThisPointer;                                          
+    Pointer mThisPointerLocked;                                                
+
+  }; 
+  
+#define BBTK_OBJECT_DEFINE_SELF(CLASS) public : typedef CLASS Self; 
+  
+#define BBTK_FORWARD_DECLARE_POINTER(CLASS)                    \
+  typedef boost::shared_ptr<CLASS> CLASS ## Pointer;           \
+    typedef boost::weak_ptr<CLASS> CLASS ## WeakPointer;
+
+
+#define BBTK_OBJECT_MINIMAL_INTERFACE                                  \
+  public:                                                              \
+  typedef boost::shared_ptr<Self> Pointer;                             \
+    typedef boost::weak_ptr<Self> WeakPointer;                         \
+    friend struct Object::Deleter;                                     
+  //private:                                                           
+
+  // does not work : why ?
+  //      boost::get_deleter<Deleter,Pointer>(pt)->mPointer = pt; 
+  //
+  
+#define BBTK_OBJECT_MINIMAL_INTERFACE_WITH_SELF(CLASS) \
+  public : typedef CLASS Self;                         \
+    BBTK_OBJECT_MINIMAL_INTERFACE;             
+
+#define BBTK_OBJECT_INTERFACE(CLASS)                               \
+  BBTK_OBJECT_MINIMAL_INTERFACE_WITH_SELF(CLASS);                  \
+public:                                                                    \
+  std::string GetObjectName() const;                               \
+    std::string GetObjectInfo() const ;                                    \
+    size_t GetObjectSize() const ;                                 \
+    size_t GetObjectInternalSize() const ;                         \
+    size_t GetObjectRecursiveSize() const ;                        \
+protected:                                                         \
+    CLASS();                                                       \
+    CLASS(const CLASS&);                                                   \
+    ~CLASS();                                      
+  
+#define BBTK_ABSTRACT_OBJECT_INTERFACE(CLASS)                          \
+  public : typedef CLASS Self;                                         \
+    BBTK_OBJECT_MINIMAL_INTERFACE;                                     \
+protected:                                                             \
+    CLASS();                                                           \
+    CLASS(const CLASS&);                                                       \
+    virtual ~CLASS();                                      
+  
+  //=======================================================================
+  // A struct with one static instance 
+  // just to print object list info after main
+  struct StaticInitTime
+  {
+    StaticInitTime();
+    ~StaticInitTime();
+
+
+    static bool PrintObjectListInfo;
+  private:
+    static Object mObject;
+  };
+  
+  
+  /*
+  template <class T, class U>
+  inline T BruteForceDownCastPointer(class U p)
+  {
+    
+  }
+  */
+
+}// namespace bbtk
+
+#endif
+
index b24272152df64d0fa61b3a7d90c45efe5289823e..94286b37811f8f99a3cc8b17a8b1ddbd51c0636f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkPackage.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See doc/license.txt or
 
 namespace bbtk
 {
+  
+
+
+  //==========================================================================
+  /// Creates a new package
+  Package::Pointer Package::New(const std::string& name,
+                               const std::string& author,
+                               const std::string& description,
+                               const std::string& version,
+                               const std::string& BBTKVersion) 
+  {
+    bbtkDebugMessage("object",1,"##> Package::New('"<<name<<"',...)"
+                    <<bbtkendl);
+    Package::Pointer p = MakePointer(new Package(name,
+                                              author,
+                                              description,
+                                              version,
+                                              BBTKVersion));
+    bbtkDebugMessage("object",2,"<## Package::New('"<<name<<"',...)"
+                    <<bbtkendl);
+    return p;
+  }
+  //==========================================================================
+
   //==========================================================================
   /// Ctor with the name of the package
   Package::Package(const std::string& name,
@@ -36,12 +60,14 @@ namespace bbtk
                   const std::string& version,
                   const std::string& BBTKVersion) 
     :
+    mDynamicLibraryHandler(0),
     mName(name),
     mAuthor(author),
     mDescription(description),
-    mVersion(version),
-    mBBTKVersion(BBTKVersion)
+    mVersion(version)
   {
+    bbtkDebugMessage("object",2,"==> Package::Package('"<<name<<"',...)"
+                    <<bbtkendl);
     std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
     char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
     std::string url = default_doc_dir; 
@@ -62,7 +88,9 @@ namespace bbtk
 
     //    std::cout  << "   url=["<<url<<"]"<<std::endl;
     //    std::cout  << "relurl=["<<relurl<<"]"<<std::endl;
-    bbtkDebugMessage("Kernel",7,"Package::Package(\""<<name<<"\")"<<bbtkendl);
+    bbtkDebugMessage("object",2,"<== Package::Package('"<<name<<"',...) OK"
+                    <<bbtkendl);
+
   }
   //==========================================================================
 
@@ -72,34 +100,542 @@ namespace bbtk
   /// Dtor
   Package::~Package()
   {
-    bbtkDebugMessageInc("Kernel",7,"Package::~Package(\""<<mName<<"\")"<<bbtkendl);
-    BlackBoxMapType::const_iterator i;
-    for (i=mBlackBoxMap.begin();
-         i!=mBlackBoxMap.end();
-       ++i) 
-     {
-       i->second->UnReference();
-     } 
-    // Adaptors are also stored in the black box map : hence already deleted
+    bbtkDebugMessage("object",2,"==> Package::~Package(\""<<mName<<"\")"<<bbtkendl);
+    bbtkDebugMessage("object",2,"<== Package::~Package(\""<<mName<<"\")"<<bbtkendl);
+  }
+  //==========================================================================
+
+
+  //==========================================================================
+  void PackageReleaseBlackBoxDescriptorInternal(Package::WeakPointer pack,
+                                               const std::string& descname)
+  {
+    // Try to release descriptor
+    bbtkDebugMessage("package",3,"--- Trying to release descriptor '"
+                    <<descname<<"'"<<bbtkendl);
+    std::string packname = pack.lock()->GetName();
+
+    Package::BlackBoxMapType::iterator desc = 
+      pack.lock()->GetBlackBoxMap().find(descname);
+    if (desc ==  pack.lock()->GetBlackBoxMap().end())
+      {
+       bbtkDebugMessage("package",3,
+                        "    Descriptor has already been released"
+                        <<bbtkendl);
+       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,
+                            "    ... and caused its package death"
+                            <<bbtkendl);
+           return;
+         }
+       desc = pack.lock()->GetBlackBoxMap().find(descname);
+       if (desc !=  pack.lock()->GetBlackBoxMap().end())
+         pack.lock()->GetBlackBoxMap().erase(desc);
+      }
+    else 
+      {
+       bbtkDebugMessage("package",3,"    ... Descriptor still alive ("
+                        <<pdesc.use_count()<<" refs)"
+                        <<bbtkendl);
+       pack.lock()->GetBlackBoxMap()[descname] = pdesc.lock();
+      }
+  }
+  //==========================================================================
+
+
+  //==========================================================================
+  /// Release
+  void Package::Release(Package::WeakPointer pack)
+  {
+    std::string packname = pack.lock()->mName;
+    bbtkDebugMessage("package",1,"==> Package::Release('"<<
+                    packname<<"')"<<bbtkendl);
+
+    long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
+    long ndesc = pack.lock()->GetBlackBoxMap().size();
+    long nrefs = pack.use_count();
+
+    bbtkDebugMessage("package",2," "<<nrefs<<" refs / "
+                    <<ndesc<<" descr / dyn="
+                    <<dyn<<std::endl);
+
+    // A package is "free" from any external reference iff :
+    // i) It is not dynamically loaded and nrefs == ndesc 
+    // (each desc references its package) or
+    // ii) It is dynamically loaded and nrefs == ndesc + 1
+    // (A dynamic library holds a static pointer on the package it contains
+    //  which is allocated when the PACKAGENAMEGetPackage() func is called,
+    //  and descallocated (reset) by PACKAGENAMEDeletePackage())
+    if (nrefs == ndesc + dyn) 
+      {
+       bbtkDebugMessage("package",2,
+                        " -> No more external ref : checking descriptors"
+                        <<bbtkendl);
+       // We must take care that removing refs on descriptors 
+       // can lead to their deletion which can in turn unref 
+       // internal boxes which can release their descriptors hence 
+       // call Package::ReleaseBlackBoxDescriptor 
+       // As a consequence during descriptors release :
+       // 1) The map can change dynamically : we cannot iterate over it 
+       //    as any iterator can become invalid
+       // 2) The package can auto-destruct : we must test its existence 
+       //    after each release
+       // We must also take care of not locking the package pointer 
+       // or any ref count check in Package::ReleaseBlackBoxDescriptor
+       // would be wrong
+
+       // 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();
+            ++i)
+         descnamelist.push_back(i->first);
+
+       // Iterator over the initial names
+       std::vector<std::string>::iterator descname;
+       for (descname=descnamelist.begin();
+            descname!=descnamelist.end();
+            ++descname)
+         {
+           // Is package still alive ?
+           if (pack.expired()) 
+             {
+               bbtkDebugMessage("package",2,"--- Package::Release('"<<
+                                packname
+                                <<"') : package expired during release : bailing out"<<bbtkendl);
+               break;
+             }
+           
+           PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
+           
+         }
+
+       //
+       UnLoadDynamicLibrary(pack);
+       // Unload orphan dl packages 
+       Package::UnLoadReleasedDynamicallyLoadedPackages();
+       
+
+       
+       
+      }
+    
+    bbtkDebugMessage("package",1,"<== Package::Release('"<<
+                    packname<<"')"<<bbtkendl);
+    if (!pack.expired())
+      {
+       long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
+       long ndesc = pack.lock()->GetBlackBoxMap().size();
+       long nrefs = pack.use_count();
+       
+       bbtkDebugMessage("package",1," ... Package still alive ("
+                        <<nrefs<<" refs / "
+                        <<ndesc<<" descr / dyn="
+                        <<dyn<<")"<<std::endl);
+      }
+    else 
+      {
+       bbtkDebugMessage("package",1,"   ... Package has been released"
+                        <<std::endl);
+      }
+  }
+  //==========================================================================
+
+  //==========================================================================
+  /// "Releases" the package
+  /// Signals the package that it can free the given descriptor
+  /// if they are no more used and free itself if it is no
+  /// more used
+  /// Note : Any non-weak pointer on the package must have been freed
+  void Package::ReleaseBlackBoxDescriptor(Package::WeakPointer pack,
+                                         BlackBoxDescriptor::WeakPointer descr)
+  {
+    std::string packname = pack.lock()->mName;
+    std::string dname = descr.lock()->GetTypeName();    
+    bbtkDebugMessage("package",3,"==> Package::ReleaseBlackBoxDescriptor('"<<
+                    packname<<"','"<<dname<<"')"<<bbtkendl);
+
+    long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
+    long ndesc = pack.lock()->GetBlackBoxMap().size();
+    long nrefs = pack.use_count();
+
+    bbtkDebugMessage("package",3," "<<nrefs<<" refs / "
+                    <<ndesc<<" descr / dynamically loaded = "
+                    <<dyn<<std::endl);
+
+    // A package is "free" from any external reference iff :
+    // i) It is not dynamically loaded and nrefs == ndesc 
+    // (each desc references its package) or
+    // ii) It is dynamically loaded and nrefs == ndesc + 1
+    // (A dynamic library holds a static pointer on the package it contains
+    //  which is allocated when the PACKAGENAMEGetPackage() func is called,
+    //  and descallocated (reset) by PACKAGENAMEDeletePackage())
+    if (nrefs == ndesc + dyn) 
+      {
+       PackageReleaseBlackBoxDescriptorInternal(pack,dname);
+      }
+    
+    // If the package is released and dynamically loaded 
+    // then put it in the static list mReleasedDynamicallyLoadedPackages
+    UnLoadDynamicLibrary(pack,false);
+        
+    bbtkDebugMessage("package",3,"<== Package::ReleaseBlackBoxDescriptor('"<<
+                    packname<<"','"<<dname<<"')"<<bbtkendl);
     /*
-    AdaptorMapType::const_iterator j;
-    for (j=mAdaptorMap.begin();
-         j!=mAdaptorMap.end();
-       ++j) 
+    if (!pack.expired())
       {
-         delete j->second;
+       long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
+       long ndesc = pack.lock()->GetBlackBoxMap().size();
+       long nrefs = pack.use_count();
+       
+       bbtkDebugMessage("package",3," ... Package still alive ("
+                        <<nrefs<<" refs / "
+                        <<ndesc<<" descr / dyn="
+                        <<dyn<<")"<<std::endl);
       }
-    */ 
-    bbtkDebugDecTab("Kernel",7);
+    else 
+      {
+       bbtkDebugMessage("package",3,"   ... Package has been released"
+                        <<std::endl);
+      }  
+    */
+  }
+  //==========================================================================    
+
+  //==========================================================================
+  /// Opens a dynamic library which contains a bbtk package
+  /// Returns the handler 
+  /// Load the package management symbols from the lib
+  /// returns false if a problem occured hence can be used 
+  /// to test that a dyn lib is a valid bbtk package lib
+  /// NB : The BBTK version exported from the library 
+  ///      is tested against the current bbtk version
+  DynamicLibraryHandler Package::OpenDynamicLibrary
+  ( const std::string& libname,
+    const std::string& package_name,
+    DLGetPackageFunction& getpack,
+    DLDeletePackageFunction& delpack)
+  {
+    bbtkDebugMessage("package",3,"==> Package::OpenDynamicLibrary("
+                    <<libname<<")"<<std::endl);
+#if defined(__GNUC__)
+
+    // Open shared lib
+    void *handler;
+    handler = dlopen(libname.c_str(),
+                    BBTK_RTLD_TIME | BBTK_RTLD_SCOPE );
+    if (!handler)
+      {
+       bbtkMessage("package",2,
+                   "Could not open shared library [" <<libname<<"] : "
+                   <<dlerror() << std::endl);
+       return 0;
+      }
+
+    bbtkDebugMessage("package",3,"* Shared lib ["<<libname<<"] open"<<std::endl);
+
+    // Loads the Package bbtk version function 
+    std::string getvername(package_name);
+    getvername += 
+      BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME);
+    DLGetPackageBBTKVersionFunction getbbtkversion 
+      = (DLGetPackageBBTKVersionFunction)(dlsym(handler,getvername.c_str()));
+    if (!getbbtkversion)
+      {
+       bbtkDebugMessage("package",3,"***"<<std::endl);
+       bbtkMessage("package",2,
+                   "Shared library ["<<libname
+                   <<"] is not a valid bbtk package."
+                   <<" Symbol ["<<getvername<<"] :"<<dlerror()<< std::endl);
+       dlclose(handler);
+       return 0;
+      }
+
+    bbtkDebugMessage("package",3,"* Symbol ["<<getvername
+                    <<"] found"<<std::endl);
+    // version matches ?
+    if (getbbtkversion() != bbtk::GetVersion())
+      {
+       bbtkMessage("package",2,
+                   "Shared library ["<<libname
+                   <<"] was build with bbtk version "
+                   <<getbbtkversion()
+                   <<" but the current program runs with version "
+                   <<bbtk::GetVersion()<<" : cannot load it"<<std::endl);
+       dlclose(handler);
+       return 0;
+       
+      }
+
+    bbtkDebugMessage("package",3,"* Package bbtk version '"<<getbbtkversion()<<"' matches"<<std::endl);
+           // Loads the Package get function
+    std::string getpackname(package_name);
+    getpackname += BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_FUNCTION_NAME);
+    getpack = (DLGetPackageFunction)(dlsym(handler, getpackname.c_str()));
+    if (!getpack)
+      {
+       bbtkMessage("package",2,
+                   "Shared library ["<<libname
+                   <<"] is not a valid bbtk package."
+                   <<" Symbol ["<<getpackname<<"] :"<<dlerror()<< std::endl);
+       dlclose(handler);
+       return 0;
+      }
+  
+    bbtkDebugMessage("package",3,"* Symbol ["<<getpackname<<"] found"<<std::endl);
+    // Loads the Package delete function
+                                         
+    std::string delpackname(package_name);
+    delpackname += BBTK_STRINGIFY_SYMBOL(BBTK_DEL_PACKAGE_FUNCTION_NAME);
+    delpack = (DLDeletePackageFunction)(dlsym(handler, delpackname.c_str()));
+    if (!delpack)
+      {
+       bbtkMessage("package",2,
+                   "Shared library ["<<libname
+                   <<"] is not a valid bbtk package."
+                   <<" Symbol ["<<delpackname<<"] :"<<dlerror()<< std::endl);
+       dlclose(handler);
+       return 0;
+      }
+    bbtkDebugMessage("package",3,"* Symbol ["<<delpackname<<"] found"<<std::endl);               
+#elif defined(_WIN32)
+    
+    HINSTANCE handler;
+    
+    SetErrorMode(0);
+    // Open shared lib
+    handler = LoadLibrary(libname.c_str());
+    if (!handler)
+      {
+       bbtkMessage("package",2,
+                   "Could not open shared library [" <<libname<<"]"
+                   << std::endl);
+       return 0;
+      }
+    
+    // Loads the Package bbtk version function 
+    std::string getvername(package_name);
+    getvername += 
+      BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME);
+    DLGetPackageBBTKVersionFunction getbbtkversion 
+      = (DLGetPackageBBTKVersionFunction)(GetProcAdress(handler,
+                                                       getvername.c_str()));
+    if (!getbbtkversion)
+      {
+       FreeLibrary(handler);
+       bbtkMessage("package",2,
+                   "Shared library ["<<libname
+                   <<"] is not a valid bbtk package."
+                   <<" Symbol ["<<getbbtkversion<<"] not found"<< std::endl);
+       return 0;
+      }
+    
+    // version matches ?
+    if (getbbtkversion() != bbtk::GetVersion())
+      {
+       FreeLibrary(handler);
+       bbtkMessage("package",2,
+                   "Shared library ["<<libname
+                   <<"] was build with bbtk version "
+                   <<getbbtkversion()
+                   <<" but the current program runs with version "
+                   <<bbtk::GetVersion()<<" : cannot load it"<<std::endl);
+       return 0;
+       
+      }
+
+     // Loads the Package get function
+    std::string getpackname(package_name);
+    getpackname += BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_FUNCTION_NAME);
+    getpack = (DLGetPackageFunction)(GetProcAdress(handler, getpackname.c_str()));
+    if (!getpack)
+      {
+       FreeLibrary(handler);
+       bbtkMessage("package",2,
+                   "Shared library ["<<libname
+                   <<"] is not a valid bbtk package."
+                   <<" Symbol ["<<getpackname<<"] not found"<< std::endl);
+       return 0;
+      }
+    
+    // Loads the Package delete function
+    std::string delpackname(package_name);
+    delpackname += BBTK_STRINGIFY_SYMBOL(BBTK_DEL_PACKAGE_FUNCTION_NAME);
+    delpack = (DLDeletePackageFunction)(GetProcAdress(handler, delpackname.c_str()));
+    if (!delpack)
+      {
+       FreeLibrary(handler);
+       bbtkMessage("package",2,
+                   "Shared library ["<<libname
+                   <<"] is not a valid bbtk package."
+                   <<" Symbol ["<<delpackname<<"] not found"<< std::endl);
+       return 0;
+      }
+                                        
+#else
+    bbtkError("neither __GNUC__ nor _WIN32 ?!? How did you compile ?");
+#endif
+    
+    return handler;
+  }
+  //==========================================================================
+  
+  //==========================================================================
+  /// Loads a package from a dynamic library
+  Package::Pointer Package::CreateFromDynamicLibrary(const std::string& libname,
+                                                    const std::string& pkgname,
+                                                    const std::string& path)
+  {
+    bbtkDebugMessage("package",1,"==> Package::CreateFromDynamicLibrary("
+                    <<libname<<")"<<std::endl);
+
+    DLGetPackageFunction gf;
+    DLDeletePackageFunction df;
+    DynamicLibraryHandler h = Package::OpenDynamicLibrary(libname,
+                                                         pkgname,
+                                                         gf,df);
+    if (h==0) return Package::Pointer(); 
+    Package::Pointer p = gf();
+    p->mDynamicLibraryHandler = h;
+    p->mDLDeletePackageFunction = df;
+    
+    std::string separator =
+      ConfigurationFile::GetInstance().Get_file_separator ();
+    //BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
+    std::string docreldoc = 
+      separator + "bbdoc" + separator + pkgname + separator + "index.html";
+    std::string reldoc = 
+      ".." + separator + ".." + docreldoc;
+    std::string doc = path + separator + ".." + separator
+      + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
+      + docreldoc;
+    
+    p->SetDocURL(doc);
+    p->SetDocRelativeURL(reldoc);
+    
+    bbtkDebugMessage("package",1,"<== Package::CreateFromDynamicLibrary("
+                    <<libname<<") .. OK"<<std::endl);
+    return p;
+  }
+  //==========================================================================
+
+
+
+
+  //==========================================================================
+  /// UnLoads the package dynamic library (if any)
+  void Package::UnLoadDynamicLibrary(Package::WeakPointer pack, bool doit)
+  {
+    if (pack.expired() || (!pack.lock()->mDynamicLibraryHandler))
+      return;
+    
+    
+    std::string packname = pack.lock()->GetName();
+    bbtkDebugMessage("package",3,"==> Package::UnLoadDynamicLibrary('"
+                    <<packname<<"')"
+                    <<std::endl);
+    
+    if (!pack.lock()->GetBlackBoxMap().empty())
+      {
+       
+       bbtkDebugMessage("package",3,"   Package not empty ... abort"
+                        <<std::endl);
+       return;
+       /*
+       bbtkGlobalError("Package::UnLoadDynamicLibrary('"<<packname<<") : "
+                       <<"BlackBoxMap not empty "
+                       <<BBTK_INTERNAL_ERROR_MESSAGE);
+       */
+       
+      }
+
+    if (pack.use_count()!=1)
+      {
+       bbtkGlobalError("Package::UnLoadDynamicLibrary('"<<packname<<") : "
+                       <<"empty dl package with external refs"
+                       <<BBTK_INTERNAL_ERROR_MESSAGE);
+      } 
+
+    if (doit) 
+      {
+       UnLoad(pack);
+       bbtkDebugMessage("package",3,"   ... dynamic library closed"
+                        <<std::endl);    
+      }
+    else 
+      {
+       mReleasedDynamicallyLoadedPackages.insert(pack);
+       bbtkDebugMessage("package",3,
+                        "   ... package put in the 'to unload' list"
+                        <<std::endl);
+
+      }
+
+    bbtkDebugMessage("package",3,"<== Package::UnLoadDynamicLibrary('"
+                    <<packname<<"')"
+                    <<std::endl);
+    
+  }
+  //==========================================================================
+
+  //==========================================================================
+  /// UnLoads released packages that were loaded dynamically
+  /// see UnLoadDynamicLibrary and ReleaseBlackBoxDescriptor
+  void Package::UnLoadReleasedDynamicallyLoadedPackages()
+  {
+    bbtkDebugMessage("package",2,"==> Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl);
+
+    std::set<Package::WeakPointer>::iterator i;
+    for (i=mReleasedDynamicallyLoadedPackages.begin();
+        i!=mReleasedDynamicallyLoadedPackages.end();
+        ++i)
+      {
+       if (!i->expired()) UnLoad(*i);
+      }
+    bbtkDebugMessage("package",2,"<== Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl);
   }
   //==========================================================================
 
+  //==========================================================================
+  void Package::UnLoad(Package::WeakPointer pack)
+  {
+    std::string packname = pack.lock()->GetName();
+    bbtkDebugMessage("package",2,"==> Package::UnLoad("<<packname<<")"<<std::endl);
 
+    Package* p = pack.lock().get();
+    
+    DynamicLibraryHandler h = p->mDynamicLibraryHandler;
+    
+    // deletes the package
+    p->mDLDeletePackageFunction();
+    
+    // closes the dl handler
+#if defined(__GNUC__)  
+    dlclose(h);  
+#elif defined(_WIN32)
+    FreeLibrary(h);
+#endif
+
+    bbtkDebugMessage("package",2,"   ... dynamic library unloaded"<<std::endl);
+  }
+  //==========================================================================
 
   //==========================================================================
   /// Creates an instance of a black box of type <type> with name <name>
-  BlackBox* Package::NewBlackBox(const std::string& type, 
-                                   const std::string& name) const
+  BlackBox::Pointer Package::NewBlackBox(const std::string& type, 
+                                        const std::string& name) const
   {
     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::NewBlackBox(\""<<type<<"\",\""<<name<<"\")"<<bbtkendl);
     
@@ -107,9 +643,9 @@ namespace bbtk
     if (i == mBlackBoxMap.end())  
     {
           bbtkDebugDecTab("Kernel",8);
-          return 0;
+          return BlackBox::Pointer();
     }
-    BlackBox* bb =i->second->CreateInstance(name);
+    BlackBox::Pointer bb =i->second->NewBlackBox(name);
     bbtkDebugDecTab("Kernel",8);
     return bb;   
 
@@ -121,7 +657,7 @@ namespace bbtk
   //==========================================================================
   /// Creates an instance of an adaptor of input type <typein> and 
   /// output type <typeout>  with name <name>
-  BlackBox* Package::NewAdaptor(const DataInfo& typein,
+  BlackBox::Pointer Package::NewAdaptor(const DataInfo& typein,
                                const DataInfo& typeout,
                                const std::string& name) const
   {
@@ -137,9 +673,9 @@ namespace bbtk
     if (i == mAdaptorMap.end())  
       {
        bbtkDebugDecTab("Kernel",8);
-       return 0;
+       return BlackBox::Pointer();
       }
-    BlackBox* bb =i->second->CreateInstance(name);
+    BlackBox::Pointer bb =i->second.lock()->NewBlackBox(name);
     bbtkDebugDecTab("Kernel",8);
     return bb;   
 
@@ -149,7 +685,7 @@ namespace bbtk
   //==========================================================================
   /// Creates an instance of an adaptor of input type <typein> and 
   /// output type <typeout>  with name <name>
-  BlackBox* Package::NewWidgetAdaptor(const DataInfo& typein,
+  BlackBox::Pointer Package::NewWidgetAdaptor(const DataInfo& typein,
                                      const DataInfo& typeout,
                                      const std::string& name) const
   {
@@ -165,9 +701,9 @@ namespace bbtk
     if (i == mAdaptorMap.end())  
       {
        bbtkDebugDecTab("Kernel",8);
-       return 0;
+       return BlackBox::Pointer();
       }
-    BlackBox* bb =i->second->CreateInstance(name);
+    BlackBox::Pointer bb =i->second.lock()->NewBlackBox(name);
     bbtkDebugDecTab("Kernel",8);
     return bb;   
 
@@ -190,7 +726,9 @@ namespace bbtk
                        <<typein<<","
                        <<typeout<<")"<<bbtkendl);
    
-    AdaptorKey key(typein,typeout,
+    AdaptorKey key(/*typein*/
+                  DataInfo(typeid(void),""),
+                  typeout,
                   BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR);
     // First try to find a single widget adaptor
     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
@@ -199,7 +737,7 @@ namespace bbtk
        bbtkDebugDecTab("Kernel",8);
        return false;
       }
-    adaptor = i->second->GetTypeName();
+    adaptor = i->second.lock()->GetTypeName();
     bbtkDebugDecTab("Kernel",8);
     return true;   
 
@@ -230,7 +768,7 @@ namespace bbtk
        bbtkDebugDecTab("Kernel",8);
        return false;
       }
-    adaptor = i->second->GetTypeName();
+    adaptor = i->second.lock()->GetTypeName();
     bbtkDebugDecTab("Kernel",8);
     return true;   
 
@@ -240,7 +778,7 @@ namespace bbtk
 
   //==========================================================================
   /// Registers a black box descriptor in the package
-  bool Package::RegisterBlackBox(BlackBoxDescriptor* d) 
+  bool Package::RegisterBlackBox(BlackBoxDescriptor::Pointer d) 
   {
     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
     
@@ -253,24 +791,22 @@ namespace bbtk
       }
 
     mBlackBoxMap[d->GetTypeName()] = d;
-    d->Reference();
-    d->SetPackage(this);
+    //    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) ||
-        (d->GetKind() == BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR) )
+    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);   
+       
        TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
        TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
        DataInfo infoin(typein,d->GetInputDescriptor("In")->GetNature());
        DataInfo infoout(typeout,d->GetOutputDescriptor("Out")->GetNature());
-       bbtkDebugMessage("Kernel",9,"Adaptor "<<infoin<<" to "<<infoout 
-                        <<" - kind="<<d->GetKind()<<std::endl);  
-
        AdaptorKey key(infoin,infoout,d->GetKind());
-
-       AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
+       
+       AdaptorMapType::const_iterator i;
+       i = mAdaptorMap.find(key);        
        if (i == mAdaptorMap.end())  
          {
            mAdaptorMap[key] = d;
@@ -278,17 +814,47 @@ namespace bbtk
        // If already an adaptor registered : error
        else 
          {
-           if (i->second->GetTypeName() != d->GetTypeName()) 
+           if (i->second.lock()->GetTypeName() != d->GetTypeName()) 
              {
                bbtkError("Package <"<<GetName()<<
                          "> : trying to register black box <"
                          <<d->GetTypeName()
                          <<"> as default adaptor but there is already a default adaptor registered (<"
-                         <<i->second->GetTypeName()<<">)");
+                         <<i->second.lock()->GetTypeName()<<">)");
+             }
+         }
+      }
+    // If it is a default adaptor, also register it in the adaptors map
+    else if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR)
+      {
+       bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<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),"");
+       DataInfo infoout(typeout,d->GetOutputDescriptor("Out")->GetNature());
+       AdaptorKey key(infoin,infoout,d->GetKind());
+
+       AdaptorMapType::const_iterator i;
+       i = mAdaptorMap.find(key);        
+       if (i == mAdaptorMap.end())  
+         {
+           mAdaptorMap[key] = d;
+         }
+       // If already an adaptor registered : error
+       else 
+         {
+           if (i->second.lock()->GetTypeName() != d->GetTypeName()) 
+             {
+               bbtkError("Package <"<<GetName()<<
+                         "> : trying to register black box <"
+                         <<d->GetTypeName()
+                         <<"> as default widget adaptor but there is already a default adaptor registered (<"
+                         <<i->second.lock()->GetTypeName()<<">)");
              }
          }
       }
     
+
     bbtkDebugDecTab("Kernel",8);
    
     return true;
@@ -312,34 +878,6 @@ namespace bbtk
   }
   //===================================================================
 
-  //==========================================================================
-  /// UnRegisters a black box descriptor from the package
-  void Package::UnRegisterBlackBox(const std::string& name) 
-  {
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::UnRegisterBlackBox(\""<<name<<"\")"<<std::endl);
-    // Looking into the bb map
-    BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
-    if (i == mBlackBoxMap.end())  
-    {
-       bbtkDebugDecTab("Kernel",8);
-       bbtkError("UnRegister : The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
-     }
-    mBlackBoxMap.erase(i);
-
-    // Is it also in the adaptors map ?
-    /*
-    AdaptorMapType::iterator j = mAdaptorMap.find(name);
-    if (j != mAdaptorMap.end())  
-      {
-         mAdaptorMap.erase(j);
-      }
-    */    
-
-    i->second->UnReference();
-
-    bbtkDebugDecTab("Kernel",8);    
-  }
-  //==========================================================================
 
   //==========================================================================
   /// Changes the name of a black box type
@@ -362,23 +900,6 @@ namespace bbtk
   }
   //==========================================================================
 
-  /*
-
-  //==========================================================================
-  /// Registers an adaptor descriptor in the package
-  bool Package::RegisterAdaptor(BlackBoxDescriptor* d) 
-  {
-    bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterAdaptor(\""<<d->GetTypeName()<<"\")"<<std::endl);
-    
-    TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
-    TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
-    AdaptorKey key(typein,typeout);
-    
-    mAdaptorMap[key] = d;
-    return true;
-  }
-  //==========================================================================
-  */
 
 
   //==========================================================================
@@ -641,7 +1162,7 @@ namespace bbtk
        s << "<TR><TD style='vertical-align: top;'><b> Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 
          << GetVersion() << "</TD></TR>\n";
        s << "<TR><TD style='vertical-align: top;'><b> bbtk Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 
-         << GetBBTKVersion() << "</TD></TR>\n";
+         << bbtk::GetVersion() << "</TD></TR>\n";
        s << "</TABLE>\n";
       }
 
@@ -770,5 +1291,61 @@ namespace bbtk
     bbtkDebugDecTab("Kernel",9);
   }
   //==========================================================================
+  
+  //==========================================================================
+  std::string  Package::GetObjectName() const 
+  { 
+    return std::string("Package '")+mName+std::string("'"); 
+  }
+  //==========================================================================
+
+  //==========================================================================
+  std::string Package::GetObjectInfo() const 
+  {
+    std::stringstream i;
+    i << "  - "<<mBlackBoxMap.size() << " boxes" << std::endl;
+    if (mDynamicLibraryHandler) 
+      {
+       i<< "  - Loaded from dynamic library"<<std::endl;
+      }
+    return i.str();
+  }
+  //==========================================================================
+
+
+  //==========================================================================
+  size_t  Package::GetObjectSize() const 
+  {
+    size_t s = Superclass::GetObjectSize();
+    s += Package::GetObjectInternalSize();
+    return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  Package::GetObjectInternalSize() const 
+  {
+    size_t s = sizeof(Package);
+    return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  Package::GetObjectRecursiveSize() const 
+  {
+    size_t s = Superclass::GetObjectRecursiveSize();
+    s += Package::GetObjectInternalSize();
+    
+    BlackBoxMapType::const_iterator i;
+    for (i = mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i )
+      {
+       s += i->second->GetObjectRecursiveSize();
+      }
+    return s;
+  }
+  //==========================================================================
+  
+  //==========================================================================
+  std::set<Package::WeakPointer> 
+  Package::mReleasedDynamicallyLoadedPackages;
+  //==========================================================================
 }
 
index 4c0b70534cf890d37f22f4f0a43c7b73bcfc3372..089dbee65498918ab3c7c829d20a754d994c6b84 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkPackage.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/09 11:16:57 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See doc/license.txt or
 #define __bbtkPackage_h__
 
 #include "bbtkBlackBox.h"
+#include "bbtkDynamicLibraryHandling.h"
 
 namespace bbtk
 {
 
-  class BBTK_EXPORT Package
+  class Factory;
+  BBTK_FORWARD_DECLARE_POINTER(Factory);
+
+  class BBTK_EXPORT Package : public Object
   {
+    BBTK_OBJECT_INTERFACE(Package);
+    typedef Object Superclass;
   public:
-    Package(const std::string& name,
-           const std::string& author,
-           const std::string& description,
-           const std::string& version,
-           const std::string& BBTKVersion);
-    ~Package();
+    /// Creates a new package
+    static Pointer New(const std::string& name,
+                      const std::string& author,
+                      const std::string& description,
+                      const std::string& version,
+                      const std::string& BBTKVersion);
+    /// Creates a package from a dynamic library
+    static Pointer CreateFromDynamicLibrary(const std::string& libname,
+                                           const std::string& pkgname,
+                                           const std::string& path);
+
+    /// UnLoads the package dynamic library 
+    /// (if any and if the package is released)
+    /// If doit == false then does not do it but just 
+    /// put the package in the list of ReleasedDynamicallyLoadedPackages.
+    /// This is because we cannot close the dl from inside a 
+    /// package member method or the program crashes.
+    /// The actual dl close must be done by an external user 
+    /// calling UnLoadReleasedDynamicallyLoadedPackages
+    static void UnLoadDynamicLibrary(Package::WeakPointer p, bool doit = true);
+
+    /// UnLoads released packages that were loaded dynamically
+    /// see UnLoadDynamicLibrary and ReleaseBlackBoxDescriptor
+    static void UnLoadReleasedDynamicallyLoadedPackages();
+
+    /// "Releases" the package
+    /// Signals the package that it can free its descriptors 
+    /// if they are no more used and frees and unloads the package 
+    /// 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);
+    /// "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 
+    /// ReleasedDynamicallyLoadedPackages if it is dyn loaded 
+    /// and no more used (released)
+    /// Note : Any non-weak pointer on the package must have been freed
+    static void ReleaseBlackBoxDescriptor(Package::WeakPointer p,
+                                         BlackBoxDescriptor::WeakPointer d);
+    
+    
+    typedef Package::Pointer (*DLGetPackageFunction)();
+    typedef void (*DLDeletePackageFunction)();
+    typedef const std::string& (*DLGetPackageBBTKVersionFunction)();
+
+    /// Opens a dynamic library which contains a bbtk package
+    /// Returns the handler 
+    /// Load the package management symbols from the lib
+    /// returns false if a problem occured hence can be used 
+    /// to test that a dyn lib is a valid bbtk package lib
+    /// NB : The BBTK version exported from the library 
+    ///      is tested against the current bbtk version
+    static DynamicLibraryHandler OpenDynamicLibrary
+    ( const std::string& dynamic_library_path,
+      const std::string& package_name,
+      DLGetPackageFunction&,
+      DLDeletePackageFunction&);
+
     /// Returns the name of the package
     const std::string& GetName() const { return mName; }
 
@@ -56,20 +115,17 @@ namespace bbtk
     /// Returns the version of the package
     const std::string& GetVersion() const { return mVersion; }
 
-    /// Returns the version of bbtk used to build the package
-    const std::string& GetBBTKVersion() const { return mBBTKVersion; }
-
     bool ContainsBlackBox(const std::string& boxname) const;
 
  
-    BlackBox* NewBlackBox(const std::string& type,
+    BlackBox::Pointer NewBlackBox(const std::string& type,
                             const std::string& name) const;
   
-    BlackBox* NewAdaptor(const DataInfo& typein,
+    BlackBox::Pointer NewAdaptor(const DataInfo& typein,
                         const DataInfo& typeout,
                         const std::string& name) const;
     
-   BlackBox* NewWidgetAdaptor(const DataInfo& typein,
+    BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein,
                              const DataInfo& typeout,
                              const std::string& name) const;
     bool FindAdaptor(const DataInfo& typein,
@@ -79,10 +135,7 @@ namespace bbtk
                           const DataInfo& typeout,
                           std::string& adaptor) const;
 
-    bool RegisterBlackBox(BlackBoxDescriptor*); 
-    void UnRegisterBlackBox(const std::string& name); 
-
-    //   bool RegisterAdaptor(BlackBoxDescriptor*); 
+    bool RegisterBlackBox(BlackBoxDescriptor::Pointer); 
 
     void PrintBlackBoxes(bool description = false, 
                         bool adaptors = false) const;
@@ -111,7 +164,8 @@ namespace bbtk
     void ChangeBlackBoxName( const std::string& oldname, 
                             const std::string& newname );
     /// The type of map of descriptors
-    typedef std::map< std::string, BlackBoxDescriptor*> BlackBoxMapType;
+    typedef std::map< std::string, BlackBoxDescriptor::Pointer> 
+    BlackBoxMapType;
     const BlackBoxMapType& GetBlackBoxMap() const { return mBlackBoxMap; }
     BlackBoxMapType& GetBlackBoxMap() { return mBlackBoxMap; }
 
@@ -144,26 +198,47 @@ namespace bbtk
     };
     
     /// The type of map of adaptor descriptors
-    typedef std::map< AdaptorKey, BlackBoxDescriptor*> AdaptorMapType;
+    typedef std::map< AdaptorKey, BlackBoxDescriptor::WeakPointer> AdaptorMapType;
 
  
    const AdaptorMapType& GetAdaptorMap() const { return mAdaptorMap; }
 
-
+    
     // Factories management
     /// Adds the factory to the set of factories which use the package
-    void AddFactory(Factory* f) { mFactorySet.insert(f); }
+    void AddFactory(FactoryPointer f) { mFactorySet.insert(f); }
     /// Removes the factory from the set of factories which use the package
-    void RemoveFactory(Factory* f) { mFactorySet.erase(f); }
+    void RemoveFactory(FactoryPointer f) { mFactorySet.erase(f); }
 
+    
+    typedef std::set<FactoryWeakPointer> FactorySet;
     /// Gets the set of factories which use the package
-    std::set<Factory*>& GetFactorySet() { return mFactorySet; }
+    FactorySet& GetFactorySet() { return mFactorySet; }
     /// Gets the set of factories which use the package (const)
-    const std::set<Factory*>& GetFactorySet() const { return mFactorySet; }
+    const FactorySet& GetFactorySet() const { return mFactorySet; }
     
     void CheckBoxes() const;
 
   private:
+    /// Default ctor is private : use the static New method
+    //    Package() {}
+    /// A Package cannot be copy constructed
+    //    Package(const Package&) {}
+    /// Ctor is private : use the static New method
+    Package(const std::string& name,
+           const std::string& author,
+           const std::string& description,
+           const std::string& version,
+           const std::string& BBTKVersion);
+    /// Does unload a package (no test)
+    static void UnLoad(Package::WeakPointer p);
+
+    /// The dynamic library handler of the package if it was loaded from a dl
+    DynamicLibraryHandler mDynamicLibraryHandler;
+    /// The pointer on the delete function of the package 
+    /// in case it was loaded from a dynamic library
+    DLDeletePackageFunction mDLDeletePackageFunction;
+
 
     /// The name of the package
     std::string mName;
@@ -175,8 +250,6 @@ namespace bbtk
     std::string mDescription;
     /// The version of the package
     std::string mVersion;
-    /// The version of the library bbtk used to build the package
-    std::string mBBTKVersion;
     /// URL of the documentation of the Package (absolute path)
     std::string mDocURL;
     /// URL of the documentation of the Package 
@@ -186,18 +259,18 @@ namespace bbtk
     /// The map of black boxes descriptors
     BlackBoxMapType mBlackBoxMap;
 
-
-  public:
-
-
-  private:
     /// The map of adaptors descriptors
     AdaptorMapType mAdaptorMap;
 
 
     /// The set of factories which contain the package 
-    std::set<Factory*> mFactorySet;
-    
+    FactorySet mFactorySet;
+
+    /// The set of released dynamically loaded packages 
+    /// to be unloaded explicitely calling 
+    /// UnLoadReleasedDynamicallyLoadedPackages
+    static std::set<Package::WeakPointer> 
+    mReleasedDynamicallyLoadedPackages;
   };
   // EO class Package
   //====================================================================
@@ -211,13 +284,23 @@ namespace bbtk
 #endif // defined(_WIN32) 
 //====================================================================
 
+#define BBTK_GET_PACKAGE_FUNCTION_NAME GetPackage
+#define BBTK_DEL_PACKAGE_FUNCTION_NAME DeletePackage
+#define BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME GetPackageBBTKVersion
+  
+
+
 //====================================================================
 #define BBTK_DECLARE_PACKAGE(NAME)                                     \
   extern "C"                                                           \
   {                                                                    \
-    bbtk::Package*& NAME ## GetPackagePointer();                       \
-    BBTK_PACKAGE_EXPORT void BBTK_CDECL NAME ## DeletePackage();       \
-    BBTK_PACKAGE_EXPORT bbtk::Package* BBTK_CDECL NAME ## GetPackage();        \
+    bbtk::Package::Pointer& NAME ## GetPackagePointer();               \
+    BBTK_PACKAGE_EXPORT                                                        \
+    void BBTK_CDECL NAME ## DeletePackage ();          \
+    BBTK_PACKAGE_EXPORT        bbtk::Package::Pointer                          \
+    BBTK_CDECL NAME ## GetPackage ();          \
+    BBTK_PACKAGE_EXPORT const std::string&                             \
+    BBTK_CDECL NAME ## GetPackageBBTKVersion ();       \
   }
 //==================================================================== 
 
@@ -225,64 +308,54 @@ namespace bbtk
 #define BBTK_IMPLEMENT_PACKAGE(NAME,AUTHOR,DESCRIPTION,VERSION)                \
   extern "C"                                                           \
   {                                                                    \
-    bbtk::Package*& NAME ## GetPackagePointer()                                \
+    bbtk::Package::Pointer& NAME ## GetPackagePointer()                        \
     {                                                                  \
-      static bbtk::Package* u = 0;                                     \
+      static bbtk::Package::Pointer u;                                 \
       return u;                                                                \
     }                                                                  \
-    BBTK_PACKAGE_EXPORT void BBTK_CDECL NAME ## DeletePackage()                \
+    BBTK_PACKAGE_EXPORT                                                        \
+    void BBTK_CDECL NAME ## DeletePackage ()                           \
     {                                                                  \
-      if (NAME ## GetPackagePointer())                                 \
-       delete NAME ## GetPackagePointer();                             \
-      NAME ## GetPackagePointer() = 0;                                 \
+      NAME ## GetPackagePointer().reset();                             \
     }                                                                  \
-    BBTK_PACKAGE_EXPORT bbtk::Package* BBTK_CDECL NAME ## GetPackage() \
+    BBTK_PACKAGE_EXPORT                                                        \
+    bbtk::Package::Pointer                                             \
+    BBTK_CDECL NAME ## GetPackage()            \
     {                                                                  \
       if (!NAME ## GetPackagePointer())                                        \
        NAME ## GetPackagePointer() =                                   \
-         new bbtk::Package(#NAME,                                      \
-                           AUTHOR,     \
-                           DESCRIPTION, \
-                           VERSION,    \
-                           BBTK_STRINGIFY_SYMBOL(BBTK_VERSION)         \
-                           );                                          \
+         bbtk::Package::New(#NAME,                                     \
+                            AUTHOR,                                    \
+                            DESCRIPTION,                               \
+                            VERSION,                                   \
+                            BBTK_STRINGIFY_SYMBOL(BBTK_VERSION)        \
+                            );                                         \
       return NAME ## GetPackagePointer();                              \
     }                                                                  \
+    BBTK_PACKAGE_EXPORT const std::string&                             \
+    BBTK_CDECL NAME ## GetPackageBBTKVersion ()        \
+    { return bbtk::GetVersion(); }                                     \
   }
 //====================================================================  
 
 //====================================================================
 #define BBTK_ADD_BLACK_BOX_TO_PACKAGE(NAME,CLASS)                      \
-  bool bbDummy##NAME##CLASS = NAME ## GetPackage()->RegisterBlackBox(CLASS::bbDescriptor());
+  bool bbDummy##NAME##CLASS = NAME ## GetPackage ()    \
+    ->RegisterBlackBox(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<TEMPLATE_PARAM>::bbDescriptor());
+  bool bbDummy##NAME##CLASS##TEMPLATE_PARAM = NAME ## GetPackage ()    \
+    ->RegisterBlackBox(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<T1,T2>::bbDescriptor()); 
+  bool bbDummy##NAME##CLASS##T1##T2 = NAME ## GetPackage ()            \
+    ->RegisterBlackBox(CLASS ## Descriptor <T1,T2>::Instance()); 
   //====================================================================
   
-//====================================================================
-//#define BBTK_ADD_ADAPTOR_TO_PACKAGE(NAME,CLASS)                      \
-//  bool bbDummy##NAME##CLASS = NAME ## GetPackage()->RegisterBlackBox(CLASS::bbDescriptor()); \
-//  bool bbDummyAdaptor##NAME##CLASS = NAME ## GetPackage()->RegisterAdaptor(CLASS::bbDescriptor());
-//====================================================================
-
-//====================================================================
-//#define BBTK_ADD_TEMPLATE_ADAPTOR_TO_PACKAGE(NAME,CLASS,TEMPLATE_PARAM) \
-//  bool bbDummy##NAME##CLASS##TEMPLATE_PARAM = NAME ## GetPackage()->RegisterBlackBox(CLASS<TEMPLATE_PARAM>::bbDescriptor()); \
-//  bool bbDummyAdaptor##NAME##CLASS##TEMPLATE_PARAM = NAME ## GetPackage()->RegisterAdaptor(CLASS<TEMPLATE_PARAM>::bbDescriptor());
-//====================================================================
-
-//====================================================================
-//#define BBTK_ADD_TEMPLATE2_ADAPTOR_TO_PACKAGE(NAME,CLASS,T1,T2)      \
-//  bool bbDummy##NAME##CLASS##T1##T2 = NAME ## GetPackage()->RegisterBlackBox(CLASS<T1,T2>::bbDescriptor()); \
-//    bool bbDummyAdaptor##NAME##CLASS##T1##T2 = NAME ## GetPackage()->RegisterAdaptor(CLASS<T1,T2>::bbDescriptor());
-  //====================================================================
 
 }// namespace bbtk
 
index cc666b79245efd6cbfc18f81cb4e7918e5718632..41ca87d216d812a09825009c9dfd613fce2e5224 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkTranscriptor.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 namespace bbtk
 {
+  Transcriptor::Pointer Transcriptor::New(const std::string& filename)
+  {
+    return MakePointer(new Transcriptor(filename));
+  }
+
 /**
  *
  */
-  Transcriptor::Transcriptor(std::string filename)
+  Transcriptor::Transcriptor(const std::string& filename)
     :
       mNoExecMode(false),
       mDialogMode(NoDialog)
@@ -314,6 +319,44 @@ void Transcriptor::ShowRelations(const std::string &nameblackbox, const std::str
     m_Fp << "  e->UnLoadPackage(\"" <<name<<"\");"<<std::endl;
   }
 
+ //==========================================================================
+  std::string Transcriptor::GetObjectName() const
+  {
+    return std::string("Transcriptor");
+  }
+  //==========================================================================
+  
+  //==========================================================================
+  std::string  Transcriptor::GetObjectInfo() const 
+  {
+    std::stringstream i;
+    return i.str();
+  }
+  //==========================================================================
+
+ //==========================================================================
+size_t  Transcriptor::GetObjectSize() const 
+{
+  size_t s = Superclass::GetObjectSize();
+  s += Transcriptor::GetObjectInternalSize();
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+size_t  Transcriptor::GetObjectInternalSize() const 
+{
+  size_t s = sizeof(Transcriptor);
+  return s;
+  }
+  //==========================================================================
+  //==========================================================================
+  size_t  Transcriptor::GetObjectRecursiveSize() const 
+  {
+    size_t s = Superclass::GetObjectRecursiveSize();
+    s += Transcriptor::GetObjectInternalSize();
+    return s;
+  }
+  //==========================================================================
 
 
 }//namespace
index c95bdbffa4c1f5deb82de9472a1f11a8686c573b..35d02e05e20b938ddce7b940d00bf7478af2d68d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkTranscriptor.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.10 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -37,14 +37,11 @@ namespace bbtk
 
   class /*BBTK_EXPORT*/ Transcriptor : public VirtualExec
   {
-
+    BBTK_OBJECT_INTERFACE(Transcriptor);
+    typedef VirtualExec Superclass;
   public:
+    static Pointer New(const std::string& filename);
 
-    /// Constructor
-    Transcriptor(std::string filename);
-
-    /// Destructor
-    ~Transcriptor( );
    
     /// Sets the inputs of the workspace : 
     void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
@@ -178,6 +175,8 @@ namespace bbtk
   protected:
 
   private:
+    /// Constructor
+    Transcriptor(const std::string& filename);
 
     /// The input values of the Root ComplexBlackBox
     std::map<std::string,std::string> mInputs;
diff --git a/kernel/src/bbtkVirtualExec.cxx b/kernel/src/bbtkVirtualExec.cxx
new file mode 100644 (file)
index 0000000..9b83dfc
--- /dev/null
@@ -0,0 +1,22 @@
+#include "bbtkVirtualExec.h"
+#include "bbtkInterpreter.h"
+
+namespace bbtk
+{
+  VirtualExec::VirtualExec() 
+    : mInterpreter() 
+  {
+  }
+  
+  VirtualExec::~VirtualExec() 
+  {
+  }
+
+  Interpreter::Pointer VirtualExec::GetInterpreter() 
+  { 
+    return mInterpreter.lock(); 
+  }
+
+
+}
+
index e736f9e8c7a8cf40c29f6b6f411f3054046b9b6d..cc2d81b547a170aad6b09fa1fd4d66f683d2e0da 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkVirtualExec.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.12 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #define __bbtkVirtualExec_h__
 
 #include "bbtkSystem.h"
-//#include "bbtkComplexBlackBox.h"
+#include "bbtkComplexBlackBoxDescriptor.h"
 #include "bbtkFactory.h"
-//#include <string>
-//#include <deque>
 
 namespace bbtk
 {
 
   class Interpreter;
+  BBTK_FORWARD_DECLARE_POINTER(Interpreter);
 
-  class /*BBTK_EXPORT*/ VirtualExec   // All methods are pure virtual
+  class /*BBTK_EXPORT*/ VirtualExec : public Object
   {
-
+    BBTK_ABSTRACT_OBJECT_INTERFACE(VirtualExec);
   public:
     typedef enum
     {
@@ -50,21 +49,18 @@ namespace bbtk
     }
     DialogModeType;
 
-    VirtualExec() : mInterpreter(0) {}
-
-    virtual ~VirtualExec() {}
 
     /// Sets the interpreter who uses it 
-    void SetInterpreter(Interpreter* i) { mInterpreter = i; }
+    void SetInterpreter(InterpreterPointer i) { mInterpreter = i; }
     /// Gets the interpreter who uses it 
-    Interpreter* GetInterpreter() { return mInterpreter; }
+    InterpreterPointer GetInterpreter(); // { return mInterpreter.lock(); }
     /// Gets the interpreter who uses it (const)
-    const Interpreter* GetInterpreter() const { return mInterpreter; }
+    //    const Interpreter::Pointer GetInterpreter() const { return mInterpreter; }
 
     /// Gets the factory used by the executer
-    virtual Factory* GetFactory() { return 0; }
+    virtual Factory::Pointer GetFactory() { return Factory::Pointer(); }
     /// Gets the factory used by the executer (const)
-    virtual const Factory* GetFactory() const { return 0; }
+    // virtual const Factory* GetFactory() const { return 0; }
     
     /// Sets the inputs of the workspace : 
     virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
@@ -185,7 +181,9 @@ namespace bbtk
     /// Prints the string ... MORE : TO EXPLAIN 
     virtual void Print(const std::string & message) = 0;
 
-    
+    ComplexBlackBoxDescriptor::Pointer GetWorkspace() 
+    { return  ComplexBlackBoxDescriptor::Pointer(); }
+  
   //  static const std::string& GetObjectDescription() = 0;
   //  { static std::string s("VirtualExec"); return s; }
   protected:
@@ -193,57 +191,8 @@ namespace bbtk
   private:
 
    /// The interpreter which uses it (0 if none)
-    Interpreter* mInterpreter;
-    /*
-    /// Gets the current working black box 
-    virtual ComplexBlackBoxDescriptor* Current() = 0;
-    
-    /// Returns true when we are inside a define/endefine block
-    //    virtual bool InDefinitionBlock() = 0;
-
-    //==================================================================
-    // ATTRIBUTES
-     
-    /// The factory used
-    //   Factory* mFactory;
-
-    /// The Root Package
-    Package* mPackage;
-    
-    /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
-    /// Its name in bbi is 'workspace'  
-    ComplexBlackBoxDescriptor* mRoot;
-
-    /// Struct that stores info on user defined complex black boxes
-    struct CBBDefinition
-    {
-      ComplexBlackBoxDescriptor* box;
-      std::string package;
-      CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
-        : box(d), package(p) {}
-    };
-
-    /// The stack of current working ComplexBlackBox
-    /// (is a stack for nested definitions)
-    /// only contains the root when outside a define/endefine block
-    std::deque<CBBDefinition> mOpenDefinition;
-
-   /// The stack of current working package
-    /// (is a stack for nested definitions)
-    std::deque<Package*> mOpenPackage;
-
-    /// flag which is true when we are inside a Define/EndDefine block
-    //    bool mDefineFlag;
-    
-    /// The input values of the Root ComplexBlackBox
-    std::map<std::string,std::string> mInputs;
-    
-    /// no exec mode flag
-    bool mNoExecMode;
+    InterpreterWeakPointer mInterpreter;
 
-    /// Dialog mode
-    DialogModeType mDialogMode;
-    */
   };
 }
 #endif
index 6a452f3c3350dfb3d60fb03dd035511b26581677..2413e4a55aba8e69c9e067adafb05c2db8b156db 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.12 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -48,7 +48,7 @@ namespace bbtk
 
 
   //=========================================================================
-  WxBlackBoxWindow::WxBlackBoxWindow(WxBlackBox* box)
+  WxBlackBoxWindow::WxBlackBoxWindow(WxBlackBox::Pointer box)
     : mBox(box), mShown(false)
   {
     bbtkDebugMessage("Wx",9,"WxBlackBoxWindow::WxBlackBoxWindow("<<
@@ -109,7 +109,7 @@ namespace bbtk
   //=========================================================================
 
   //=========================================================================
-  WxBlackBoxDialog::WxBlackBoxDialog(WxBlackBox* box,
+  WxBlackBoxDialog::WxBlackBoxDialog(WxBlackBox::Pointer box,
                                     wxWindow *parent,
                                     wxString title,
                                     wxSize size)
@@ -177,7 +177,7 @@ namespace bbtk
   //=========================================================================
 
   //=========================================================================
-  WxBlackBoxFrame::WxBlackBoxFrame(WxBlackBox* box,
+  WxBlackBoxFrame::WxBlackBoxFrame(WxBlackBox::Pointer box,
                                   wxWindow *parent,
                                   wxString title,
                                   wxSize size)
@@ -324,8 +324,9 @@ namespace bbtk
   //=========================================================================
 
   //=========================================================================
-  WxBlackBoxWidgetEventHandler::WxBlackBoxWidgetEventHandler( WxBlackBox* box, 
-                                                             wxWindow *widget )
+  WxBlackBoxWidgetEventHandler::
+  WxBlackBoxWidgetEventHandler( WxBlackBox::Pointer box, 
+                               wxWindow *widget )
     :
     mBox(box),
     mWindow(widget)
@@ -422,7 +423,7 @@ namespace bbtk
   //=========================================================================
   //=========================================================================
   //=========================================================================
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(WxBlackBox,AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(WxBlackBox,AtomicBlackBox);
   //=========================================================================
   
   //=========================================================================
@@ -513,7 +514,7 @@ namespace bbtk
                         "-> Output 'Widget' connected : transfering execution to parent"
                         <<std::endl);
        
-       i->second->GetConnectionVector().front()
+       i->second->GetConnectionVector().front().lock()
          ->GetBlackBoxTo()->bbExecute(force);
 
       }
@@ -533,7 +534,7 @@ namespace bbtk
 
   //=========================================================================
   /// Main processing method of the box.
-  IOStatus WxBlackBox::bbBackwardUpdate( Connection* caller )
+  IOStatus WxBlackBox::bbBackwardUpdate( Connection::Pointer caller )
   {
     bbtkDebugMessageInc("Process",1,
                        "=> WxBlackBox::bbBackwardUpdate("
@@ -564,7 +565,7 @@ namespace bbtk
                             "-> Output 'Widget' connected : transfering execution to parent"
                             <<std::endl);
            
-           i->second->GetConnectionVector().front()
+           i->second->GetConnectionVector().front().lock()
              ->GetBlackBoxTo()->bbExecute(false);
            done = true;
          }
@@ -609,7 +610,8 @@ namespace bbtk
            bbtkDebugMessage("Process",3,
                             "-> No widget event handler : creating one"
                             <<std::endl);
-           new WxBlackBoxWidgetEventHandler(this,bbGetOutputWidget());
+           new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
+                                            bbGetOutputWidget());
          }
        else if ( ! bbGetWidgetEventHandler()->IsHandlerOf 
                  ( bbGetOutputWidget() ) )
@@ -618,7 +620,8 @@ namespace bbtk
                             "-> Obsolete widget event handler : re-creating one"
                             <<std::endl);
            delete bbGetWidgetEventHandler();
-           new WxBlackBoxWidgetEventHandler(this,bbGetOutputWidget());
+           new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
+                                            bbGetOutputWidget());
          }
        // Sets the name of the wxWindow to the input WinTitle
        bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle()));
@@ -661,7 +664,7 @@ namespace bbtk
            bbtkDebugMessage("Process",2,
                             "   Input WinDialog set to true : creating a Dialog"
                             <<std::endl);
-           show = (Window*) new WxBlackBoxDialog( this,
+           show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
                                                   bbGetWxParent(), 
                                                   std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
                                                   wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
@@ -672,7 +675,7 @@ namespace bbtk
            bbtkDebugMessage("Process",2,
                             "   Input WinDialog set to false : creating a Frame"
                             <<std::endl);
-           show = (Window*) new WxBlackBoxFrame( this,
+           show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
                                                  bbGetWxParent(), 
                                                  std2wx( bbGetInputWinTitle()  + " - bbtk (c) CREATIS LRMN"),
                                                  wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
@@ -730,8 +733,9 @@ namespace bbtk
       = bbGetOutputConnectorMap().find("Widget");
     if ( i->second->GetConnectionVector().size() != 0 ) 
       {
-       return ((WxBlackBox*)i->second->GetConnectionVector().front()
-               ->GetBlackBoxTo())->bbGetContainingWindow();
+       return boost::static_pointer_cast<WxBlackBox>
+         (i->second->GetConnectionVector().front().lock()->GetBlackBoxTo())
+         ->bbGetContainingWindow();
       }
     return 0;
   }
index d259a874be3b584c15bbea4c7a5dd3f5f34ee57f..92d711d3bc488bbbee1ae3a4ca3629a9d2237394 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -61,8 +61,8 @@ namespace bbtk
   //==================================================================
   /// Widget black boxes
   class BBTK_EXPORT WxBlackBox : public bbtk::AtomicBlackBox  
-  {
-    BBTK_USER_BLACK_BOX_INTERFACE(WxBlackBox,bbtk::AtomicBlackBox);
+  { 
+    BBTK_BLACK_BOX_INTERFACE(WxBlackBox,bbtk::AtomicBlackBox);
     //   BBTK_DECLARE_INPUT(WinParent,WxParentToChildData*);
     BBTK_DECLARE_INPUT(WinTitle,std::string);
     BBTK_DECLARE_INPUT(WinWidth,int);
@@ -131,7 +131,7 @@ namespace bbtk
 
     //==================================================================
     /// Main processing method of the box.
-    virtual IOStatus bbBackwardUpdate( Connection* caller );
+    virtual IOStatus bbBackwardUpdate( Connection::Pointer caller );
     //==================================================================
 
 
@@ -237,16 +237,16 @@ namespace bbtk
   class BBTK_EXPORT WxBlackBoxWindow //: public wxWindow
   {
   public:
-    WxBlackBoxWindow(WxBlackBox* box);
+    WxBlackBoxWindow(WxBlackBox::Pointer box);
     virtual ~WxBlackBoxWindow();
     virtual void bbShow();
     virtual void bbHide();
     bool bbIsShown() { return mShown; }
-    virtual WxBlackBox* bbGetBlackBox() { return mBox; }
+    virtual WxBlackBox::Pointer bbGetBlackBox() { return mBox; }
     virtual wxDialog* bbGetDialog() { return 0; } 
     virtual wxFrame* bbGetFrame() { return 0; } 
   private:
-    WxBlackBox* mBox;
+    WxBlackBox::Pointer mBox;
     bool mShown;
   };
   //==================================================================
@@ -256,7 +256,7 @@ namespace bbtk
   class BBTK_EXPORT  WxBlackBoxDialog : public wxDialog, public WxBlackBoxWindow
   {
   public:
-    WxBlackBoxDialog(WxBlackBox* box, 
+    WxBlackBoxDialog(WxBlackBox::Pointer box, 
                     wxWindow *parent, wxString title, wxSize size);
     ~WxBlackBoxDialog();
     void bbShow();  
@@ -270,7 +270,7 @@ namespace bbtk
   class BBTK_EXPORT  WxBlackBoxFrame : public wxFrame, public WxBlackBoxWindow
   {
   public:
-    WxBlackBoxFrame(WxBlackBox* box,
+    WxBlackBoxFrame(WxBlackBox::Pointer box,
                    wxWindow *parent, wxString title, wxSize size);
     ~WxBlackBoxFrame();
     void bbShow();
@@ -280,33 +280,6 @@ namespace bbtk
   //==================================================================
 
 
-  /*
- //=================================================================
-  /// Class from which a user defined widget associated to a WxBlackBox 
-  /// should inherit
-  class BBTK_EXPORT  WxBlackBoxWidget
-  {
-  public:
-    /// Ctor with the WxBlackBox which created it 
-    WxBlackBoxWidget( WxBlackBox* box);
-    /// Dtor
-    virtual ~WxBlackBoxWidget();
-
-    /// Returns the WxBlackBox which created it
-    WxBlackBox* GetBlackBox() { return mBox; }
-    /// Returns the WxBlackBox which created it (const)
-    const WxBlackBox* GetBlackBox() const { return mBox; }
-
-    /// Returns the wxWindow associated to the widget
-    virtual wxWindow* GetWxWindow() { return 0; }
-
-    virtual bool IsDead() { return false; }
-
-  private:
-    WxBlackBox* mBox;
-  };  
-  //=================================================================
-  */
 
   //=================================================================
   // Handles the destroy events of a widget associated to a WxBlackBox 
@@ -315,7 +288,7 @@ namespace bbtk
   {
   public:
     /// Ctor with the box and widget 
-    WxBlackBoxWidgetEventHandler( WxBlackBox* box, wxWindow *widget );
+    WxBlackBoxWidgetEventHandler( WxBlackBox::Pointer box, wxWindow *widget );
     /// Dtor
     ~WxBlackBoxWidgetEventHandler();
     /// Returns true iff is the handler for that window  
@@ -327,37 +300,12 @@ namespace bbtk
     //bool IsDead() { return mDead; }
 
   private:
-    WxBlackBox* mBox;
+    WxBlackBox::Pointer mBox;
     wxWindow* mWindow;
     //bool mDead;
   };  
   //=================================================================
 
-  /*
-  //=================================================================
-  /// A WxBlackBoxWidget which is a wxPanel also
-  class BBTK_EXPORT  WxBlackBoxWidgetPanel :     
-                               public wxPanel,
-                               public WxBlackBoxWidget
-//                             public WxBlackBoxWidget,
-//                             public wxPanel
-  {
-  public:
-    /// Ctor with the parent and the WxBlackBox which created it 
-    WxBlackBoxWidgetPanel(WxBlackBox* box,  wxWindow *parent)
-      :
-      wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
-      WxBlackBoxWidget(box)
-    {}
-    
-    /// Returns the top panel of the widget    
-    wxWindow* GetWxWindow() { return (wxWindow*)(wxPanel*)(this); }
-    /// Returns the top panel of the widget    
-    wxPanel* GetPanel() { return (wxPanel*)(this); }
-
-  };  
-  //=================================================================
-  */
 
 
 } //namespace bbtk
index c823932332bac37446c58a886aea5c846492cc98..a4d4299144b6067fbe87626fe27f4bcb86bfc276 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIConsole.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/25 06:22:53 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -64,7 +64,7 @@ namespace bbtk
 //    m_mgr = new wxAuiManager(this);
        m_mgr.SetManagedWindow(this);
    
-    mInterpreter = new bbtk::Interpreter();
+       mInterpreter = bbtk::Interpreter::New();
     mInterpreter->SetUser(this);
     mInterpreter->SetCommandLine(true);
     //==============
@@ -214,7 +214,7 @@ namespace bbtk
     std::string filename = mWxGUIHtmlBrowser->GetCurrentPage();//wx2std(temp);
     size_t s = filename.length();
 
-    Interpreter* I = new Interpreter;
+    Interpreter::Pointer I = Interpreter::New();
     
     if ((s>3) && (filename[s-1]=='s')
        && (filename[s-2]=='b')
@@ -230,8 +230,7 @@ namespace bbtk
       {
        SetStatusText(_T("The current page is not a bbs file : cannot execute it"));
       }
-    
-    delete I;
+
   }
   //================================================================  
 
@@ -278,9 +277,8 @@ namespace bbtk
     std::string command("toolsbbtk/appli/CreatePackage");
 
     bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
-    Interpreter* I = new Interpreter;    
+    Interpreter::Pointer I = Interpreter::New();    
     I->InterpretFile(command);
-    delete I;
   }
   //================================================================
 
@@ -290,9 +288,8 @@ namespace bbtk
   {
     std::string command("toolsbbtk/appli/CreateBlackBox");
     bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
-    Interpreter* I = new Interpreter;    
+    Interpreter::Pointer I = Interpreter::New();    
     I->InterpretFile(command);
-    delete I;
   }
   //================================================================
   
index a8c328d9ef8c277966699b14f2c53ca385777f6f..6a4b17d007b2a68c649d247267659c7d77408377 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIConsole.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/25 06:22:53 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -63,9 +63,9 @@ namespace bbtk
     /// Returns the Interpreter used 
     /// ONLY ONE FOR THE MOMENT BUT IN THE FUTURE CAN BE DIFFERENT 
     /// (DIFFERENT WORKSPACES)
-    Interpreter* GetInterpreter() { return mInterpreter; }
+    //Interpreter::Pointer GetInterpreter() { return mInterpreter; }
     /// Returns the Interpreter used (const)
-    const Interpreter* GetInterpreter() const { return mInterpreter; }
+    Interpreter::Pointer GetInterpreter() const { return mInterpreter; }
 
     /// Sets the inputs of the workspace : 
     /// the map is passed as is to the Executer
@@ -104,7 +104,7 @@ namespace bbtk
 
   private:
     wxAuiManager m_mgr;
-    Interpreter* mInterpreter;
+    Interpreter::Pointer mInterpreter;
 
     
 //EED    wxNotebook* mwxNotebook;
index 515a707cdb1fd4f0156ab5d587b2ca597ee7ffab..4f7a84dd6359633668994851dce06f9a858b1a36 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIPackageBrowser.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/31 13:18:04 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 namespace bbtk
 {
   //================================================================
-  WxGUIPackageBrowserBlackBox::WxGUIPackageBrowserBlackBox(wxWindow* parent,
-                                                          WxGUIPackageBrowser* browser,
-                                                          BlackBoxDescriptor* descr) :
+  WxGUIPackageBrowserBlackBox::
+  WxGUIPackageBrowserBlackBox(wxWindow* parent,
+                             WxGUIPackageBrowser* browser,
+                             BlackBoxDescriptor::Pointer descr) :
     wxPanel(parent, -1),
     mBrowser(browser),
     mDescriptor(descr)
@@ -303,7 +304,7 @@ namespace bbtk
                                    WxGUIPackageBrowserUser* user )
     : wxPanel(parent, -1),
       mUser(user),
-      mInterpreter(0)
+      mInterpreter()
   {
 
     wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
@@ -339,26 +340,26 @@ namespace bbtk
   //================================================================
   WxGUIPackageBrowser::~WxGUIPackageBrowser()
   {
-    std::cout << "del interpreter" << std::endl;
-    if (mInterpreter) delete mInterpreter;
-    std::cout << "ok" << std::endl;
+    // std::cout << "del interpreter" << std::endl;
+    //   if (mInterpreter) delete mInterpreter;
+    //    std::cout << "ok" << std::endl;
   }
   //================================================================
 
   //================================================================
   void WxGUIPackageBrowser::IncludeAll()
   {
-    if (!mInterpreter) mInterpreter = new bbtk::Interpreter();
+    if (!mInterpreter) mInterpreter = bbtk::Interpreter::New();
     mInterpreter->SetCommandLine(true);
     mInterpreter->InterpretLine("include *");
 
-    Factory* F = mInterpreter->GetExecuter()->GetFactory();
+    Factory::Pointer F = mInterpreter->GetExecuter()->GetFactory();
     BuildFromFactory(F);
   }
   //================================================================
   //================================================================
   
-  void WxGUIPackageBrowser::BuildFromFactory(Factory* F)
+  void WxGUIPackageBrowser::BuildFromFactory(Factory::Pointer F)
   {
 #ifndef LINUX
     wxTreeMultiWindowInfo wndinfo(wxTMC_BG_ADJUST_CNT, 8, 0);
@@ -370,7 +371,7 @@ namespace bbtk
     Factory::PackageMapType::const_iterator i;
     for (i=M.begin();i!=M.end();++i)
       {
-       Package* P = i->second.mPackage;
+       Package::Pointer P = i->second;
        wxString packname = std2wx(P->GetName());
        if (packname==_T("user")) continue;
        wxTreeMultiItem pack = mTree->AddRoot(packname,packname);
index 3958d4c8903c9e3cbb79175eecd0d881178520fb..35327bf73a6836fba67aca7b4164f9f42917aa1a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIPackageBrowser.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/28 15:04:10 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -68,12 +68,12 @@ namespace bbtk
   public:
     WxGUIPackageBrowserBlackBox(wxWindow* parent,
                                WxGUIPackageBrowser* browser,
-                               BlackBoxDescriptor* descr);
+                               BlackBoxDescriptor::Pointer descr);
     ~WxGUIPackageBrowserBlackBox();
 
   private:
     WxGUIPackageBrowser* mBrowser;
-    BlackBoxDescriptor* mDescriptor;
+    BlackBoxDescriptor::Pointer mDescriptor;
   } ;
   //================================================================
 
@@ -88,11 +88,11 @@ namespace bbtk
     ~WxGUIPackageBrowser();
 
     void IncludeAll();
-    void BuildFromFactory(Factory* f);
+    void BuildFromFactory(Factory::Pointer f);
 
   private:
     WxGUIPackageBrowserUser* mUser;
-    Interpreter* mInterpreter;
+    Interpreter::Pointer mInterpreter;
     wxTreeMultiCtrl* mTree;
 
   };
index d7349e8ec230dddd69a754e0d9669bf9261dff54..d95d80dee445b049038efc327f155694e990439a 100644 (file)
@@ -3,8 +3,8 @@
 Program:   bbtk
 Module:    $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $
 Language:  C++
-Date:      $Date: 2008/04/09 11:16:57 $
-Version:   $Revision: 1.4 $
+Date:      $Date: 2008/04/18 12:59:16 $
+Version:   $Revision: 1.5 $
                                                                                 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
 l'Image). All rights reserved. See Doc/License.txt or
@@ -109,7 +109,7 @@ namespace bbtk
 #endif
   }
   
-  void WxGUIBlackBoxList::Insert(BlackBoxDescriptor* d)
+  void WxGUIBlackBoxList::Insert(BlackBoxDescriptor::Pointer d)
   {
     if (GetColumnCount()!=3)
       {
@@ -127,8 +127,9 @@ namespace bbtk
     int nID = this->GetItemCount();
     kNewItem.SetId(nID);
     kNewItem.SetMask(wxLIST_MASK_DATA);
-    kNewItem.SetData(d);  
-    //    BlackBoxDescriptor* d2 = (BlackBoxDescriptor*)kNewItem.GetData();
+    // TO DO : STORE SHARED POINTER
+    //    kNewItem.SetData(d.get());  
+    //    BlackBoxDescriptor::Pointer* d2 = (BlackBoxDescriptor::Pointer*)kNewItem.GetData();
     //    std::cout << "Descr = "<<d<<" = "<<d2<<std::endl;
     this->InsertItem(kNewItem);
     this->SetItem(nID, 0, std2wx(d->GetPackage()->GetName()) );
@@ -312,8 +313,9 @@ namespace bbtk
     info.m_mask = wxLIST_MASK_DATA;
     if ( GetItem(info) )
       {
-       BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData());
-       if (d!=0) mUser->WxGUIBlackBoxListUserOnSelected(d);
+       // TO DO : STORE SHARED
+       //      BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData());
+       //      if (d!=0) mUser->WxGUIBlackBoxListUserOnSelected(d);
       }
     else
       {
@@ -556,7 +558,7 @@ namespace bbtk
   WxGUIBlackBoxInfo::WxGUIBlackBoxInfo(wxWindow* parent)
     :
     wxPanel(parent, -1),
-    mDescriptor(0)
+    mDescriptor()
   {
     wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
     
@@ -604,7 +606,7 @@ namespace bbtk
 
     
   //================================================================
-  void WxGUIBlackBoxInfo::UpdateInfo(BlackBoxDescriptor* descr)
+  void WxGUIBlackBoxInfo::UpdateInfo(BlackBoxDescriptor::Pointer descr)
   {
 
     //    mName->SetLabel(std2wx(descr->GetTypeName()));
@@ -758,7 +760,7 @@ namespace bbtk
                                              WxGUIPackageBrowser2User* user )
     : wxPanel(parent, -1),
       mUser(user),
-      mInterpreter(0)
+      mInterpreter()
   {
     m_mgr.SetManagedWindow(this);
 
@@ -882,7 +884,7 @@ namespace bbtk
 
   //================================================================
   // User callback when a box is selected in the list 
-  void WxGUIPackageBrowser2::WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* d)
+  void WxGUIPackageBrowser2::WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor::Pointer d)
   {
     mBoxInfo->UpdateInfo(d);
     std::string title = d->GetPackage()->GetName()+"::"+d->GetTypeName();
@@ -895,26 +897,27 @@ namespace bbtk
   //================================================================
   WxGUIPackageBrowser2::~WxGUIPackageBrowser2()
   {
-    std::cout << "del interpreter" << std::endl;
-    if (mInterpreter) delete mInterpreter;
-    std::cout << "ok" << std::endl;
+
+    //    std::cout << "del interpreter" << std::endl;
+    //    if (mInterpreter) delete mInterpreter;
+    //    std::cout << "ok" << std::endl;
   }
   //================================================================
 
   //================================================================
   void WxGUIPackageBrowser2::IncludeAll()
   {
-    if (!mInterpreter) mInterpreter = new bbtk::Interpreter();
+    if (!mInterpreter) mInterpreter =bbtk::Interpreter::New();
     mInterpreter->SetCommandLine(true);
     mInterpreter->InterpretLine("include *");
 
-    Factory* F = mInterpreter->GetExecuter()->GetFactory();
+    Factory::Pointer F = mInterpreter->GetExecuter()->GetFactory();
     BuildFromFactory(F);
   }
   //================================================================
 
   //================================================================
-  void WxGUIPackageBrowser2::BuildFromFactory(Factory* F)
+  void WxGUIPackageBrowser2::BuildFromFactory(Factory::Pointer F)
   {
     mFactory = F;
     RebuildList();
@@ -931,7 +934,7 @@ namespace bbtk
     Factory::PackageMapType::const_iterator i;
     for (i=M.begin();i!=M.end();++i)
       {
-       Package* P = i->second.mPackage;
+       Package::Pointer P = i->second;
        if (P->GetName() == "user") continue;
        
        Package::BlackBoxMapType::iterator j;
@@ -949,7 +952,7 @@ namespace bbtk
   //================================================================
 
   //================================================================
-  bool WxGUIPackageBrowser2::IsVisible(BlackBoxDescriptor* d)
+  bool WxGUIPackageBrowser2::IsVisible(BlackBoxDescriptor::Pointer d)
   {
     //    std::cout << "   '" << wx2std(mPackageFilter->GetValue())<<"'"<<std::endl;
     //    std::cout << "vs '" << d->GetPackage()->GetName() << "'"<<std::endl;
index dd31edfe467085ee98fe8df3f41966fb188d4870..debebbdb1500fbddb62c2bd755e1a8f3f1c4dd92 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/04 09:45:05 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -79,7 +79,7 @@ namespace bbtk
     WxGUIBlackBoxInfo(wxWindow* parent);
     ~WxGUIBlackBoxInfo();
 
-    void UpdateInfo(BlackBoxDescriptor* descr);
+    void UpdateInfo(BlackBoxDescriptor::Pointer descr);
     void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
   private:
     BlackBoxDescriptor* mDescriptor;
@@ -101,7 +101,7 @@ namespace bbtk
     virtual ~WxGUIBlackBoxListUser() {}
     
     // User callback when a box is selected in the list 
-    virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
+    virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor::Pointer ) {}
   };
   //================================================================
 
@@ -119,7 +119,7 @@ namespace bbtk
     void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
 
     // add one item to the listctrl in report mode
-    void Insert(BlackBoxDescriptor* d);
+    void Insert(BlackBoxDescriptor::Pointer d);
     
     // 
     void OnColClick(wxListEvent& event);
@@ -184,20 +184,20 @@ private:
     ~WxGUIPackageBrowser2();
 
     void IncludeAll();
-    void BuildFromFactory(Factory* f);
+    void BuildFromFactory(Factory::Pointer f);
     void RebuildList();
-    bool IsVisible(BlackBoxDescriptor* d);
+    bool IsVisible(BlackBoxDescriptor::Pointer d);
 
     void OnFilter(wxCommandEvent&);
  
     // User callback when a box is selected in the list 
-    void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
+    void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor::Pointer );
 
   private:
     wxAuiManager m_mgr;
     WxGUIPackageBrowser2User* mUser;
-    Interpreter* mInterpreter;
-    Factory* mFactory;
+    Interpreter::Pointer mInterpreter;
+    Factory::Pointer mFactory;
     WxGUIBlackBoxList* mBoxList;
     WxGUIBlackBoxInfo* mBoxInfo;
 
index 136986a640ac2fd3068c3d85fe13a0851115974d..b7745ad0d43c0997ebcc10052f4abdf30d32508b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/25 15:47:54 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -69,7 +69,7 @@ namespace bbtk
 //    m_mgr = new wxAuiManager(this);
        m_mgr.SetManagedWindow(this);
    
-    mInterpreter = new bbtk::Interpreter();
+       mInterpreter = bbtk::Interpreter::New();
     mInterpreter->SetUser(this);
     mInterpreter->SetCommandLine(true);
     mInterpreter->SetThrow(true);
@@ -304,18 +304,13 @@ namespace bbtk
   //================================================================
   void WxGUIScriptingInterface::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event))
   {
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 01 \n");
-    std::string command("toolsbbtk/appli/CreatePackage");
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 02 \n");
 
+    std::string command("toolsbbtk/appli/CreatePackage");
     bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 03 \n");
-    Interpreter* I = new Interpreter;    
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 04 \n");
+    
+    Interpreter::Pointer I = Interpreter::New();    
     I->InterpretFile(command);
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 05 \n");
-    delete I;
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 06 \n");
+
   }
   //================================================================
 
@@ -325,9 +320,9 @@ printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 06 \n");
   {
     std::string command("toolsbbtk/appli/CreateBlackBox");
     bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
-    Interpreter* I = new Interpreter;    
+    
+    Interpreter::Pointer I = Interpreter::New();    
     I->InterpretFile(command);
-    delete I;
   }
   //================================================================
   
@@ -354,10 +349,8 @@ printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 06 \n");
   {
     std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path();
     std::string filepath = doc_path+"/bbdoc/make-index.bbs";
-    Interpreter* I = new Interpreter;    
 
-//EED  std::cout << "bbi: include "<<filepath<<std::endl;
-//EED  I->InterpretFile( filepath );
+    Interpreter::Pointer I = Interpreter::New();    
 
     I->InterpretLine( "exec freeze");
     I->InterpretLine( "include *");
@@ -366,7 +359,6 @@ printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 06 \n");
     I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories");
     I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors");
     
-    delete I;
   }
   //================================================================
 
index e817bcb78430b24f2ce87f757204c1e0dbe38699..a59e7e875dcc89d18cac7aa4c4ab5158b59e0ab1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIScriptingInterface.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/25 15:47:54 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:16 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -66,9 +66,7 @@ namespace bbtk
     /// Returns the Interpreter used 
     /// ONLY ONE FOR THE MOMENT BUT IN THE FUTURE CAN BE DIFFERENT 
     /// (DIFFERENT WORKSPACES)
-    Interpreter* GetInterpreter() { return mInterpreter; }
-    /// Returns the Interpreter used (const)
-    const Interpreter* GetInterpreter() const { return mInterpreter; }
+    Interpreter::Pointer GetInterpreter() const { return mInterpreter; }
 
     /// Sets the inputs of the workspace : 
     /// the map is passed as is to the Executer
@@ -122,7 +120,7 @@ namespace bbtk
     bool WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target);
   private:
     wxAuiManager m_mgr;
-    Interpreter* mInterpreter;
+    Interpreter::Pointer mInterpreter;
 
     
 //EED    wxNotebook* mwxNotebook;
index 75968dd95ecea0587c1b4a18435f22f994958c58..6dec457842d833c30b9cf064a1f53078a94abb5b 100644 (file)
@@ -5,9 +5,9 @@
 namespace bbitk
 {
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(AnyImageToTypedImage,
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(AnyImageToTypedImage,
                                              bbtk::AtomicBlackBox);
-  BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(AnyImageToConstTypedImage,
+  BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(AnyImageToConstTypedImage,
                                               bbtk::AtomicBlackBox);
   //====================================================================
   
index 768b57e617a7fad4ba6ef4ab3da50b94dc240e5a..61e404ffb25e6df8f65ee56ef33b8f8f55326c1d 100644 (file)
@@ -14,8 +14,9 @@ namespace bbitk
   template <class itkImageTypePointer>
   class AnyImageToTypedImage : public bbtk::AtomicBlackBox
   {  
-    BBTK_USER_BLACK_BOX_INTERFACE(AnyImageToTypedImage,
-                                 bbtk::AtomicBlackBox);
+    BBTK_TEMPLATE_BLACK_BOX_INTERFACE(AnyImageToTypedImage,
+                                     bbtk::AtomicBlackBox,
+                                     itkImageTypePointer);
     BBTK_DECLARE_INPUT(In,anyImagePointer);
     BBTK_DECLARE_OUTPUT(Out,itkImageTypePointer);
     BBTK_PROCESS(DoIt);
@@ -25,7 +26,8 @@ namespace bbitk
   
   //=================================================================
   // BlackBox description
-  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage,
+                                     bbtk::AtomicBlackBox);
   BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To"
            +bbtk::HumanTypeName<T>());
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
@@ -63,8 +65,10 @@ namespace bbitk
   template <class itkImageTypePointer, class itkImageTypeConstPointer>
   class AnyImageToConstTypedImage : public bbtk::AtomicBlackBox
   {  
-    BBTK_USER_BLACK_BOX_INTERFACE(AnyImageToConstTypedImage,
-                                 bbtk::AtomicBlackBox);
+    BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(AnyImageToConstTypedImage,
+                                      bbtk::AtomicBlackBox,
+                                      itkImageTypePointer,
+                                      itkImageTypeConstPointer);
     BBTK_DECLARE_INPUT(In,anyImagePointer);
     BBTK_DECLARE_OUTPUT(Out,itkImageTypeConstPointer);
     BBTK_PROCESS(DoIt);
@@ -74,7 +78,8 @@ namespace bbitk
   
   //=================================================================
   // BlackBox description
-  BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage,
+                                      bbtk::AtomicBlackBox);
   BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To" +
            bbtk::HumanTypeName<T2>());
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
index be5b11769ecd83ce80e1367ecfcdd35d0a903ce2..bfc1d748e6b049afcfe030bff1c61277a2caf964 100644 (file)
@@ -5,9 +5,9 @@
 namespace bbitk
 {
   
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(BinaryThresholdImageFilter,
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(BinaryThresholdImageFilter,
                                              bbtk::AtomicBlackBox);
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(BinaryThresholdImageFilterGeneric,
+  BBTK_BLACK_BOX_IMPLEMENTATION(BinaryThresholdImageFilterGeneric,
                                     bbtk::AtomicBlackBox);
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,
                                BinaryThresholdImageFilterGeneric);
index d734f862bf23fd88625ed871971086a5812ff495..3e6e75ef6d8a2de0250bfef184f64ac629aeaeac 100644 (file)
@@ -13,8 +13,8 @@ namespace bbitk
     public bbtk::AtomicBlackBox,
     public itk::BinaryThresholdImageFilter<T,T>
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
-                                 bbtk::AtomicBlackBox);
+    BBTK_TEMPLATE_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
+                                     bbtk::AtomicBlackBox,T);
     typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
     BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
     BBTK_DECLARE_ITK_PARAM(itkParent,LowerThreshold,typename T::PixelType);
@@ -31,7 +31,8 @@ namespace bbitk
 
   };
   
-  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter,
+                                     bbtk::AtomicBlackBox);
   BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)");
@@ -56,7 +57,7 @@ namespace bbitk
     : 
     public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
+    BBTK_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
                                  bbtk::AtomicBlackBox);
     BBTK_DECLARE_INPUT(In,anyImagePointer);
     BBTK_DECLARE_INPUT(LowerThreshold,double);
@@ -109,7 +110,7 @@ namespace bbitk
                        <<bbtk::TypeName<T>()<<">()"<<std::endl);
  
     typedef BinaryThresholdImageFilter<T> FilterType;
-    FilterType* f = FilterType::bbNew("Temp");
+    typename FilterType::Pointer f = FilterType::New("Temp");
     f->bbSetInputIn( this->bbGetInputIn().get<T*>());
     f->bbSetInputLowerThreshold ( (typename T::PixelType)
                                  this->bbGetInputLowerThreshold() );
@@ -122,7 +123,7 @@ namespace bbitk
     f->bbExecute();
     f->bbGetOutputOut()->Register();
     this->bbSetOutputOut( f->bbGetOutputOut() );
-    f->bbDelete();
+
     bbtkDebugDecTab("Core",9);
   }
   
index 1a3f717a9a56577bf2e615eb7af2323761866b37..1f20b105d589b025e0b5c5b048f030c40d6a16f3 100644 (file)
@@ -6,9 +6,9 @@
 namespace bbitk
 {
   
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ExtractImageFilter,
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ExtractImageFilter,
                                              bbtk::AtomicBlackBox);
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExtractImageFilterGeneric,
+  BBTK_BLACK_BOX_IMPLEMENTATION(ExtractImageFilterGeneric,
                                     bbtk::AtomicBlackBox);
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ExtractImageFilterGeneric)
index b6de2d11513789a4cd5d1bd33b12fdd53b900cd5..12d07bf3e3de1949b4d6499e7412c9952aa76478 100644 (file)
@@ -15,7 +15,9 @@ namespace bbitk
     public bbtk::AtomicBlackBox,
     public itk::ExtractImageFilter<T,T>
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(ExtractImageFilter,bbtk::AtomicBlackBox);
+    BBTK_TEMPLATE_BLACK_BOX_INTERFACE(ExtractImageFilter,
+                                     bbtk::AtomicBlackBox,
+                                     T);
     typedef itk::ExtractImageFilter<T,T> itkParent;
 
     BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
@@ -27,7 +29,8 @@ namespace bbitk
   };
 
 
-  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter,
+                                     bbtk::AtomicBlackBox);
   BBTK_NAME("ExtractImageFilter<"+bbtk::TypeName<T>()+">");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_DESCRIPTION("Decrease the image size by cropping the image to the selected region bounds (bbification of itk::ExtractImageFilter)");
@@ -42,8 +45,8 @@ namespace bbitk
   class /*BBTK_EXPORT*/ ExtractImageFilterGeneric
     : public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(ExtractImageFilterGeneric,
-                                 bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(ExtractImageFilterGeneric,
+                            bbtk::AtomicBlackBox);
     BBTK_DECLARE_INPUT(In,anyImagePointer);
     BBTK_DECLARE_INPUT(Region,anyImageRegion);
     BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
@@ -76,13 +79,13 @@ namespace bbitk
                        <<bbtk::TypeName<T>()<<">()"<<std::endl);
     typedef T ImageType;
     typedef ExtractImageFilter<ImageType> FilterType;
-    FilterType* f = FilterType::bbNew("Temp");
+    typename FilterType::Pointer f = FilterType::New("Temp");
     f->bbSetInputIn( this->bbGetInputIn().unsafe_get<T*>() );
     f->bbSetInputExtractionRegion ( this->bbGetInputRegion().get<typename T::RegionType>() );
     f->bbExecute();
     f->bbGetOutputOut()->Register();
     this->bbSetOutputOut( f->bbGetOutputOut() );
-    f->bbDelete();
+    //  f->bbDelete();
 
     bbtkDebugDecTab("Core",9);
   }
index 5d4c883c2ec3875831d7289094e80a04e146be95..99417f7d425177cb841ef2cc2333e4361bf7df78 100644 (file)
@@ -8,8 +8,8 @@ namespace bbstd
 {
   
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(Relay,
-                                              bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(Relay,
+                                        bbtk::AtomicBlackBox);
   //====================================================================
 }
 using namespace bbstd;
index d46c01be06e9f994c472587a462f280164dfb9c4..223950e857550ff35cc8ad932bcdc628dfadc24a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkImageProperties.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/07 07:58:54 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -26,7 +26,7 @@
 
 namespace bbitk 
 {
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageProperties,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ImageProperties,bbtk::AtomicBlackBox);
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageProperties);
 
index e2987999a1d63eb8a424f0cfa226ea319856f3b4..25053b23d6d1d7604c2b5dc99d989552e53c2399 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkImageProperties.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -40,8 +40,8 @@ namespace bbitk
   class ImageProperties : public bbtk::AtomicBlackBox  
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(ImageProperties,
-                                 bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(ImageProperties,
+                            bbtk::AtomicBlackBox);
 
     BBTK_DECLARE_INPUT(In,anyImagePointer);
     BBTK_DECLARE_OUTPUT(TypeName,std::string);
index 329c579922e23123d738a32b0134d5df3a1b1800..b6d9bb11b85e9688419985babd0eabdfd54f8d3f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkImageReader.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/07 07:58:54 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -27,8 +27,8 @@
 
 namespace bbitk 
 {
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageReader,bbtk::AtomicBlackBox);
-
+  BBTK_BLACK_BOX_IMPLEMENTATION(ImageReader,bbtk::AtomicBlackBox);
+  
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageReader);
 
 
index 4a1715259c5aa4bc2daf8755f34359e190525da5..44a6318f67e3a762dd3524fb8ff57252d917baf3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkImageReader.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,8 +39,8 @@ namespace bbitk
   class ImageReader : public bbtk::AtomicBlackBox  
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(ImageReader,
-                                 bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(ImageReader,
+                            bbtk::AtomicBlackBox);
 
     BBTK_DECLARE_INPUT(Filename,std::string);
     BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
index b1bcf8cd2eb7517832a9536e02f9b2ab35ebbc39..dffba00f430ad6e26b55c4eb4df9e989a3804fdf 100644 (file)
@@ -6,8 +6,8 @@
 namespace bbitk
 {
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageRegionCreator,
-                                    bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ImageRegionCreator,
+                               bbtk::AtomicBlackBox);
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageRegionCreator);
 
index fdcf5890f86a1862ec9e74a1b73ab08f04f94c61..3e0746403b1ab1b00ab9167ed89f230dae170c9d 100644 (file)
@@ -46,7 +46,7 @@ namespace bbitk
   class /*BBTK_EXPORT*/ ImageRegionCreator
     : public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(ImageRegionCreator,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(ImageRegionCreator,bbtk::AtomicBlackBox);
     BBTK_DECLARE_INPUT(Index,std::vector<long>);
     BBTK_DECLARE_INPUT(Size,std::vector<long>);
     BBTK_DECLARE_OUTPUT(Out,anyImageRegion);
index 058c2886bbc80937c96e3850ff6de94ddc0fa5ab..36432d54e3b847b2ca1c39e6b350c8e7b3eaed31 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkImageSeriesReader.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/07 07:58:54 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -27,8 +27,8 @@
 
 namespace bbitk 
 {
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageSeriesReader,bbtk::AtomicBlackBox);
-
+  BBTK_BLACK_BOX_IMPLEMENTATION(ImageSeriesReader,bbtk::AtomicBlackBox);
+  
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageSeriesReader);
 
 
index 5798b7a73398144b8555ea74dffdb493bc32f8e4..0b4797a43257c915dabbef64e5470e5bda47d7ce 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkImageSeriesReader.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,8 +39,8 @@ namespace bbitk
   class ImageSeriesReader : public bbtk::AtomicBlackBox  
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(ImageSeriesReader,
-                                 bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(ImageSeriesReader,
+                            bbtk::AtomicBlackBox);
 
     BBTK_DECLARE_INPUT(FileNames,std::vector<std::string>);
     BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
index 327108ee52ac0c34b4fbac35a35aa7b61e1ad7a2..efa672c99892a556e00309b1c14cb3ee3f708a46 100644 (file)
@@ -10,8 +10,8 @@ namespace bbstd
   
   
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
-                                             bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
+                                        bbtk::AtomicBlackBox);
   //====================================================================
   
   //====================================================================
index 820add6b2caa0c4e8b79e6eb99a455071cc8aa1f..540fc70df8c6bfd89dccc261d60984fee9639607 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkImageWriter.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/07 07:58:55 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -27,7 +27,7 @@
 
 namespace bbitk 
 {
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageWriter,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ImageWriter,bbtk::AtomicBlackBox);
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageWriter);
 
index d4fa74b1878d61933cab08e678209feacac6e732..d5b025f9f52ca089401c4cf33bf84ed605d0817f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkImageWriter.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:31 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,7 +39,7 @@ namespace bbitk
   class ImageWriter : public bbtk::AtomicBlackBox  
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(ImageWriter,
+    BBTK_BLACK_BOX_INTERFACE(ImageWriter,
                                  bbtk::AtomicBlackBox);
 
     BBTK_DECLARE_INPUT(Filename,std::string);
index fd98e5ebd41d2173d26ac1484c5ba2096730a002..3e50d8aa05a6a69c9f0a96056cfdcf435b4e4fad 100644 (file)
@@ -5,7 +5,7 @@
 namespace bbitk
 {
   
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ResampleImageFilter,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ResampleImageFilter,bbtk::AtomicBlackBox);
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ResampleImageFilter);
 }
 
index 8c9ed215bddd1683c6911efdf9e6a71dc75ecfb8..54be167cbc2344f1c072e2a57cf527ac071f03d3 100644 (file)
@@ -16,7 +16,7 @@ namespace bbitk
     : 
     public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(ResampleImageFilter,
+    BBTK_BLACK_BOX_INTERFACE(ResampleImageFilter,
                                  bbtk::AtomicBlackBox);
     BBTK_DECLARE_INPUT(In,anyImagePointer);
     BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
index 9946c286e450ba98318d028c0cf723e88c58708b..f7fbaf740764747a93b7c0047a37fe0972f97131 100644 (file)
@@ -5,8 +5,8 @@
 namespace bbitk
 {
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(TypedImageToAnyImage,
-                                             bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(TypedImageToAnyImage,
+                                        bbtk::AtomicBlackBox);
   
   //====================================================================
   
index 50efb5031f1e6cac262155114895285406855b61..edb82685e3aba183f1eb217c0677a28c96c8cd23 100644 (file)
@@ -15,8 +15,9 @@ namespace bbitk
   template <class itkImageTypePointer>
   class TypedImageToAnyImage : public bbtk::AtomicBlackBox
   {  
-    BBTK_USER_BLACK_BOX_INTERFACE(TypedImageToAnyImage,
-                                 bbtk::AtomicBlackBox);
+    BBTK_TEMPLATE_BLACK_BOX_INTERFACE(TypedImageToAnyImage,
+                                     bbtk::AtomicBlackBox,
+                                     itkImageTypePointer);
     BBTK_DECLARE_INPUT(In,itkImageTypePointer);
     BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
     BBTK_PROCESS(DoIt);
@@ -26,7 +27,8 @@ namespace bbitk
  
   //=================================================================
   // BlackBox description
-  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(TypedImageToAnyImage);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(TypedImageToAnyImage,
+                                     bbtk::AtomicBlackBox);
   BBTK_NAME(bbtk::HumanTypeName<T>()
            + "To" + bbtk::HumanTypeName<anyImagePointer>());
   BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
index 04b523d52e68a271a5923881ceb74a254b6aa015..3fe9fe370701bd9d566cc48fdd68fb62d9854f5c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkvtkitkImage2vtkImageData.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/03 11:49:17 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -32,7 +32,7 @@
 
 namespace bbitkvtk 
 {
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(itkImage2vtkImageData,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(itkImage2vtkImageData,bbtk::AtomicBlackBox);
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itkvtk,itkImage2vtkImageData);
 
index e0a21c3b7e6e7ac8ee4f64ef3a42cee4d59dc831..d2f9564fdd896945202a4fe529f04144052d0240 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkvtkitkImage2vtkImageData.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:31 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,8 +39,8 @@ namespace bbitkvtk
   class itkImage2vtkImageData : public bbtk::AtomicBlackBox  
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(itkImage2vtkImageData,
-                                 bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(itkImage2vtkImageData,
+                            bbtk::AtomicBlackBox);
 
     BBTK_DECLARE_INPUT(In,bbitk::anyImagePointer);
     BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
index 92d5fed9953938bdff5437e7540ce30a426e47bc..3afb1e81eb0df56651b8f6e670628131ef133bdb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkvtkvtkImageData2itkImage.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/03 11:49:17 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -33,7 +33,7 @@
 namespace bbitkvtk 
 {
   
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(vtkImageData2itkImage,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(vtkImageData2itkImage,bbtk::AtomicBlackBox);
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(itkvtk,vtkImageData2itkImage);
   
index 94fc7ce289513e02de63e4baa534ac82dcb4e076..d092863f23127ba6f09324dd0dbbc6cb9ed85066 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbitkvtkvtkImageData2itkImage.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:31 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:50 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,8 +39,8 @@ namespace bbitkvtk
   class /*BBTK_EXPORT*/ vtkImageData2itkImage : public bbtk::AtomicBlackBox  
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(vtkImageData2itkImage,
-                                 bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(vtkImageData2itkImage,
+                            bbtk::AtomicBlackBox);
 
     BBTK_DECLARE_INPUT(In,vtkImageData*);
     BBTK_DECLARE_OUTPUT(Out,bbitk::anyImagePointer);
index 316d47373b984e62fd667ce90d6234dfc7534209..c24da54f26b8be29ef98e7bf766fd637e50eca74 100644 (file)
@@ -2,69 +2,69 @@
 #include "bbstdPackage.h"
 namespace bbstd
 {
-
-       BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ASCII)
-       BBTK_USER_BLACK_BOX_IMPLEMENTATION(ASCII,bbtk::AtomicBlackBox);
-       void ASCII::Process()
-       {
-               int asciiValue;
-               char strTmp[10];
-               std::string result("");
-               if (bbGetInputIn()!=""){
-
-                       if (bbGetInputtype()==0){
-                               std::string commandstr(bbGetInputIn());
-                               bool ok=true;
-                               int pos1=0,pos2;
-                               pos2 = commandstr.find(" ",pos1);
-                               std::string ccommand;
-                               while (ok==true)
-                               {
-                                       if (pos2==-1)   
-                                       {
-                                               ok=false;
-                                               ccommand=commandstr.substr(pos1,commandstr.length()-pos1 );
-                                       }       else  {
-                                               ccommand=commandstr.substr(pos1,pos2-pos1);
-                                       }
-                                       asciiValue = atoi( ccommand.c_str() );
-                                       sprintf(strTmp,"%c",asciiValue);
-                                       result += strTmp;
-
-                                       pos1=pos2+1;
-                                       pos2 = commandstr.find(" ",pos2+1);
-                               } // while
-                       } // if type 0
-
-                       if (bbGetInputtype()==1){
-                               int i,size=bbGetInputIn().size();
-                               for (i=0;i<size;i++){
-                                       asciiValue = (int)bbGetInputIn()[i];
-                                       sprintf(strTmp,"%d",asciiValue);
-                                       result +=strTmp;
-                                       if (i!=size-1) {
-                                               result +=" ";
-                                       } // i!=size-1
-                               } // for
-                       } // type 1
-               }
-               bbSetOutputOut( result );  
-       }
-
-       void ASCII::bbUserConstructor()
-       {
-       bbSetInputIn("");
-       bbSetInputtype(0);
-       }
-
-       void ASCII::bbUserCopyConstructor()
-       {
-
-       }
-
-       void ASCII::bbUserDestructor()
-       {
-       }
+  
+  BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ASCII);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ASCII,bbtk::AtomicBlackBox);
+  void ASCII::Process()
+  {
+    int asciiValue;
+    char strTmp[10];
+    std::string result("");
+    if (bbGetInputIn()!=""){
+      
+      if (bbGetInputtype()==0){
+       std::string commandstr(bbGetInputIn());
+       bool ok=true;
+       int pos1=0,pos2;
+       pos2 = commandstr.find(" ",pos1);
+       std::string ccommand;
+       while (ok==true)
+         {
+           if (pos2==-1)       
+             {
+               ok=false;
+               ccommand=commandstr.substr(pos1,commandstr.length()-pos1 );
+             }         else  {
+             ccommand=commandstr.substr(pos1,pos2-pos1);
+           }
+           asciiValue = atoi( ccommand.c_str() );
+           sprintf(strTmp,"%c",asciiValue);
+           result += strTmp;
+           
+           pos1=pos2+1;
+           pos2 = commandstr.find(" ",pos2+1);
+         } // while
+      } // if type 0
+      
+      if (bbGetInputtype()==1){
+       int i,size=bbGetInputIn().size();
+       for (i=0;i<size;i++){
+         asciiValue = (int)bbGetInputIn()[i];
+         sprintf(strTmp,"%d",asciiValue);
+         result +=strTmp;
+         if (i!=size-1) {
+           result +=" ";
+         } // i!=size-1
+       } // for
+      } // type 1
+    }
+    bbSetOutputOut( result );  
+  }
+  
+  void ASCII::bbUserConstructor()
+  {
+    bbSetInputIn("");
+    bbSetInputtype(0);
+  }
+  
+  void ASCII::bbUserCopyConstructor()
+  {
+    
+  }
+  
+  void ASCII::bbUserDestructor()
+  {
+  }
 }
 // EO namespace bbstd
 
index 13cee0e341cd2423775c386701918e3b76f57403..688c104585c23c86d35139ebfed8847e69e0a98d 100644 (file)
@@ -6,27 +6,27 @@
 namespace bbstd
 {
 
-class /*BBTK_EXPORT*/ ASCII
- : 
-   public bbtk::AtomicBlackBox
-{
-  BBTK_USER_BLACK_BOX_INTERFACE(ASCII,bbtk::AtomicBlackBox);
-//==================================================================
-/// User callback called in the box contructor
-virtual void bbUserConstructor();
-/// User callback called in the box copy constructor
-virtual void bbUserCopyConstructor();
-/// User callback called in the box destructor
-virtual void bbUserDestructor();
-//==================================================================
-  BBTK_DECLARE_INPUT(In,std::string);
-  BBTK_DECLARE_INPUT(type,int);
-  BBTK_DECLARE_OUTPUT(Out,std::string);
-  BBTK_PROCESS(Process);
-  void Process();
-};
-
-BBTK_BEGIN_DESCRIBE_BLACK_BOX(ASCII,bbtk::AtomicBlackBox);
+  class /*BBTK_EXPORT*/ ASCII
   
+    public bbtk::AtomicBlackBox
+  {
+    BBTK_BLACK_BOX_INTERFACE(ASCII,bbtk::AtomicBlackBox);
+    //==================================================================
+    /// User callback called in the box contructor
+    virtual void bbUserConstructor();
+    /// User callback called in the box copy constructor
+    virtual void bbUserCopyConstructor();
+    /// User callback called in the box destructor
+    virtual void bbUserDestructor();
+    //==================================================================
+    BBTK_DECLARE_INPUT(In,std::string);
+    BBTK_DECLARE_INPUT(type,int);
+    BBTK_DECLARE_OUTPUT(Out,std::string);
+    BBTK_PROCESS(Process);
+    void Process();
+  };
+  
+  BBTK_BEGIN_DESCRIBE_BLACK_BOX(ASCII,bbtk::AtomicBlackBox);
   BBTK_NAME("ASCII");  
   BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr");
   BBTK_DESCRIPTION("ascii codes sequence to string - string to ascii codes sequence");
@@ -34,7 +34,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ASCII,bbtk::AtomicBlackBox);
   BBTK_INPUT(ASCII,In,"Input Ascii code or Ascii character",std::string,"");
   BBTK_INPUT(ASCII,type,"type (default 0) 0=Ascii codes to string, 1=String to ascii codes",int,"");
   BBTK_OUTPUT(ASCII,Out,"Ascii codes sequence or characters sequence",std::string,"");
-BBTK_END_DESCRIBE_BLACK_BOX(ASCII);
+  BBTK_END_DESCRIBE_BLACK_BOX(ASCII);
 }
 // EO namespace bbstd
 
index bd3f94fe6d84540e8bd7af060aa94147ee512713..a579cfdd21c7f6589d8d14324e0a2eb2ba135bb9 100644 (file)
@@ -5,8 +5,8 @@ namespace bbstd
 {
   
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
-                                              bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
+                                         bbtk::AtomicBlackBox);
   //====================================================================
   
   //====================================================================
index 81f6e20c5bc25b79c2d04f1a8b00731bcb0b9cfc..c1b1af2d8fac02cb4817b4247af97c22824488c1 100644 (file)
@@ -11,7 +11,7 @@ namespace bbstd
   template <class T, class U>
   class Cast : public bbtk::AtomicBlackBox
   {  
-    BBTK_USER_BLACK_BOX_INTERFACE(Cast,bbtk::AtomicBlackBox);
+    BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(Cast,bbtk::AtomicBlackBox,T,U);
     BBTK_DECLARE_INPUT(In,T);
     BBTK_DECLARE_OUTPUT(Out,U);
     BBTK_PROCESS(DoIt);
@@ -32,7 +32,7 @@ namespace bbstd
   
   //=================================================================
   // UserBlackBox description
-  BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(Cast);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(Cast,bbtk::AtomicBlackBox);
   BBTK_NAME("Cast"+bbtk::HumanTypeName<T1>()+"To"+bbtk::HumanTypeName<T2>());
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_DESCRIPTION("Static cast from "+bbtk::HumanTypeName<T1>()+" ("
index ec70935cd626f532e9f2f010f9b79ad8c46099b6..098c95c1ba3e6cfe40c8c6e9de3946f4c25ce1ac 100644 (file)
@@ -3,37 +3,37 @@
 
 namespace bbstd
 {
-       BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ConcatStrings)
-       BBTK_USER_BLACK_BOX_IMPLEMENTATION(ConcatStrings,bbtk::AtomicBlackBox);
-
-       void ConcatStrings::bbUserConstructor() 
-   
-      bbSetInputIn1("");
-      bbSetInputIn2("");
-      bbSetInputIn3("");
-      bbSetInputIn4("");
-      bbSetInputIn5("");
-      bbSetInputIn6("");
-      bbSetInputIn7("");
-      bbSetInputIn8("");
-      bbSetInputIn9("");
-      bbSetInputIn10("");
-   }
-
-
-       void ConcatStrings::DoProcess()
-       {
-      bbSetOutputOut(  bbGetInputIn1() + 
-                                               bbGetInputIn2() +
-                                               bbGetInputIn3() +
-                                               bbGetInputIn4() +
-                                               bbGetInputIn5() +
-                                               bbGetInputIn6() +
-                                               bbGetInputIn7() +
-                                               bbGetInputIn8() +
-                                               bbGetInputIn9() +
-                                               bbGetInputIn10()  );      
-       }
+  BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ConcatStrings);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ConcatStrings,bbtk::AtomicBlackBox);
+  
+  void ConcatStrings::bbUserConstructor() 
+  { 
+    bbSetInputIn1("");
+    bbSetInputIn2("");
+    bbSetInputIn3("");
+    bbSetInputIn4("");
+    bbSetInputIn5("");
+    bbSetInputIn6("");
+    bbSetInputIn7("");
+    bbSetInputIn8("");
+    bbSetInputIn9("");
+    bbSetInputIn10("");
+  }
+  
+  
+  void ConcatStrings::DoProcess()
+  {
+    bbSetOutputOut(    bbGetInputIn1() + 
+                       bbGetInputIn2() +
+                       bbGetInputIn3() +
+                       bbGetInputIn4() +
+                       bbGetInputIn5() +
+                       bbGetInputIn6() +
+                       bbGetInputIn7() +
+                       bbGetInputIn8() +
+                       bbGetInputIn9() +
+                       bbGetInputIn10()  );      
+  }
 }
 // EO namespace bbstd
 
index 38a27588e251e680422f203132b13470a4c134b6..2c2881026316fbad71b201ff47a82d0b8069c7b9 100644 (file)
@@ -9,7 +9,7 @@ namespace bbstd
     : 
     public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(ConcatStrings,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(ConcatStrings,bbtk::AtomicBlackBox);
     BBTK_DECLARE_INPUT(In1, std::string);
     BBTK_DECLARE_INPUT(In2, std::string);
     BBTK_DECLARE_INPUT(In3, std::string);
index 8981782aa6af169b5c3b43c78db9190acbd085be..e6032a382f2b598a28999aa2b6c73db438b6022e 100644 (file)
@@ -4,8 +4,8 @@
 #include "bbtkConfigurationFile.h"
 namespace bbstd
 {
-  BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,Configuration)
-    BBTK_USER_BLACK_BOX_IMPLEMENTATION(Configuration,bbtk::AtomicBlackBox);
+  BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,Configuration);
+  BBTK_BLACK_BOX_IMPLEMENTATION(Configuration,bbtk::AtomicBlackBox);
   
   void Configuration::bbUserConstructor() 
   { 
index c85ff384a90986dec55ca2a1b4365f03bfaa7edb..9f3aced1acec41991955e65a4adf07598264b06c 100644 (file)
@@ -9,7 +9,7 @@ namespace bbstd
     : 
     public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(Configuration,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(Configuration,bbtk::AtomicBlackBox);
     BBTK_DECLARE_OUTPUT(BinPath,std::string);
     BBTK_DECLARE_OUTPUT(DataPath,std::string);
     BBTK_DECLARE_OUTPUT(DocPath,std::string);
index fb85734a9b71a4be1151ac0fe492ad28aeacb1f5..c52598db56ac542e2d0de94b024a9678c8b3e062 100755 (executable)
@@ -7,7 +7,7 @@ namespace bbstd
 {
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecBbiCommand);
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExecBbiCommand,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ExecBbiCommand,bbtk::AtomicBlackBox);
 
   void ExecBbiCommand::bbUserConstructor() 
   { 
@@ -17,6 +17,7 @@ namespace bbstd
 
   void ExecBbiCommand::DoProcess()
     {
+      /*
       // Look for the interpreter
       bbtk::Interpreter* I = 0;
          bool delete_inter = false; 
@@ -67,7 +68,7 @@ namespace bbstd
        }
       
       if (delete_inter) delete I;
-      
+      */
       /*  Grrr  not works in windows
        char * pch;
        pch = strtok (bbGetInputIn(),";");
index 2718848401dd31f1f2b99155ce573dede7d6b231..8bf3f56f9dab1265659cbbfa6aee47b2e172917c 100755 (executable)
@@ -10,25 +10,25 @@ namespace bbstd
     : 
     public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(ExecBbiCommand,bbtk::AtomicBlackBox);
-      BBTK_DECLARE_INPUT(In,std::string);
-//    BBTK_DECLARE_OUTPUT(Out,std::string);
+    BBTK_BLACK_BOX_INTERFACE(ExecBbiCommand,bbtk::AtomicBlackBox);
+    BBTK_DECLARE_INPUT(In,std::string);
+    //    BBTK_DECLARE_OUTPUT(Out,std::string);
     BBTK_PROCESS(DoProcess);
     void DoProcess();
-
+    
   protected:
     virtual void bbUserConstructor();
-
+    
   };
 
   BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExecBbiCommand,bbtk::AtomicBlackBox);
-    BBTK_NAME("ExecBbiCommand");
-    BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
-    BBTK_DESCRIPTION("Executes bbi commands");
-    BBTK_INPUT(ExecBbiCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");  
-//  BBTK_OUTPUT(ExecBbiCommand,Out,"Concatenated string",std::string);
+  BBTK_NAME("ExecBbiCommand");
+  BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
+  BBTK_DESCRIPTION("Executes bbi commands");
+  BBTK_INPUT(ExecBbiCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");  
+  //  BBTK_OUTPUT(ExecBbiCommand,Out,"Concatenated string",std::string);
   BBTK_END_DESCRIBE_BLACK_BOX(ExecBbiCommand);
-
+  
 } // EO namespace bbstd
 
 #endif //  __bbstdExecBbiCommand_h_INCLUDED__
index 0447b2b2015699a6049788369e0f4eae7c41ac37..5dfdf6b4aadf9f994e91529c4e557e81665902e7 100755 (executable)
@@ -6,7 +6,7 @@ namespace bbstd
 {
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecSystemCommand);
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExecSystemCommand,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ExecSystemCommand,bbtk::AtomicBlackBox);
   
   void ExecSystemCommand::bbUserConstructor() 
   { 
index e3b6ba1e5194ab9677651ea841ca5917ea3c08a3..9f070b80904fbdcc2af947effab0f2c2f75f45f4 100755 (executable)
@@ -10,9 +10,9 @@ namespace bbstd
     : 
     public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(ExecSystemCommand,bbtk::AtomicBlackBox);
-      BBTK_DECLARE_INPUT(In,std::string);
-//    BBTK_DECLARE_OUTPUT(Out,std::string);
+    BBTK_BLACK_BOX_INTERFACE(ExecSystemCommand,bbtk::AtomicBlackBox);
+    BBTK_DECLARE_INPUT(In,std::string);
+    //    BBTK_DECLARE_OUTPUT(Out,std::string);
     BBTK_PROCESS(DoProcess);
     void DoProcess();
 
@@ -22,13 +22,13 @@ namespace bbstd
   };
 
   BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExecSystemCommand,bbtk::AtomicBlackBox);
-    BBTK_NAME("ExecSystemCommand");
-    BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
-    BBTK_DESCRIPTION("Execute bbi commands");
-    BBTK_INPUT(ExecSystemCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");  
-//  BBTK_OUTPUT(ExecSystemCommand,Out,"Concatenated string",std::string);
+  BBTK_NAME("ExecSystemCommand");
+  BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
+  BBTK_DESCRIPTION("Execute bbi commands");
+  BBTK_INPUT(ExecSystemCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");  
+  //  BBTK_OUTPUT(ExecSystemCommand,Out,"Concatenated string",std::string);
   BBTK_END_DESCRIBE_BLACK_BOX(ExecSystemCommand);
-
+  
 } // EO namespace bbstd
 
 #endif //  __bbstdExecSystemCommand_h_INCLUDED__
index 758467fb188459d6eed1074d541a1cad76eedba5..f11eb89fc8bc511f30224e8050b2173aba28f985 100644 (file)
@@ -3,9 +3,9 @@
 namespace bbstd
 {
 
-BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MagicBox)
-BBTK_USER_BLACK_BOX_IMPLEMENTATION(MagicBox,bbtk::AtomicBlackBox);
-
+  BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MagicBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(MagicBox,bbtk::AtomicBlackBox);
+  
 }
 // EO namespace bbstd
 
index 561e37b4f8819497779057eb5c3342ffe3d59fe8..55f0d7ca8c893931001eaabbe22cd528bf80178c 100644 (file)
@@ -10,9 +10,9 @@ namespace bbstd
     : 
     public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(MagicBox,bbtk::AtomicBlackBox);
-       BBTK_DECLARE_INPUT(In,bbtk::Data);
-       BBTK_DECLARE_OUTPUT(Out,bbtk::Data);
+    BBTK_BLACK_BOX_INTERFACE(MagicBox,bbtk::AtomicBlackBox);
+    BBTK_DECLARE_INPUT(In,bbtk::Data);
+    BBTK_DECLARE_OUTPUT(Out,bbtk::Data);
     BBTK_PROCESS(DoProcess);
     void DoProcess() { bbSetOutputOut( bbGetInputIn() ); }
     
index e450d2cbd0f7e364571c14f93c78f7ea1a8a627a..5ab0115bdedf0f814efc1602633726f5d6013e79 100644 (file)
@@ -5,28 +5,28 @@
 namespace bbstd
 {
 
-       BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MakeFileName)
-       BBTK_USER_BLACK_BOX_IMPLEMENTATION(MakeFileName,bbtk::AtomicBlackBox);
-
-       void MakeFileName::bbUserConstructor()
-   {
-      bbSetInputDirectory("");
-      bbSetInputFile("");
-      bbSetInputExtent("");
-   }
-
-       void MakeFileName::DoProcess()
-       {
-      std::string fileSep = bbtk::ConfigurationFile::GetInstance().Get_file_separator();
-      std::string fullFileName = bbGetInputDirectory();
-      if ( fullFileName.c_str()[fullFileName.size()-1] != '/' && fullFileName.c_str()[fullFileName.size()-1] != '\\' )
-         fullFileName += fileSep;
-      fullFileName += bbGetInputFile();
-      if ( bbGetInputExtent() != "")
-         if ( bbGetInputExtent()[0] != '.' )
-            fullFileName += ".";
-      fullFileName +=  bbGetInputExtent();
-      bbSetOutputOut( fullFileName );    
-       }
+  BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MakeFileName);
+  BBTK_BLACK_BOX_IMPLEMENTATION(MakeFileName,bbtk::AtomicBlackBox);
+  
+  void MakeFileName::bbUserConstructor()
+  {
+    bbSetInputDirectory("");
+    bbSetInputFile("");
+    bbSetInputExtent("");
+  }
+  
+  void MakeFileName::DoProcess()
+  {
+    std::string fileSep = bbtk::ConfigurationFile::GetInstance().Get_file_separator();
+    std::string fullFileName = bbGetInputDirectory();
+    if ( fullFileName.c_str()[fullFileName.size()-1] != '/' && fullFileName.c_str()[fullFileName.size()-1] != '\\' )
+      fullFileName += fileSep;
+    fullFileName += bbGetInputFile();
+    if ( bbGetInputExtent() != "")
+      if ( bbGetInputExtent()[0] != '.' )
+       fullFileName += ".";
+    fullFileName +=  bbGetInputExtent();
+    bbSetOutputOut( fullFileName );      
+  }
 }
 // EO namespace bbstd
index af944629acbcd4b797e7ec29ca79c53d6b110aa6..d9d6eab01d5684cb62202ddc1f98c12a307fe222 100644 (file)
@@ -9,11 +9,11 @@ namespace bbstd
     :
   public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(MakeFileName,bbtk::AtomicBlackBox);
-       BBTK_DECLARE_INPUT(Directory,std::string);
-       BBTK_DECLARE_INPUT(File,std::string);
-       BBTK_DECLARE_INPUT(Extent,std::string);
-       BBTK_DECLARE_OUTPUT(Out,std::string);
+    BBTK_BLACK_BOX_INTERFACE(MakeFileName,bbtk::AtomicBlackBox);
+    BBTK_DECLARE_INPUT(Directory,std::string);
+    BBTK_DECLARE_INPUT(File,std::string);
+    BBTK_DECLARE_INPUT(Extent,std::string);
+    BBTK_DECLARE_OUTPUT(Out,std::string);
     BBTK_PROCESS(DoProcess);
     void DoProcess();
 
index 57085632a2d7f494c9e68db550f0538a9cb64d26..af486141a31b8c85e33f74009512ea587f8e7b15 100644 (file)
@@ -8,10 +8,10 @@ namespace bbstd
 {
   
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(Relay,
-                                              bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(Relay,
+                                        bbtk::AtomicBlackBox);
   //====================================================================
+  
   //====================================================================
   // Standard relays 
   using namespace std;
index 8ce2f93936d41665a7c371f16d13c0d637fb93ae..c0ef92d0ab181cb5922c4e10aa8dad484737297a 100644 (file)
@@ -11,9 +11,9 @@ namespace bbstd
     :
     public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(Relay,bbtk::AtomicBlackBox);
-       BBTK_DECLARE_INPUT(In,T);
-       BBTK_DECLARE_OUTPUT(Out,T);
+    BBTK_TEMPLATE_BLACK_BOX_INTERFACE(Relay,bbtk::AtomicBlackBox,T);
+    BBTK_DECLARE_INPUT(In,T);
+    BBTK_DECLARE_OUTPUT(Out,T);
     BBTK_PROCESS(Process);
   protected:
     void Process() { bbSetOutputOut ( bbGetInputIn() ); }
@@ -21,7 +21,7 @@ namespace bbstd
   //=======================================================================
 
   //=======================================================================
-  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(Relay);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(Relay,bbtk::AtomicBlackBox);
   BBTK_NAME(bbtk::HumanTypeName<T>()+"Relay");
   BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
   BBTK_CATEGORY("misc");
index 6316d0af6d5bf65d34b0d779d1916f02fbdf44a0..0c9bc95150f4042b200aed262c71b35942e9e901 100644 (file)
@@ -4,40 +4,40 @@
 namespace bbstd
 {
 
-       BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,StringSelect)
-       BBTK_USER_BLACK_BOX_IMPLEMENTATION(StringSelect,bbtk::AtomicBlackBox);
-
-       void StringSelect::bbUserConstructor() 
-               
-                       bbSetInputIn(0);
-                       bbSetInputIn0("");
-                       bbSetInputIn1("");
-                       bbSetInputIn2("");
-                       bbSetInputIn3("");
-                       bbSetInputIn4("");
-                       bbSetInputIn5("");
-                       bbSetInputIn6("");
-                       bbSetInputIn7("");
-                       bbSetInputIn8("");
-                       bbSetInputIn9("");
-               }
-
-
-
-       void StringSelect::DoProcess()
-       {
-               if (bbGetInputIn()==0) bbSetOutputOut( bbGetInputIn0() );
-               else if (bbGetInputIn()==1) bbSetOutputOut( bbGetInputIn1() );
-               else if (bbGetInputIn()==2) bbSetOutputOut( bbGetInputIn2() );
-               else if (bbGetInputIn()==3) bbSetOutputOut( bbGetInputIn3() );
-               else if (bbGetInputIn()==4) bbSetOutputOut( bbGetInputIn4() );
-               else if (bbGetInputIn()==5) bbSetOutputOut( bbGetInputIn5() );
-               else if (bbGetInputIn()==6) bbSetOutputOut( bbGetInputIn6() );
-               else if (bbGetInputIn()==7) bbSetOutputOut( bbGetInputIn7() );
-               else if (bbGetInputIn()==8) bbSetOutputOut( bbGetInputIn8() );
-               else if (bbGetInputIn()==9) bbSetOutputOut( bbGetInputIn9() );
-         
-       }
+  BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,StringSelect)
+    BBTK_BLACK_BOX_IMPLEMENTATION(StringSelect,bbtk::AtomicBlackBox);
+  
+  void StringSelect::bbUserConstructor() 
+  { 
+    bbSetInputIn(0);
+    bbSetInputIn0("");
+    bbSetInputIn1("");
+    bbSetInputIn2("");
+    bbSetInputIn3("");
+    bbSetInputIn4("");
+    bbSetInputIn5("");
+    bbSetInputIn6("");
+    bbSetInputIn7("");
+    bbSetInputIn8("");
+    bbSetInputIn9("");
+  }
+  
+  
+  
+  void StringSelect::DoProcess()
+  {
+    if (bbGetInputIn()==0) bbSetOutputOut( bbGetInputIn0() );
+    else if (bbGetInputIn()==1) bbSetOutputOut( bbGetInputIn1() );
+    else if (bbGetInputIn()==2) bbSetOutputOut( bbGetInputIn2() );
+    else if (bbGetInputIn()==3) bbSetOutputOut( bbGetInputIn3() );
+    else if (bbGetInputIn()==4) bbSetOutputOut( bbGetInputIn4() );
+    else if (bbGetInputIn()==5) bbSetOutputOut( bbGetInputIn5() );
+    else if (bbGetInputIn()==6) bbSetOutputOut( bbGetInputIn6() );
+    else if (bbGetInputIn()==7) bbSetOutputOut( bbGetInputIn7() );
+    else if (bbGetInputIn()==8) bbSetOutputOut( bbGetInputIn8() );
+    else if (bbGetInputIn()==9) bbSetOutputOut( bbGetInputIn9() );
+    
+  }
 }
 // EO namespace bbstd
 
index 8bafeba58e4a7fef2ec57c77cff7b3b5ea150254..9bdf09fa52b7c756e9d4b2b99c089876f7c5289b 100644 (file)
@@ -10,25 +10,25 @@ namespace bbstd
     : 
     public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(StringSelect,bbtk::AtomicBlackBox);
-      BBTK_DECLARE_INPUT(In,int);
-      BBTK_DECLARE_INPUT(In0,std::string);
-      BBTK_DECLARE_INPUT(In1,std::string);
-      BBTK_DECLARE_INPUT(In2,std::string);
-      BBTK_DECLARE_INPUT(In3,std::string);
-      BBTK_DECLARE_INPUT(In4,std::string);
-      BBTK_DECLARE_INPUT(In5,std::string);
-      BBTK_DECLARE_INPUT(In6,std::string);
-      BBTK_DECLARE_INPUT(In7,std::string);
-      BBTK_DECLARE_INPUT(In8,std::string);
-      BBTK_DECLARE_INPUT(In9,std::string);
-      BBTK_DECLARE_OUTPUT(Out,std::string);
+    BBTK_BLACK_BOX_INTERFACE(StringSelect,bbtk::AtomicBlackBox);
+    BBTK_DECLARE_INPUT(In,int);
+    BBTK_DECLARE_INPUT(In0,std::string);
+    BBTK_DECLARE_INPUT(In1,std::string);
+    BBTK_DECLARE_INPUT(In2,std::string);
+    BBTK_DECLARE_INPUT(In3,std::string);
+    BBTK_DECLARE_INPUT(In4,std::string);
+    BBTK_DECLARE_INPUT(In5,std::string);
+    BBTK_DECLARE_INPUT(In6,std::string);
+    BBTK_DECLARE_INPUT(In7,std::string);
+    BBTK_DECLARE_INPUT(In8,std::string);
+    BBTK_DECLARE_INPUT(In9,std::string);
+    BBTK_DECLARE_OUTPUT(Out,std::string);
     BBTK_PROCESS(DoProcess);
     void DoProcess();
-
+    
   protected:
     virtual void bbUserConstructor();
-
+    
   };
   //=======================================================================
 
index 9ab6b06f593af95114f6268d18993069f65bad95..af90ff3e1f0d8c2cdb56bac502651529e9a4a013 100644 (file)
@@ -6,8 +6,8 @@ namespace bbstd
 {
 
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringTo,
-                                              bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringTo,
+                                        bbtk::AtomicBlackBox);
   //====================================================================
 
   //====================================================================
index 49e672c80de4ffb2aff461f52065bfab0cdcc0e3..61a8d5793377d3742df755035f01e56f555a40a8 100644 (file)
@@ -10,9 +10,9 @@ namespace bbstd
   template <class T>
   class StringTo : public bbtk::AtomicBlackBox
   {  
-    BBTK_USER_BLACK_BOX_INTERFACE(StringTo,bbtk::AtomicBlackBox);
-       BBTK_DECLARE_INPUT(In,std::string);
-       BBTK_DECLARE_OUTPUT(Out,T);
+    BBTK_TEMPLATE_BLACK_BOX_INTERFACE(StringTo,bbtk::AtomicBlackBox,T);
+    BBTK_DECLARE_INPUT(In,std::string);
+    BBTK_DECLARE_OUTPUT(Out,T);
     BBTK_PROCESS(DoIt);
     void DoIt(); 
   };
@@ -20,7 +20,7 @@ namespace bbstd
 
   //=================================================================  
   // BlackBox description
-  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringTo);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringTo,bbtk::AtomicBlackBox);
   BBTK_NAME("StringTo"+bbtk::HumanTypeName<T>());
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_DEFAULT_ADAPTOR();
index 18ed459460cf0a8d8b4a48f8dc12651db98209e4..0d1f50639f1a35a7fa16b37783c006fca43f4cf0 100644 (file)
@@ -5,8 +5,8 @@
 namespace bbstd
 {
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringToVector,
-                                             bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringToVector,
+                                        bbtk::AtomicBlackBox);
   //====================================================================
   
   
index bd5d9f2ce0bcd8f171798874b8e5cf5d8a2df58f..31305d3f345e3ad67bc162a820290da369984ea7 100644 (file)
@@ -10,7 +10,7 @@ namespace bbstd
   template <class T>
   class StringToVector : public bbtk::AtomicBlackBox
   {  
-    BBTK_USER_BLACK_BOX_INTERFACE(StringToVector,bbtk::AtomicBlackBox);
+    BBTK_TEMPLATE_BLACK_BOX_INTERFACE(StringToVector,bbtk::AtomicBlackBox,T);
     BBTK_DECLARE_INPUT(In,std::string);
     BBTK_DECLARE_OUTPUT(Out,std::vector<T>);
     BBTK_PROCESS(DoIt);
@@ -21,7 +21,7 @@ namespace bbstd
 
   //=================================================================
   // BlackBox description
-  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringToVector);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringToVector,bbtk::AtomicBlackBox);
   BBTK_NAME("StringTo"+bbtk::HumanTypeName<std::vector<T> >());
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_DEFAULT_ADAPTOR();
index 75022c68765434926a66851622eda3a65f8c98d0..49823491f69863be59d88bb39e6dc67ad6168fca 100644 (file)
@@ -7,8 +7,8 @@ namespace bbstd
 {
 
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
-                                              bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
+                                        bbtk::AtomicBlackBox);
   //====================================================================
   
   //====================================================================
index b69312df677e4fda158c2127df48b75e2306406e..f1be738a19c38fe678b6635f3673f16e4234d3a8 100644 (file)
@@ -10,9 +10,9 @@ namespace bbstd
   template <class T>
   class ToString : public bbtk::AtomicBlackBox
   {  
-    BBTK_USER_BLACK_BOX_INTERFACE(ToString,bbtk::AtomicBlackBox);
-      BBTK_DECLARE_INPUT(In,T);
-      BBTK_DECLARE_OUTPUT(Out,std::string);
+    BBTK_TEMPLATE_BLACK_BOX_INTERFACE(ToString,bbtk::AtomicBlackBox,T);
+    BBTK_DECLARE_INPUT(In,T);
+    BBTK_DECLARE_OUTPUT(Out,std::string);
     BBTK_PROCESS(DoIt);
     void DoIt(); 
   };
@@ -20,7 +20,7 @@ namespace bbstd
 
   //=================================================================
   // BlackBox description
-  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ToString);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ToString,bbtk::AtomicBlackBox);
   BBTK_NAME(bbtk::HumanTypeName<T>()+"ToString");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_DEFAULT_ADAPTOR();
index cd9d96a7fb350d9878ab75390c9912a1a557c0b9..d6c164d77653e15871eff79f98d440f7730ab862 100644 (file)
@@ -5,8 +5,8 @@
 namespace bbstd
 {
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(VectorToString,
-                                             bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(VectorToString,
+                                        bbtk::AtomicBlackBox);
   //====================================================================
   
   
index 96816d7fb2196fb510a52a901b492277ed0d9e3f..0a48b6cab6011b30dc6d79f27f5d786e24b47aee 100644 (file)
@@ -10,10 +10,10 @@ namespace bbstd
   template <class T>
   class VectorToString : public bbtk::AtomicBlackBox
   {  
-    BBTK_USER_BLACK_BOX_INTERFACE(VectorToString,bbtk::AtomicBlackBox);
-      BBTK_DECLARE_INPUT(In,std::vector<T>);
-      BBTK_DECLARE_INPUT(Separator,std::string);
-      BBTK_DECLARE_OUTPUT(Out,std::string);
+    BBTK_TEMPLATE_BLACK_BOX_INTERFACE(VectorToString,bbtk::AtomicBlackBox,T);
+    BBTK_DECLARE_INPUT(In,std::vector<T>);
+    BBTK_DECLARE_INPUT(Separator,std::string);
+    BBTK_DECLARE_OUTPUT(Out,std::string);
     BBTK_PROCESS(DoIt);
     void DoIt(); 
     virtual void bbUserConstructor();
@@ -22,7 +22,7 @@ namespace bbstd
 
   //=================================================================
   // BlackBox description
-  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString);
+  BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString,bbtk::AtomicBlackBox);
   BBTK_NAME(bbtk::HumanTypeName<std::vector<T> >()+"ToString");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_DEFAULT_ADAPTOR();
index 5bcdd96d66265234444f5db65b82113c115aa303..3935d1a8f049c64c100116d1422dd8ef34e63bf0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkImageDataToString.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/15 08:46:19 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,8 +39,8 @@ namespace bbtk
 namespace bbstd
 {
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
-                                             bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
+                                        bbtk::AtomicBlackBox);
   //====================================================================
   
   
index fcb77af4b0fc161e71bcfcb85ee2878516596acd..6f46cf34b02d28739e6ff816e22b15262d92d34b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkImagePlanes.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/01 14:26:22 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -32,8 +32,8 @@
 namespace bbstd
 {
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
-                                              bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
+                                         bbtk::AtomicBlackBox);
   //====================================================================
 
 }
@@ -56,7 +56,7 @@ namespace bbvtk
 
 
    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImagePlanes)
-   BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
+   BBTK_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
 
 
 
index 863ca66a42dc2329df6cd4284459cd6b315b2f62..df253077ee0e91a14699e756fa59ec458d731ef7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkImagePlanes.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -58,7 +58,7 @@ namespace bbvtk
   class /*BBTK_EXPORT*/ ImagePlanes : public bbtk::AtomicBlackBox
   { 
   public:
-    BBTK_USER_BLACK_BOX_INTERFACE(ImagePlanes,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(ImagePlanes,bbtk::AtomicBlackBox);
     //    BBTK_DECLARE_INPUT(Contour,int);
     BBTK_DECLARE_INPUT(In,vtkImageData *);
     BBTK_DECLARE_OUTPUT(PlaneX,vtkImagePlaneWidget*);
index 782c00efc2e8c01d25bd9350570b527b11301aca..3e4e55f32979a9f56d9f8abbdb86cbae3de24272 100644 (file)
@@ -4,8 +4,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkIsoSurfaceExtractor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/19 13:30:18 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -32,7 +32,7 @@
 namespace bbvtk
 {
    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,IsoSurfaceExtractor)
-   BBTK_USER_BLACK_BOX_IMPLEMENTATION(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
+   BBTK_BLACK_BOX_IMPLEMENTATION(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
 
    void IsoSurfaceExtractor::bbUserConstructor() 
    { 
index 5cebfec8b5e4c4a585a2f54d0df34c871813c9af..8e34cf209f5cbc1e5ddffa778439835edd6a6a26 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkIsoSurfaceExtractor.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -59,7 +59,7 @@ namespace bbvtk
     vtkActor          *vtkactor; 
     
     
-    BBTK_USER_BLACK_BOX_INTERFACE(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
     
     BBTK_DECLARE_INPUT(In,vtkImageData *);
     //    BBTK_DECLARE_INPUT(InVtkObject,vtkObject *);
index 708d19431b61355f3658b0abf66de17efa41472f..be2a7d49c54f218c7a53f37d0ffd471c420e54c6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkMIPCreator.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/19 13:30:18 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -33,7 +33,7 @@ namespace bbvtk
 
 
    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MIPCreator)
-   BBTK_USER_BLACK_BOX_IMPLEMENTATION(MIPCreator,bbtk::AtomicBlackBox);
+   BBTK_BLACK_BOX_IMPLEMENTATION(MIPCreator,bbtk::AtomicBlackBox);
 
 
 
index cf04d7952f20ca457cfd19391d51bbd6f8d6d841..28f43583f28ecfe32822c7f114e9aca6a96b8297 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkMIPCreator.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -54,7 +54,7 @@ namespace bbvtk
   class /*BBTK_EXPORT*/ MIPCreator : public bbtk::AtomicBlackBox
   { 
   public:
-    BBTK_USER_BLACK_BOX_INTERFACE(MIPCreator,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(MIPCreator,bbtk::AtomicBlackBox);
     //    BBTK_DECLARE_INPUT(Contour,int);
     BBTK_DECLARE_INPUT(In,vtkImageData *);
     BBTK_DECLARE_INPUT(Shift,int);
index 98dd19e72b9fd05c08492d3b9c42596815db6e81..49d1f1da6f489d1fabb34b1681dffc2efea72802 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkMarchingCubes.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/13 08:21:38 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,7 +30,7 @@ namespace bbvtk
 {
 
    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MarchingCubes)
-   BBTK_USER_BLACK_BOX_IMPLEMENTATION(MarchingCubes,bbtk::AtomicBlackBox);
+   BBTK_BLACK_BOX_IMPLEMENTATION(MarchingCubes,bbtk::AtomicBlackBox);
 
 } // EO namespace bbvtk
 
index b281f7ef4e5eade886f424d0fb95d48a035387d4..6ad955504ee51dc1d4b282b84aafa03584be3af1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkMarchingCubes.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,7 +49,7 @@ namespace bbvtk
     public bbtk::AtomicBlackBox,
     public vtkMarchingCubes
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(MarchingCubes,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(MarchingCubes,bbtk::AtomicBlackBox);
     
     BBTK_DECLARE_VTK_INPUT(vtkMarchingCubes,In,vtkImageData *);
     BBTK_DECLARE_VTK_OUTPUT(vtkMarchingCubes,Out,vtkPolyData *);
index 341c6e4af3e22c2a591d53ce122da5685b6f0d17..9b03e2d85c14785143d5bba8dacf3dd0a2205bfc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxColourSelector.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/21 10:09:11 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -31,7 +31,7 @@ namespace bbwx
 {
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ColourSelector);
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ColourSelector,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ColourSelector,bbtk::AtomicBlackBox);
 
   void ColourSelector::bbUserConstructor()
   {
index 885951d9ddf44a9c8ad5d609dd897bb1df2e3862..84d43187cd8c5fd9b699c1b4db0408245a66d25a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxColourSelector.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -46,7 +46,7 @@ namespace bbwx
   //=================================================================
   class /*BBTK_EXPORT*/ ColourSelector : public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(ColourSelector,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(ColourSelector,bbtk::AtomicBlackBox);
     BBTK_DECLARE_OUTPUT(Out,std::string);
     BBTK_PROCESS(Process);
 //    BBTK_CREATE_WIDGET(CreateWidget);
index bfb48b09ccc0c8f3680ffeb57ef25c4e89353f17..0280ac2ddd8db30896960c9310db6e6a3450396d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxColourSelectorButton.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/10 06:24:13 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -101,7 +101,7 @@ void wxColourPickerCtrlWidget::UpdateBox()
 
   //--------------------------------------------------------------------------
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(ColourSelectorButton,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(ColourSelectorButton,bbtk::WxBlackBox);
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ColourSelectorButton);
   
   void ColourSelectorButton::bbUserConstructor() 
index 4d51d1a8e1c73bb1853a9d5387876ffb77c7c285..22dd10193913eadedb0866696affa9aedd387c39 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxColourSelectorButton.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -80,7 +80,7 @@ private:
 // The black box
   class /*BBTK_EXPORT*/ ColourSelectorButton : public bbtk::WxBlackBox
   {    
-    BBTK_USER_BLACK_BOX_INTERFACE(ColourSelectorButton,bbtk::WxBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(ColourSelectorButton,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(In,std::string);
     BBTK_DECLARE_OUTPUT(Out,std::string);
     BBTK_PROCESS(Process);
index 2b943b2edbf278d48c3cd512f8bbf58b6638a3bf..e48681db7cfc3525e08e6396d5d4d36fdc2fbfb8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxCommandButton.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/26 14:47:37 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 
   l'Image). All rights reserved. See Doc/License.txt or
@@ -68,12 +68,10 @@ namespace bbwx
   void CommandButtonWidget::OnCommandButton( wxEvent& )
   {
     // Look for the interpreter
-      bbtk::Interpreter* I = 0;
+    bbtk::Interpreter::Pointer I;
       if (mBox->bbGetParent() != 0) 
        {
-         bbtk::Factory* f = 
-           ((bbtk::ComplexBlackBoxDescriptor*)mBox->bbGetParent()
-            ->bbGetDescriptor())->GetFactory();
+         bbtk::Factory::Pointer f = boost::dynamic_pointer_cast<bbtk::ComplexBlackBoxDescriptor>(mBox->bbGetParent()->bbGetDescriptor())->GetFactory();
          if ((f != 0)&&
              (f->GetExecuter()))
            {
@@ -83,7 +81,7 @@ namespace bbwx
       if (I==0) 
        {
          //      bbtkError("ExecBbiCommand::DoProcess() : could not find interpreter");
-         I = new bbtk::Interpreter();
+         I = bbtk::Interpreter::New();
        }
       
       std::string commandstr(mBox->bbGetInputIn());
@@ -145,7 +143,7 @@ namespace bbwx
   //-------------------------------------------------------------------------- 
 
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(CommandButton,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(CommandButton,bbtk::WxBlackBox);
 
   void CommandButton::bbUserConstructor() 
   { 
index 9e58b1af9af64a99a694642dd98849a2f5f552cb..4702c6234c16661f4b7979b71bb70c8c857c032a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk 
   Module:    $RCSfile: bbwxCommandButton.h,v $ 
   Language:  C++ 
-  Date:      $Date: 2008/04/08 06:59:32 $ 
-  Version:   $Revision: 1.2 $ 
+  Date:      $Date: 2008/04/18 12:59:52 $ 
+  Version:   $Revision: 1.3 $ 
                                                                                  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 
   l'Image). All rights reserved. See Doc/License.txt or 
@@ -67,7 +67,7 @@ namespace bbwx
   class /*BBTK_EXPORT*/ CommandButton : public bbtk::WxBlackBox 
   {     
     friend class CommandButtonWidget;
-    BBTK_USER_BLACK_BOX_INTERFACE(CommandButton,bbtk::WxBlackBox); 
+    BBTK_BLACK_BOX_INTERFACE(CommandButton,bbtk::WxBlackBox); 
     BBTK_DECLARE_INPUT(In, std::string );      
     BBTK_DECLARE_INPUT(Label, std::string ); 
     BBTK_DECLARE_INPUT(Colour, std::vector<double> );  
index a0b4f5c7a6b4a3c450acf5bb7d483cff445963d0..4ac2edb66a92f153d3486bc50468aec9a758277c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxDirectorySelector.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/17 07:04:09 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -35,7 +35,7 @@ namespace bbwx
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,DirectorySelector);
   
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(DirectorySelector,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(DirectorySelector,bbtk::AtomicBlackBox);
 
 
   void DirectorySelector::Process() 
index b4f175323ab94681ca6735691d6b6c4480161e54..82bfe638869b47fbd8e5dc67b423d08439341088 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxDirectorySelector.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,7 +49,7 @@ namespace bbwx
   //=================================================================
   class /*BBTK_EXPORT*/ DirectorySelector : public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(DirectorySelector,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(DirectorySelector,bbtk::AtomicBlackBox);
     BBTK_DECLARE_INPUT(Title,std::string);
     BBTK_DECLARE_INPUT(Message,std::string);
     BBTK_DECLARE_INPUT(DefaultDir,std::string);
index 53e3ee3a47bd8b40e31daa76189c3d1170807917..4a049c54c1f4785b886e51c34355f29faa9f3c91 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxFileSelector.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/15 12:47:18 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,7 +36,7 @@ namespace bbwx
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,FileSelector);
   
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(FileSelector,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(FileSelector,bbtk::AtomicBlackBox);
 
 
   void FileSelector::Process() 
index 836bf44b40d85fd35ac803ad0758ff70c01b39e6..051754b165aa242469ae72db3b4de2b3d6bc7a0a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxFileSelector.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,7 +49,7 @@ namespace bbwx
   //=================================================================
   class /*BBTK_EXPORT*/ FileSelector : public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(FileSelector,bbtk::AtomicBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(FileSelector,bbtk::AtomicBlackBox);
     BBTK_DECLARE_INPUT(Title,std::string);
     BBTK_DECLARE_INPUT(Message,std::string);
     BBTK_DECLARE_INPUT(DefaultDir,std::string);
index 5b3dd2060f5b32bb7f6514e7ec339ad680cc049c..13bf00602c60883ca059d14ea0cfc668aff581fd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxInputText.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/15 12:47:18 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -106,7 +106,7 @@ namespace bbwx
   //--------------------------------------------------------------------------
 
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WxBlackBox);
 
 
 
index 0db6f4e32ccdae1c1b736f93e7205d9aeb15f172..18226a73cd9438b6dcc2f063162f07503c830a76 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxInputText.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -78,7 +78,7 @@ namespace bbwx
   class /*BBTK_EXPORT*/ InputText : public bbtk::WxBlackBox
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(InputText,bbtk::WxBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(InputText,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(In,std::string);
     BBTK_DECLARE_INPUT(Title,std::string);
     BBTK_DECLARE_OUTPUT(Out,std::string);
index 67404621f4d1cceadcc027c2621563819485aeee..d2289d730e1401a519c5d79a4c621030ea73cbf7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxLayoutLine.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/10 10:01:15 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:52 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -31,7 +31,7 @@
 namespace bbwx
 {
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx, LayoutLine);
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(LayoutLine,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(LayoutLine,bbtk::WxBlackBox);
   
   void LayoutLine::bbUserConstructor()
   {
index a9e99097eadf48bce34077f5d944b432784914b5..952941dc8449305b9245dc2810992e994a7c5e73 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxLayoutLine.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,7 +49,7 @@ namespace bbwx
   class /*BBTK_EXPORT*/ LayoutLine : public bbtk::WxBlackBox
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(LayoutLine,bbtk::WxBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(LayoutLine,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(Widget1,wxWindow*);
     BBTK_DECLARE_INPUT(Widget2,wxWindow*);
     BBTK_DECLARE_INPUT(Widget3,wxWindow*);
index 45750741d263c9d51661e0acd260d1729a6c8442..1f9e079e2d34f275e275453766cbfbf94a83451e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxLayoutSplit.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/15 12:24:43 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -31,7 +31,7 @@
 namespace bbwx
 {
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,LayoutSplit);
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::WxBlackBox);
 
   void LayoutSplit::bbUserConstructor()
   {
index 32424b36b67808a5ec730d13dc06acba4fce6f3d..9e214717b4eb3349f4a571328ffaaef1866846ac 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxLayoutSplit.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -46,7 +46,7 @@ namespace bbwx
   class LayoutSplit : public bbtk::WxBlackBox
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(LayoutSplit,bbtk::WxBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(LayoutSplit,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(Widget1,wxWindow*);
     BBTK_DECLARE_INPUT(Widget2,wxWindow*);
     BBTK_DECLARE_INPUT(Orientation,std::string);
index b61b23c1b8998a01a5b942a32cd7171e6fd2a694..d6cd1de8874e7a7db40800aa3cbc3dd3dc1bc007 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxLayoutTab.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/19 18:31:36 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,7 +36,7 @@ namespace bbwx
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx , LayoutTab);
   
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(LayoutTab,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(LayoutTab,bbtk::WxBlackBox);
   
        void LayoutTab::bbUserConstructor() 
        { 
index 68278531bed0903b463f9152d0687cf39c52b138..5049b9b2ab3d259b3a47949e7c94693920b8ce69 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxLayoutTab.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,7 +49,7 @@ namespace bbwx
   class /*BBTK_EXPORT*/ LayoutTab : public bbtk::WxBlackBox
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(LayoutTab,bbtk::WxBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(LayoutTab,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(Widget1,wxWindow*);
     BBTK_DECLARE_INPUT(Widget2,wxWindow*);
     BBTK_DECLARE_INPUT(Widget3,wxWindow*);
index f415c665bc522f22a75c161593b20f0e6637da60..4a23029b71289106f1291c456133fc7c8091c00a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxRadioButton.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/14 20:26:54 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -139,7 +139,7 @@ namespace bbwx
   //--------------------------------------------------------------------------
 
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
 
 
   void RadioButton::bbUserConstructor() 
index f6764e49231d45b84ca2ec517de64213da6994ec..c6c4b7ae3bb41c867fbe46681471f0f40893d1ca 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxRadioButton.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -79,7 +79,7 @@ namespace bbwx
   class /*BBTK_EXPORT*/ RadioButton : public bbtk::WxBlackBox
   {
 
-    BBTK_USER_BLACK_BOX_INTERFACE(RadioButton,bbtk::WxBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(RadioButton,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(In,int);
     BBTK_DECLARE_INPUT(In0,std::string);
     BBTK_DECLARE_INPUT(In1,std::string);
index 192553bd07469ac26b9e17fcf34ad23c34c20390..5345a005150e3292de99bd7f5ff2ed35fba62cd7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxSlider.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/10 12:28:43 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -326,7 +326,7 @@ namespace bbwx
   //--------------------------------------------------------------------------
 
   //--------------------------------------------------------------------------
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::WxBlackBox);
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,Slider);
   
   //--------------------------------------------------------------------------
index 33c44baf1b37b2bf47b71e42e608ffc05b37f385..f061465ccc6f7ee550cc7946c348a1cf6e8bb023 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxSlider.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:32 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -111,7 +111,7 @@ namespace bbwx
   class /*BBTK_EXPORT*/ Slider : public bbtk::WxBlackBox
   {
     
-    BBTK_USER_BLACK_BOX_INTERFACE(Slider,bbtk::WxBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(Slider,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(In,int);
     BBTK_DECLARE_INPUT(Min,int);
     BBTK_DECLARE_INPUT(Max,int);
index 43a20b31793a42e8af7f6969589afb46bbd1244c..a6ecfa24a8c843b6310cb655c39acd4cf2011718 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer2D.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/10 12:28:44 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -162,7 +162,7 @@ namespace bbwxvtk
   //--------------------------------------------------------------------------
 
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(Viewer2D,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(Viewer2D,bbtk::WxBlackBox);
 
 
   void Viewer2D::Process() 
index 34d5d5504ea26769d84ded525b9b679f4bc92e25..1f7dc824343144bfad1a0e75385d7a9429cfbd17 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer2D.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:33 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -74,7 +74,7 @@ namespace bbwxvtk
   
   class /*BBTK_EXPORT*/ Viewer2D : public bbtk::WxBlackBox
   {    
-    BBTK_USER_BLACK_BOX_INTERFACE(Viewer2D,bbtk::WxBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(Viewer2D,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(Slice,int);
     BBTK_DECLARE_INPUT(Orientation,int);
     BBTK_DECLARE_INPUT(In,vtkImageData *);
index 394e35341129eb7f92785d087ba5b6a2956462d0..4f057191e11b4f4425634c1f4595aa5f71fc34ce 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer3D.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/01 14:26:23 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -110,7 +110,7 @@ namespace bbwxvtk
   //--------------------------------------------------------------------------
 
 
-  BBTK_USER_BLACK_BOX_IMPLEMENTATION(Viewer3D,bbtk::WxBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(Viewer3D,bbtk::WxBlackBox);
 
   void Viewer3D::bbUserConstructor() 
   { 
index 24a0a3c8ac4d377b0d983c9e3c549e5dbc64629c..a9f441f8047abc647d8aee7e86d2768341386180 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer3D.h,v $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:33 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/04/18 12:59:53 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -71,7 +71,7 @@ namespace bbwxvtk
   
   class /*BBTK_EXPORT*/ Viewer3D : public bbtk::WxBlackBox
   {    
-    BBTK_USER_BLACK_BOX_INTERFACE(Viewer3D,bbtk::WxBlackBox);
+    BBTK_BLACK_BOX_INTERFACE(Viewer3D,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(In1, vtkProp3D *);
     BBTK_DECLARE_INPUT(In2, vtkProp3D *);
     BBTK_DECLARE_INPUT(In3, vtkProp3D *);
index 21c8a90e006841c51cc2068fa64edc164a837696..f60f93c69d6ce515c45cd39706215963fe40dab2 100644 (file)
@@ -8,8 +8,8 @@
 namespace bbstd
 {
   //====================================================================
-  BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
-                                              bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
+                                         bbtk::AtomicBlackBox);
   //====================================================================