]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkExecuter.cxx
#2536 BBTK Feature New Normal wt-version Package
[bbtk.git] / kernel / src / bbtkExecuter.cxx
index fe1e36d98538b4a0a85777f6e18e2c29be6eabc9..bf51fe564d3a1b644ee850f9bbc044d9b3abfa08 100644 (file)
@@ -1,20 +1,40 @@
+/*
+ # ---------------------------------------------------------------------
+ #
+ # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+ #                        pour la SantÈ)
+ # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+ # Previous Authors : Laurent Guigues, Jean-Pierre Roux
+ # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+ #
+ #  This software is governed by the CeCILL-B license under French law and
+ #  abiding by the rules of distribution of free software. You can  use,
+ #  modify and/ or redistribute the software under the terms of the CeCILL-B
+ #  license as circulated by CEA, CNRS and INRIA at the following URL
+ #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ #  or in the file LICENSE.txt.
+ #
+ #  As a counterpart to the access to the source code and  rights to copy,
+ #  modify and redistribute granted by the license, users are provided only
+ #  with a limited warranty  and the software's author,  the holder of the
+ #  economic rights,  and the successive licensors  have only  limited
+ #  liability.
+ #
+ #  The fact that you are presently reading this means that you have had
+ #  knowledge of the CeCILL-B license and that you accept its terms.
+ # ------------------------------------------------------------------------ */
+
+
 /*=========================================================================
-                                                                                
   Program:   bbtk
-  Module:    $RCSfile: bbtkExecuter.cxx,v $ $
+  Module:    $RCSfile: bbtkExecuter.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/05 12:16:55 $
-  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
-  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.
-                                                                                
+  Date:      $Date: 2012/11/16 08:49:01 $
+  Version:   $Revision: 1.34 $
 =========================================================================*/
+
+                                                                      
+
 /**
  *  \file 
  *  \brief class Executer: level 0 of script execution (code)
 #include "bbtkMessageManager.h"
 #include "bbtkFactory.h"
 #include "bbtkUtilities.h"
+//#include "bbtkWx.h"
 #include <fstream>
 
-#ifdef _USE_WXWIDGETS_
+#ifdef USE_WXWIDGETS
 #include <wx/textdlg.h>
 #endif
 
 #include "bbtkConfigurationFile.h"
 
 namespace bbtk
-{  
-/**
- *  
- */
+{
+  //=======================================================================
+  Executer::Pointer Executer::New()
+  {
+    bbtkDebugMessage("object",9,"Executer::New()"<<std::endl);
+    return MakePointer(new Executer());
+  }
+  //=======================================================================
+
+  //=======================================================================
   Executer::Executer()
-    : mPackage(0),
-      mRoot(0),
-      mNoExecMode(false),
-      mDialogMode(NoDialog)
+    : 
+    mFactory(),
+    mRootPackage(),
+    mRootCBB(),
+    mNoExecMode(false),
+    mDialogMode(NoDialog),
+    mNoErrorMode(false)
   {
-    //VirtualExec();
-    
-    bbtkDebugMessageInc("Core",9,"Executer::Executer()" <<std::endl);
+    bbtkDebugMessage("object",2,"==> Executer()" <<std::endl);
+    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("Core",9);
-  } 
+    bbtkDebugMessage("object",2,"<== Executer()" <<std::endl);
+  }
+  //=======================================================================
 
-/**
- *  
- */
+  //=======================================================================
   Executer::~Executer()
   {
-     bbtkDebugMessageInc("Core",9,"Executer::~Executer()" <<std::endl);
-     if (mRoot) 
-     {
-        mPackage->UnRegisterBlackBox("workspace");
-        delete mRoot;    
-     }
-     if (mPackage) 
-     {
-        GetGlobalFactory()->UnLoadPackage("user");
-     }
-     bbtkDebugDecTab("Core",9);
+     bbtkDebugMessage("object",2,"==> ~Executer()" <<std::endl);
+     mOpenDefinition.clear();
+     mOpenPackage.clear();
+     mFactory->Reset();
+     mFactory.reset();
+     bbtkDebugMessage("object",2,"<== ~Executer()" <<std::endl);
   }
-  
+  //=======================================================================
+
+  //=======================================================================
+   /// Loads a package
+    void Executer::LoadPackage(const std::string &name )
+   {
+     GetFactory()->LoadPackage(name);
+   }
+  //=======================================================================
+
+  //=======================================================================
+    /// Unloads a package
+    void Executer::UnLoadPackage(const std::string &name )
+    {
+      GetFactory()->UnLoadPackage(name);
+    }
+  //=======================================================================
 
-/**
- *  
- */
+  //=======================================================================
   void Executer::Reset()
   {
-    bbtkDebugMessageInc("Core",9,"Executer::Reset()" <<std::endl);
+    bbtkDebugMessage("kernel",9,"==> Executer::Reset()" <<std::endl);
 
-    // 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 (mRoot) 
-    {
-       mPackage->UnRegisterBlackBox(mRoot->GetTypeName());
-       delete mRoot;    
-    }
-    if (mPackage) 
-    {
-       GetGlobalFactory()->UnLoadPackage("user");
-    }
-    GetGlobalFactory()->Reset();
+    //    GetFactory()->Check();
+    mOpenDefinition.clear();
+    mOpenPackage.clear();
+
+    //  Wx::DestroyTopWindow();
+
+    GetFactory()->Reset();
+#if(USE_WXWIDGETS)
+    Wx::ProcessPendingEvents();
+#endif
+
     // Create user package
-    mPackage = new Package("user","internal to bbi",
-                           "User defined black boxes",
-                           "",
-                           BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
+    Package::Pointer p =
+      Package::New("user","internal","User defined black boxes","");
+    // Insert the user package in the factory
+    GetFactory()->InsertPackage(p);
+    // And in the list of open packages
+    mOpenPackage.push_back(p);
+    mRootPackage = p;
+
     // Create user workspace
-    mRoot = new ComplexBlackBoxDescriptor("workspace"); //,f);
-    mRoot->AddToAuthor("bbi (internal)");
-    mRoot->AddToDescription("User's workspace");
-    mOpenDefinition.push_back(CBBDefinition(mRoot,"user"));
+    ComplexBlackBoxDescriptor::Pointer r = 
+      ComplexBlackBoxDescriptor::New("workspace"); 
+    //    mRootCBB->Reference();
+    r->SetFactory(GetFactory());
+    r->AddToAuthor("bbtk");
+    r->AddToDescription("User's workspace");
+    mOpenDefinition.push_back(CBBDefinition(r,"user"));
     // Register it into the user package
-    mPackage->RegisterBlackBox(mRoot);
-    // Insert the user package in the factory
-    InsertPackage(mPackage);
-    mOpenPackage.push_back(mPackage);
-    bbtkDebugDecTab("Core",9);
+    p->Register(r);
+    mRootCBB = r;
+
+    //    Object::PrintObjectListInfo();
+    //  GetFactory()->CheckPackages();
+    bbtkDebugMessage("kernel",9,"<== Executer::Reset()" <<std::endl);
   }
-  
+  //=======================================================================
+
+
+  //=======================================================================
   /// changes the workspace name
   void Executer::SetWorkspaceName( const std::string& n )
   {
-    mPackage->ChangeBlackBoxName( mRoot->GetTypeName(), n );
+    GetUserPackage()->ChangeDescriptorName( GetWorkspace()->GetTypeName(), n );
   }
-  
+  //=======================================================================
+
+  //=======================================================================
   void Executer::BeginPackage (const std::string &name)
   {
-     bbtkDebugMessageInc("Core",9,"Executer::BeginPackage(\""<<name<<"\")"
+     bbtkDebugMessage("kernel",9,"==> Executer::BeginPackage(\""<<name<<"\")"
                         <<std::endl);
-     Package* p;
+     Package::Pointer p;
      try 
       {
-       p = GetGlobalFactory()->GetPackage(name);
+         p = GetFactory()->GetPackage(name);
       }
     catch (Exception e)
       {
-       p = new Package(name,
-                       "",
-                       "",
-                       "",
-                       BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
-       InsertPackage(p);
+       p = Package::New(name,"","","");
+       GetFactory()->InsertPackage(p);
       }
      mOpenPackage.push_back(p);
+
+     bbtkDebugMessage("kernel",9,"<== Executer::BeginPackage(\""<<name<<"\")"
+                     <<std::endl);
   }
+  //=======================================================================
 
+  //=======================================================================
   void Executer::EndPackage()
   {
     if (mOpenPackage.size()>1) mOpenPackage.pop_back();
   }
+  //=======================================================================
 
+  //=======================================================================
   void Executer::Define (const std::string &name,
-                        const std::string &pack,
-                        const std::string &scriptfilename)
+                         const std::string &pack,
+                         const std::string &scriptfilename)
   {
-    bbtkDebugMessageInc("Core",9,"Executer::Define(\""<<name<<
-                       ","<<pack<<"\")" 
-                        <<std::endl);
+    bbtkDebugMessage("kernel",9,"==> Executer::Define(\""<<name<<
+                    ","<<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 ) );
     
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugMessage("kernel",9,"<== Executer::Define(\""<<name<<
+                    ","<<pack<<"\")"
+                    <<std::endl);
+  }
+  //=======================================================================
+
+  //=======================================================================
+  /// Sets the file name to use for the current definition
+  /// (Used to set it after the Define command)
+  void Executer::SetCurrentFileName (const std::string &name )
+  {
+    mOpenDefinition.back().box->SetScriptFileName(name);
   }
+  //=======================================================================
 
+       void Executer::SetTypeOfScript_Application ()
+       {
+               mOpenDefinition.back().box->SetTypeOfScript_Application();
+       }
+       
+       
+       
+  //=======================================================================
+  void Executer::Clear()
+  {
+    bbtkDebugMessage("kernel",9,"==> Executer::Clear()" <<std::endl);
+    GetCurrentDescriptor()->GetPrototype()->Clear();
+    bbtkDebugMessage("kernel",9,"<== Executer::Clear()" <<std::endl);
+  }
+  //=======================================================================
+
+  //=======================================================================
   void Executer::EndDefine ()
   {
-    bbtkDebugMessageInc("Core",9,"Executer::EndDefine(\""
-                        <<Current()->GetTypeName()<<"\")" 
-                        <<std::endl);
+    bbtkDebugMessage("kernel",9,"==> Executer::EndDefine(\""
+                    <<GetCurrentDescriptor()->GetTypeName()<<"\")" 
+                    <<std::endl);
     // Does current package exist ?
-    Package* p;
+    Package::Pointer p;
     std::string pname(mOpenDefinition.back().package);
     if (pname.size()>0)
-    {
-      try
       {
-           p = GetGlobalFactory()->GetPackage(pname);
+       try
+         {
+           p = GetFactory()->GetPackage(pname);
+         }
+       catch (Exception e)
+         {
+           p = Package::New(pname,"","","");
+           GetFactory()->InsertPackage(p);
+         }
       }
-      catch (Exception e)
+    else
       {
-            p = new Package(pname,
-                       "",
-                       "",
-                       "",
-                       BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
-           InsertPackage(p);
+       p = mOpenPackage.back().lock();
       }
-    }
-    else
-    {
-          p = mOpenPackage.back();
-    }
-    p->RegisterBlackBox(Current());
-
+    // Register the descriptor in the current package
+    p->Register(GetCurrentDescriptor());
+    
+    bbtkDebugMessage("kernel",9,"<== Executer::EndDefine(\""
+                    <<GetCurrentDescriptor()->GetTypeName()<<"\")" 
+                    <<std::endl);
     mOpenDefinition.pop_back();
   }
+  //======================================================================= 
 
+  //=======================================================================  
+  void Executer::Kind(const std::string& kind)
+  {
+    if (kind=="ADAPTOR")
+      {
+       GetCurrentDescriptor()->AddToCategory("adaptor");
+       GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::ADAPTOR);
+      }
+    else if (kind=="DEFAULT_ADAPTOR")
+      {
+       GetCurrentDescriptor()->AddToCategory("adaptor");
+       GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR);
+      }
+    if (kind=="GUI")
+      {
+       GetCurrentDescriptor()->AddToCategory("gui");
+       GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::GUI);
+      }
+    else if (kind=="DEFAULT_GUI")
+      {
+       GetCurrentDescriptor()->AddToCategory("gui");
+       GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_GUI);
+      }
+    else
+      {
+       bbtkError("Unknown box kind : '"<<kind<<"'. "
+                 <<"Valid kinds are 'ADAPTOR','DEFAULT_ADAPTOR',"
+                 <<"'GUI','DEFAULT_GUI'");
+      }
+  }
+  //=======================================================================
 
+  //=======================================================================
   void Executer::Create ( const std::string& nodeType, 
                           const std::string& nodeName)
   {
-     Current()->Add(nodeType,nodeName);
+     GetCurrentDescriptor()->Add(nodeType,nodeName);
   }
-  
+  //=======================================================================
 
-  /*
-    void Executer::Remove (const std::string &nodeName)
+  //=======================================================================
+  void Executer::Destroy(const std::string &boxName)
   {
-    // Current()->RemoveBlackBox(nodeName);
+    GetCurrentDescriptor()->Remove(boxName,true);
   }
-  */    
+  //=======================================================================
 
-/**
- *  
- */
-  void Executer::Connect (const std::string &nodeFrom, 
-                          const std::string &outputLabel, 
+  //=======================================================================
+  void Executer::Connect (const std::string &nodeFrom,
+                          const std::string &outputLabel,
                           const std::string &nodeTo, 
                           const std::string &inputLabel)
   {
-    Current()->Connect(nodeFrom, outputLabel, nodeTo, inputLabel);
+    GetCurrentDescriptor()->Connect(nodeFrom, outputLabel, nodeTo, inputLabel);
   }
+  //=======================================================================
 
- /**
- *  
- */ 
-  void Executer::Update (const std::string &nodeName) // would 'Execute' be more meaningfull ?
+  //=======================================================================
+  void Executer::Execute (const std::string &nodeName) 
   {
- // if in root
-     if (Current()==mRoot
   // if in root
+    if (GetCurrentDescriptor()==GetWorkspace()
      {
         if (!mNoExecMode) 
         {
-           Current()->GetPrototype()->bbGetBlackBox(nodeName)->bbExecute(true);
+           GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(nodeName)->bbExecute(true);
         }
      }
      else 
      {
-        Current()->AddToExecutionList(nodeName) ;
+        GetCurrentDescriptor()->AddToExecutionList(nodeName) ;
      }
   }
-    
-/**
- *  
- */
+  //=======================================================================
+
+  //=======================================================================
   void Executer::DefineInput ( const std::string &name,
                                const std::string &box,
                                const std::string &input,
                                const std::string& help)
   {
     // If the input is defined in the Root box
-    if (Current()==mRoot
+    if (GetCurrentDescriptor()==GetWorkspace()
       {
       // If the dialog mode is set to NoDialog
       // and the user passed the name in the Inputs map 
@@ -270,7 +386,7 @@ namespace bbtk
            std::cin >> ans;
            Set(box,input,ans);
         }
-       #ifdef _USE_WXWIDGETS_
+#ifdef USE_WXWIDGETS
        // If the dialog mode is set to GraphicalDialog
        // A dialog box is pop up
        else if (mDialogMode == GraphicalDialog) 
@@ -282,55 +398,53 @@ namespace bbtk
           mess += ")";
           std::string title(name);
           title += " ?";
-    
           std::string ans = wx2std ( wxGetTextFromUser( std2wx (mess), std2wx(title)));
           Set(box,input,ans); 
        }
 #endif
     }
 
-    Current()->DefineInput(name,box,input,help);
+    GetCurrentDescriptor()->DefineInput(name,box,input,help);
 
   }
-  
- /**
- *  
- */ 
+  //=======================================================================
+
+  //=======================================================================
    void Executer::DefineOutput ( const std::string &name,
                                  const std::string &box,
                                  const std::string &output,
                                  const std::string& help)
   {
-    Current()->DefineOutput(name,box,output,help);
+    GetCurrentDescriptor()->DefineOutput(name,box,output,help);
   }
+  //=======================================================================
 
-  /**
-   *  
-   */ 
+  //=======================================================================
   void Executer::Set (const std::string &box,
                       const std::string &input,
                       const std::string &value)
   {
-    BlackBox* b = Current()->GetPrototype()->bbGetBlackBox(box);
+    BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
     // Looks for the adaptor
 
-    if ( b->bbGetInputType(input) !=  typeid(std::string) ) 
+    if ( ( b->bbGetInputType(input) != typeid(bbtk::any<bbtk::thing>) )&&
+        ( b->bbGetInputType(input) != typeid(std::string) ) )
       {
-         BlackBox* a = /*mFactory->*/
-         NewAdaptor(typeid(std::string),
-                    b->bbGetInputType(input),
-                    "tmp");
+       BlackBox::Pointer a =
+          GetFactory()->NewAdaptor(typeid(std::string),
+                                   b->bbGetInputType(input),
+                                   "tmp");
          if (!a) 
-         {
-            bbtkError("No <"<<
-                      TypeName(b->bbGetInputType(input))
-                      <<"> to <std::string> found");
-         }
+          {
+            bbtkError("No <"<<
+                      TypeName(b->bbGetInputType(input))
+                      <<"> to <std::string> found");
+          }
          std::string v(value);
          a->bbSetInput("In",v);
          a->bbExecute();
          b->bbSetInput(input,a->bbGetOutput("Out"));
-         a->bbDelete();
+        //         a->Delete();
       }
     else 
       {
@@ -338,78 +452,86 @@ namespace bbtk
       b->bbSetInput(input,v);
       }
   }
+  //=======================================================================
 
-  /**
-   *  
-   */ 
+  //=======================================================================
   std::string Executer::Get(const std::string &box,
                             const std::string &output)
   {
-    BlackBox* b = Current()->GetPrototype()->bbGetBlackBox(box);
+    BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
     // Looks for the adaptor
     if (b->bbGetOutputType(output) != typeid(std::string)) 
       {
-      BlackBox* a = /*mFactory->*/
-          NewAdaptor(
-             b->bbGetOutputType(output),
-             typeid(std::string),
-             "tmp");
-      if (!a) 
-        {
-        bbtkError("No <"<<
-                   TypeName(b->bbGetOutputType(output))
-                   <<"> to <std::string> found");
-        }
+       BlackBox::Pointer a =
+          GetFactory()->NewAdaptor(
+                                  b->bbGetOutputType(output),
+                                  typeid(std::string),
+                                  "tmp");
+       if (!a) 
+         {
+           bbtkError("No <"<<
+                     TypeName(b->bbGetOutputType(output))
+                     <<"> to <std::string> found");
+         }
         b->bbExecute();
-
+       
         a->bbSetInput("In",b->bbGetOutput(output));
         a->bbExecute();
         std::string r = a->bbGetOutput("Out").unsafe_get<std::string>();
-       //std::string v = *((std::string*)a->bbGetOutput("Out")) ;
-       //   std::cout << a->bbGetOutput("Out").unsafe_get<std::string>() 
-       //             << std::endl;
-       //std::string v(value);
-       //b->bbSetInput(input,a->bbGetOutput("Out"));
-        a->bbDelete();
+       //std::string v = *((std::string*)a->bbGetOutput("Out")) ;
+       //   std::cout << a->bbGetOutput("Out").unsafe_get<std::string>() 
+       //             << std::endl;
+       //std::string v(value);
+       //b->bbSetInput(input,a->bbGetOutput("Out"));
+       //        a->bbDelete();
         return r;
       }
-    else 
+    else
       {
-       b->bbExecute();
-       return b->bbGetOutput(output).unsafe_get<std::string>();
-       // std::string v = *((std::string*)b->bbGetOutput(output)) ;
-       // std::cout << b->bbGetOutput("Out").unsafe_get<std::string>() 
-       //   << std::endl;
-       // b->bbSetInput(input,&v);
+       b->bbExecute();
+       return b->bbGetOutput(output).unsafe_get<std::string>();
+       // std::string v = *((std::string*)b->bbGetOutput(output)) ;
+       // std::cout << b->bbGetOutput("Out").unsafe_get<std::string>() 
+       //   << std::endl;
+       // b->bbSetInput(input,&v);
       }
   }
+  //=======================================================================
 
-
+  //=======================================================================
   void Executer::Author(const std::string &authorName)
   {
-    Current()->AddToAuthor(authorName,Current()==mRoot);
+    GetCurrentDescriptor()->AddToAuthor(authorName,GetCurrentDescriptor()==GetWorkspace());
   }
+  //=======================================================================
 
+  //=======================================================================
   void Executer::Category(const std::string &category)
   {
-    Current()->AddToCategory(category,Current()==mRoot);
+    GetCurrentDescriptor()->AddToCategory(category,GetCurrentDescriptor()==GetWorkspace());
   }
+  //=======================================================================
 
+  //=======================================================================
   void Executer::Description(const std::string &d)
   {
-     Current()->AddToDescription(d,Current()==mRoot);
+    GetCurrentDescriptor()->AddToDescription(d,GetCurrentDescriptor()==GetWorkspace());
   }
+  //=======================================================================
+
 
 
+  //=======================================================================
   /// prints the list of the boxes of the current descriptor
-  void Executer::PrintBoxes()
-  {  
-    bbtkMessageInc("Help",1,"The black box descriptor \""
-                   <<Current()->GetTypeName()<<"\" contains : "<<std::endl);
-    Current()->PrintBlackBoxes();
-    bbtkDecTab("Help",1);
+  void Executer::PrintHelpListBoxes()
+  {
+    bbtkMessage("help",1,"The black box descriptor \""
+               <<GetCurrentDescriptor()->GetTypeName()<<"\" contains : "<<std::endl);
+    GetCurrentDescriptor()->PrintBlackBoxes();
  }
+  //=======================================================================
 
+  //=======================================================================
   std::string Executer::ShowGraph(const std::string &nameblackbox, 
                                  const std::string &detailStr, 
                                  const std::string &levelStr,
@@ -420,99 +542,90 @@ namespace bbtk
   {
     int detail =       atoi(detailStr.c_str());
     int level  =       atoi(levelStr.c_str());
+         bool relative_link = true;
 
-    std::string filename_rootHtml (output_html) ;
-    std::string simplefilename_rootHtml ( Utilities::get_file_name(output_html));
-
-    bool relative_link = true;
-
-    // No output provided : automatic generation
-    if (output_html.length() == 0)
-      {
-       // Don't pollute the file store with  "doc_tmp" directories ...    
-       std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_doc_tmp();
-       
-       char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
-       
-       std::string directory = default_doc_dir; 
-       if (c != '/' && c !='\\') directory = directory + "/";
-       directory = directory +  "doc_tmp";    
-       
-       filename_rootHtml = directory + "/" + "User.html";
-       simplefilename_rootHtml = "User.html" ;
-
-       // Creating directory
-       std::string command0("mkdir \"" +directory + "\"");
-       system( command0.c_str() );
-
-       relative_link = false;
-      }
-
-
-    Package* p;
+    Package::Pointer p;
     try
     {
-          p = GetGlobalFactory()->GetPackage(nameblackbox);
+       p = GetFactory()->GetPackage(nameblackbox);
     }
     catch (Exception e)
     {
-          p = mPackage;
+      p = GetUserPackage();
     }
+         
+      std::string doc_path = bbtk::ConfigurationFile::GetInstance().Get_doc_path();
+      doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
+      doc_path += "bbdoc";
+      doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
+         
+         std::string pack_name(p->GetName());
+         std::string pack_path = doc_path + pack_name;
+         // Creating directory
+         if ( ! bbtk::Utilities::FileExists(pack_path) )
+         {
+                 std::string command("mkdir \"" +pack_path+ "\"");
+                 system( command.c_str() );
+         }
+         std::string pack_index(pack_path);
+         pack_index += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
+         pack_index += "index.html"; 
+         
+         
     // Generating documentation-help of workspace
-    p->SetDocURL(filename_rootHtml);
-    p->SetDocRelativeURL(simplefilename_rootHtml);
-
-    p->CreateHtmlPage(filename_rootHtml,"bbi","user package",custom_header,custom_title,detail,level,relative_link);
-
-    std::string page = filename_rootHtml;
+       p->SetDocURL(pack_index);
+    p->SetDocRelativeURL("index.html");
+       p->CreateHtmlPage(pack_index,"bbtk","user package",custom_header,custom_title,detail,level,relative_link);
+         
     /*
     try 
     {
-         ShowGraphTypes(nameblackbox);
+       ShowGraphTypes(nameblackbox);
     }
     catch (bbtk::Exception a)
     {
-         std::cout <<"EXC"<<std::endl;
-         page = ShowGraphInstances(nameblackbox,detail,level,system_display);
+       std::cout <<"EXC"<<std::endl;
+       page = ShowGraphInstances(nameblackbox,detail,level,system_display);
     }
     */
-    return page;
+    return pack_index;
   }
+  //=======================================================================
 
+  //=======================================================================
   /// Generate a png file with the actual pipeline (Graphviz-dot needed)
   std::string Executer::ShowGraphInstances(const std::string &nameblackbox, int detail, int level,
-                                   bool system_display)
+                                           bool system_display)
   {
 
-    BlackBox* blackbox=NULL;
+    BlackBox::Pointer blackbox;
     if (nameblackbox==".")
     {
-         blackbox=Current()->GetPrototype();
+       blackbox = GetCurrentDescriptor()->GetPrototype();
     }
-    else 
+    else
     {
-         blackbox = Current()->GetPrototype()->bbFindBlackBox(nameblackbox);
+       blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
     }
     
     std::string page;
 
     if (blackbox)
       {      
-       // Don't pollute the file store with  "doc_tmp" directories ...    
-       std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_doc_tmp();
+       // Don't pollute the file store with  "temp_dir" directories ...
+       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 directory = default_doc_dir; 
        if (c != '/' && c !='\\') directory = directory + "/";
 
-       directory = directory +  "doc_tmp"; 
-       
-       //std::string directory("doc_tmp");
+       directory = directory +  "temp_dir";
+       //std::string directory("temp_dir");
        std::string filename(directory + "/" + "bbtk_graph_pipeline");
        std::string filename_html(filename+".html");
        std::string command0("mkdir \""+directory + "\"");
 
-#if defined(_WIN32)  
+#if defined(_WIN32)
        std::string command2("start ");
 #else 
        std::string command2("gnome-open ");
@@ -533,9 +646,8 @@ namespace bbtk
              } else {
              s << "<center>" << blackbox->bbGetName()<< "</center>";
            } 
-
            blackbox->bbInsertHTMLGraph( s, detail, level, true, directory, false );
-           s << "</body></html>\n";      
+           s << "</body></html>\n";
          }
        s.close();
        
@@ -544,49 +656,169 @@ namespace bbtk
       } 
     else 
       {
-       bbtkMessageInc("Help",1,"No black box: \""
-                      <<nameblackbox<<"\" " <<std::endl);
-       
+       bbtkMessage("help",1,"No black box: \""
+                   <<nameblackbox<<"\" " <<std::endl);
       }
     return page;
   }
+  //=======================================================================
 
-void Executer::ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr)
+  //=======================================================================
+  void Executer::PrintHelpBlackBox(const std::string &nameblackbox, 
+                              const std::string &detailStr, 
+                              const std::string &levelStr)
   {
-       bool found=false;
+    bool found=false;
+    
+    int detail = atoi(detailStr.c_str());
+    int level  = atoi(levelStr.c_str());
+    BlackBox::Pointer blackbox;
+    if (nameblackbox.compare(".")==0)
+      {
+       blackbox=GetCurrentDescriptor()->GetPrototype();
+      } 
+    else 
+      {
+       blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
+      }
+    
+    if (blackbox)
+      {
+       found=true;
+       blackbox->bbPrintHelp(blackbox,detail,level); //,mFactory);
+      }
+    
+    if (!found) 
+      {
+       bbtkError("box with name '"  <<nameblackbox<<"' unknown");
+      }
+  }
+  //=======================================================================
 
-       int detail = atoi(detailStr.c_str());
-       int level  = atoi(levelStr.c_str());
-       BlackBox* blackbox=NULL;
-       if (nameblackbox.compare(".")==0)
-       {
-          blackbox=Current()->GetPrototype();
-       } else {
-          blackbox = Current()->GetPrototype()->bbFindBlackBox(nameblackbox);
-       }
+  //=======================================================================
+  /// sets the level of message
+  void Executer::SetMessageLevel(const std::string &kind,
+                                int level)
+  {
+    bbtk::MessageManager::SetMessageLevel(kind,level);
+  }
+  //=======================================================================
+
+  //=======================================================================
+  /// Prints help on the messages
+  void  Executer::HelpMessages()
+  {
+    bbtk::MessageManager::PrintInfo();
+  }
+  //=======================================================================
+
+  //=======================================================================
+  ///
+  void Executer::Print(const std::string &str)
+  {  
+    if (GetNoExecMode() &&  (GetCurrentDescriptor()==GetWorkspace()) ) return;
+    if (GetCurrentDescriptor()!=GetWorkspace()) return;
+
+    bbtkDebugMessage("kernel",9,"Executer::Print(\""<<str<<"\")"<<std::endl);
+
+ // TO DO :
+ // InterpretLine ("load std")
+ // InterpretLine("new ConcatStrings _C_ ") -> trouver un nom unique : # commande 
+ // InterpretLine("new Print _P_") 
+ // InterpretLine("connect _C_.Out _P_.In")
+ // int num = 1
+
+    std::vector<std::string> chains;
+    std::string delimiters("$");
 
-       if (blackbox)
+    // Skip delimiters at beginning.
+    std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
+    bool is_text = true;
+    if (lastPos>0) is_text = false;
+
+    // Find first delimiter.
+    std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
+
+    while (std::string::npos != pos || std::string::npos != lastPos)
+    {
+       if (is_text) 
        {
-          found=true;
-          blackbox->bbShowRelations(blackbox,detail,level); //,mFactory);
+          // Found a text token, add it to the vector.
+          chains.push_back(str.substr(lastPos, pos - lastPos));
+ // std::string token = str.substr(lastPos, pos - lastPos)
+ // InterpretLine("set _C_.In%num% %token%")
        }
-
-       if (!found) 
+       else 
        {
-          bbtkError("Blackbox Name not found.. <"  <<nameblackbox<<">");
+
+       // is an output (between $$) : decode 
+         std::string tok,box,output;
+         tok = str.substr(lastPos, pos - lastPos);
+         Utilities::SplitAroundFirstDot(tok,box,output);
+         chains.push_back( Get(box,output) );
+
+// InterpretLine("connect %tok% _C_.In%num%") 
+
        }
+        // Skip delimiters.  Note the "not_of"
+       lastPos = str.find_first_not_of(delimiters, pos);
+        // Find next delimiter
+       pos = str.find_first_of(delimiters, lastPos);
+    //
+       is_text = !is_text;
+// num ++;
+     }
+// InterpretLine("exec _P_")
+// if (IS_IN_WORKSPACE) InterpretLine("delete _C_; delete _P_");
+
+    std::vector<std::string>::iterator i;
+    for (i= chains.begin(); i!=chains.end(); ++i) 
+      {
+       Utilities::SubsBackslashN(*i);
+       bbtkMessage("output",1,*i);
+      }
+    bbtkMessage("output",1,std::endl);
   }
+  //==========================================================================
 
-  /*
-  /// sets the level of message
-  void Executer::Message(const std::string &kind,
-                         const std::string& level)
+  //==========================================================================
+  std::string Executer::GetObjectName() const
   {
-    int l;
-    sscanf(level.c_str(),"%d",&l);
-    bbtk::MessageManager::SetMessageLevel(kind,l);
+    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