]> Creatis software - bbtk.git/commitdiff
- Finished the Transcriptor
authorguigues <guigues>
Wed, 26 Mar 2008 14:47:35 +0000 (14:47 +0000)
committerguigues <guigues>
Wed, 26 Mar 2008 14:47:35 +0000 (14:47 +0000)
- created 2 apps :
  - bbs2cpp which translates a bbs script into a c++ code
  - bbc which translates and compiles a bbs script ending with an exe !

17 files changed:
kernel/appli/CMakeLists.txt
kernel/appli/bbc/CMakeLists.txt [new file with mode: 0644]
kernel/appli/bbc/CMakeLists.txt.in [new file with mode: 0644]
kernel/appli/bbc/bbc.sh.in [new file with mode: 0755]
kernel/appli/bbc/main.cxx.in [new file with mode: 0644]
kernel/appli/bbi/bbi.cxx
kernel/appli/bbs2cpp/CMakeLists.txt [new file with mode: 0644]
kernel/appli/bbs2cpp/bbs2cpp.cxx [new file with mode: 0644]
kernel/src/bbtkInterpreter.cxx
kernel/src/bbtkInterpreter.h
kernel/src/bbtkTranscriptor.cxx
kernel/src/bbtkTranscriptor.h
kernel/src/bbtkVirtualExec.h
kernel/src/bbtkWx.cxx
kernel/src/bbtkWx.h
packages/std/src/bbstdExecBbiCommand.cxx
packages/wx/src/bbwxCommandButton.cxx

index 0a02f7d9cb7847ad71f7ac59b5f6ec25a6b87a9e..44c49a70b9b3a8cb66bfe7823292e1c49ba89395 100644 (file)
@@ -22,3 +22,7 @@ SUBDIRS(bbCreateBlackBox)
 SUBDIRS(bbed)
 
 SUBDIRS(bbhelp)
+
+SUBDIRS(bbs2cpp)
+
+SUBDIRS(bbc)
diff --git a/kernel/appli/bbc/CMakeLists.txt b/kernel/appli/bbc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d121f00
--- /dev/null
@@ -0,0 +1,35 @@
+# Relative path to the data used by bbc from data root folder
+SET(bbc_DATA_REL_PATH_FROM_DATA kernel/bbc)
+# Relative path to the data used by bbc from bin folder
+SET(bbc_DATA_REL_PATH_FROM_BIN ../${BBTK_DATA_REL_PATH}/${bbc_DATA_REL_PATH_FROM_DATA})
+
+IF(UNIX)
+  # Build tree 
+  CONFIGURE_FILE(
+    ${CMAKE_CURRENT_SOURCE_DIR}/main.cxx.in
+    ${BBTK_DATA_BUILD_PATH}/${bbc_DATA_REL_PATH_FROM_DATA}/main.cxx.in
+    COPYONLY
+    )
+  CONFIGURE_FILE(
+    ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in
+    ${BBTK_DATA_BUILD_PATH}/${bbc_DATA_REL_PATH_FROM_DATA}/CMakeLists.txt.in
+    COPYONLY
+    )
+  CONFIGURE_FILE(
+    ${CMAKE_CURRENT_SOURCE_DIR}/bbc.sh.in
+    ${BBTK_BINARY_DIR}/bin/bbc
+    @ONLY IMMEDIATE
+    )
+  # Install tree
+  INSTALL(
+    FILES ${CMAKE_CURRENT_SOURCE_DIR}/main.cxx.in ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in
+    DESTINATION ${BBTK_DATA_INSTALL_PATH}/${bbc_DATA_REL_PATH_FROM_DATA}
+    )
+  INSTALL(
+    PROGRAMS ${BBTK_BINARY_DIR}/bin/bbc
+    DESTINATION bin
+    )
+    
+ELSE(UNIX)
+  # TO DO : bat for win
+ENDIF(UNIX)
diff --git a/kernel/appli/bbc/CMakeLists.txt.in b/kernel/appli/bbc/CMakeLists.txt.in
new file mode 100644 (file)
index 0000000..ed352d8
--- /dev/null
@@ -0,0 +1,18 @@
+
+#-----------------------------------------------------------------------------
+# Search for bbtk
+FIND_PACKAGE(BBTK)
+# If found
+IF(BBTK_FOUND)
+  # Include USE_FILE which configures the use of the lib
+  INCLUDE(${BBTK_USE_FILE})
+ENDIF(BBTK_FOUND)
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Build the program
+# Usual add executable
+ADD_EXECUTABLE(OUTPUT main)
+# Link against the testLib libraries
+TARGET_LINK_LIBRARIES(OUTPUT ${BBTK_LIBRARIES})
+#-----------------------------------------------------------------------------
diff --git a/kernel/appli/bbc/bbc.sh.in b/kernel/appli/bbc/bbc.sh.in
new file mode 100755 (executable)
index 0000000..83eca03
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/bash
+# compiles bbs files
+
+source ~/.bashrc
+
+if [ $# -lt 1 ]
+    then
+    echo "usage : bbc <input bbs file>"  
+    exit
+fi
+
+#
+CUR=${PWD}
+
+# bbc bin path
+TMP=$(which $0|rev)
+BINPATH=$(echo ${TMP#*/}|rev)
+# data path
+DATADIR=${BINPATH}/@bbc_DATA_REL_PATH_FROM_BIN@
+
+# extract bbs file name
+IN=$1
+TMP="${IN##*/}"
+OUTPUT="${TMP%%.*}"
+echo Output=\"${OUTPUT}\"
+
+WORKDIR=bbc_tmp
+mkdir ${WORKDIR}
+
+sed s,OUTPUT,${OUTPUT},g ${DATADIR}/CMakeLists.txt.in > ${WORKDIR}/CMakeLists.txt
+sed s,EXEC_FUNCTION,${OUTPUT},g ${DATADIR}/main.cxx.in > ${WORKDIR}/main.cxx
+cd ${WORKDIR}
+bbs2cpp ${IN}
+cmake .
+cmake .
+cmake .
+make
+mv ${OUTPUT} ${CUR}/
+cd ${CUR}
+rm -Rf ${WORKDIR}
+
diff --git a/kernel/appli/bbc/main.cxx.in b/kernel/appli/bbc/main.cxx.in
new file mode 100644 (file)
index 0000000..b4ac527
--- /dev/null
@@ -0,0 +1,200 @@
+#ifdef _USE_WXWIDGETS_
+
+//==========================================================================
+// WITH WX
+//==========================================================================
+#include "bbtkInterpreter.h"
+#include "bbtkWxBlackBox.h"
+#include "bbtkWxGUIConsole.h"
+
+#include <wx/cmdline.h>
+#include <vector>
+#include <map>
+
+#include "EXEC_FUNCTION.h"
+
+static const wxCmdLineEntryDesc cmdLineDesc[] =
+{
+  { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Debug messages on (message All 9)") },
+  { wxCMD_LINE_SWITCH, _T("q"), _T("quiet"),   _T("be quiet") },
+  { wxCMD_LINE_SWITCH, _T("h"), _T("help"),   _T("print help") },
+  { wxCMD_LINE_SWITCH, _T("g"), _T("graphical-dialog"),   _T("prompts the user for the parameters values using dialog boxes") },
+  { wxCMD_LINE_SWITCH, _T("t"), _T("text-dialog"),   _T("prompts the user for the parameters values in text mode") },
+  { wxCMD_LINE_PARAM,  NULL, NULL, _T("Input=Value"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
+  { wxCMD_LINE_NONE }
+};
+
+
+
+class wxBBIApp : public wxApp
+{
+public:
+  bool OnInit( );
+  int  OnExit() { delete mExecuter; return true; }
+  void OnInitCmdLine(wxCmdLineParser& parser);
+  bool OnCmdLineParsed(wxCmdLineParser& parser);
+  void Run(bbtk::Interpreter*);
+
+  bbtk::Executer* mExecuter;
+  //  int argc;
+  //  std::vector<std::string> argv;
+  bool command;
+  bool debug;
+  bool quiet;
+  bool help;
+  bool graphical_dialog;
+  bool text_dialog;
+
+  std::map<std::string,std::string> param_map;
+  
+};
+
+IMPLEMENT_APP(wxBBIApp);
+
+void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser)
+{
+  parser.SetDesc(cmdLineDesc);
+}
+
+bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser)
+{
+  debug = ( parser.Found(_T("d")) );
+  quiet = ( parser.Found(_T("q")) );
+  help = ( parser.Found(_T("h")) );
+  graphical_dialog = ( parser.Found(_T("g")) );
+  text_dialog = ( parser.Found(_T("t")) );
+
+  // parse the arguments and consider those which contain a "=" 
+  // as set input commands
+  int argc = parser.GetParamCount();
+  for (int i=0; i<argc; ++i) 
+    {
+      std::string s = bbtk::wx2std(parser.GetParam(i));
+      std::string::size_type pos = s.find_first_of("=");
+      if (std::string::npos != pos) 
+       {
+         std::string left = s.substr(0,pos);
+         std::string right = s.substr(pos+1,s.size());
+         param_map[left]=right;
+       }
+      else 
+       {
+         std::cout << "'" << s << "' option unrecognized : ignored"<<std::endl;
+       }
+    }
+
+  if (help) {
+    std::cout << bbtk::wx2std(parser.GetParam(0)) << std::endl;
+    parser.Usage();
+  }
+
+  return true;
+}
+
+
+
+// ----------------------------------------------------------------------------
+// The `main program' equivalent, creating the windows and returning the
+// main frame
+bool wxBBIApp::OnInit( )
+{
+  //    std::cout << "OnInit"<<std::endl;
+  wxApp::OnInit();
+#ifdef __WXGTK__
+  //See http://www.wxwindows.org/faqgtk.htm#locale
+  setlocale(LC_NUMERIC, "C");
+#endif
+  
+  if (quiet) bbtk::MessageManager::SetMessageLevel("All",0);
+  if (debug) bbtk::MessageManager::SetMessageLevel("All",9);
+  
+  bbtk::Wx::CreateInvisibleTopWindow();
+
+  try {
+    mExecuter = new bbtk::Executer();
+    mExecuter->SetInputs(param_map);
+
+    if (help) mExecuter->SetNoExecMode(true);
+
+    if (graphical_dialog) mExecuter->SetDialogMode(bbtk::VirtualExec::GraphicalDialog);
+    if (text_dialog) mExecuter->SetDialogMode(bbtk::VirtualExec::TextDialog);
+
+    EXEC_FUNCTION(mExecuter);
+    
+    mExecuter->SetNoExecMode(false);
+
+    if (help) 
+      {
+       std::string package; 
+       mExecuter->GetFactory()->HelpBlackBox("workspace",package,false);
+      }
+  }
+  catch (bbtk::Exception e)
+    {
+      wxString mess;
+      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()) 
+    { 
+      return false;
+    }
+  return true;
+}
+
+
+#if defined(_WIN32) 
+
+//  How to have a Console and wxWidgets
+//  http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
+//   In Visual C++ 6 (7 should be similar), to create an application that is both a console application 
+//  (cout's to the console are visible) and has a wxWidgets GUI, 
+//  you need to use the linker option "/subsystem:console" and the following code:
+int main(int argc, char* argv[])
+{
+  return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 
+                SW_SHOWNORMAL);
+}
+
+#endif // defined(_WIN32) 
+
+
+#else
+//==========================================================================
+// WITHOUT WX
+//==========================================================================
+
+#include "bbtkInterpreter.h"
+
+int main(int argc, char* argv[])
+{  
+
+  if (argc>2) return 0;
+
+  std::cout << "BBI (Black Box Interpreter) - bbtk "
+           << bbtk::GetVersion()<< " - (c) Creatis 2007"
+           <<std::endl;
+
+  bbtk::Interpreter I;
+  if (argc==1) 
+    {
+      I.CommandLineInterpreter();
+    }
+  else 
+    {
+      std::string f(argv[1]);
+      I.InterpretFile(f);
+    }
+    
+  return 0;
+
+}
+
+// EOF
+#endif //#ifdef _USE_WXWIDGETS_
+
+
+
index 1d92d7e533f488feba3d2ae13199148728435c69..0ee9e1a0c9b7b3d5b641b130c36eb33e316922d0 100644 (file)
@@ -141,8 +141,8 @@ bool wxBBIApp::OnInit( )
   bool help_on_script = help && (input_file.size() > 0);
   if (help_on_script) I->SetNoExecMode(true);
 
-  if (graphical_dialog) I->SetDialogMode(bbtk::Executer::GraphicalDialog);
-  if (text_dialog) I->SetDialogMode(bbtk::Executer::TextDialog);
+  if (graphical_dialog) I->SetDialogMode(bbtk::VirtualExec::GraphicalDialog);
+  if (text_dialog) I->SetDialogMode(bbtk::VirtualExec::TextDialog);
 
   std::vector<std::string>::const_iterator i;
   bool error = false;
diff --git a/kernel/appli/bbs2cpp/CMakeLists.txt b/kernel/appli/bbs2cpp/CMakeLists.txt
new file mode 100644 (file)
index 0000000..519826f
--- /dev/null
@@ -0,0 +1,14 @@
+
+SET(SOURCES bbs2cpp )
+SET(EXENAME bbs2cpp )
+
+IF(BBTK_USE_WXWIDGETS AND WIN32)
+  ADD_EXECUTABLE(${EXENAME} WIN32 ${SOURCES})  
+#  SET_TARGET_PROPERTIES(bbhelp PROPERTIES LINK_FLAGS /subsystem:console )
+ELSE(BBTK_USE_WXWIDGETS AND WIN32)
+  ADD_EXECUTABLE(${EXENAME} ${SOURCES})  
+ENDIF(BBTK_USE_WXWIDGETS AND WIN32)
+
+
+TARGET_LINK_LIBRARIES(${EXENAME} bbtk)
+INSTALL_TARGETS(/bin/ ${EXENAME})
diff --git a/kernel/appli/bbs2cpp/bbs2cpp.cxx b/kernel/appli/bbs2cpp/bbs2cpp.cxx
new file mode 100644 (file)
index 0000000..529a035
--- /dev/null
@@ -0,0 +1,30 @@
+#include "bbtkInterpreter.h"
+#include "bbtkUtilities.h"
+
+int main(int argc, char* argv[])
+{  
+  if (argc<2) return 1;
+
+  std::string file,path;
+  file = bbtk::Utilities::ExtractScriptName(argv[1],path);
+  file += ".h";
+  bbtk::Interpreter* I = new bbtk::Interpreter(file);
+
+  I->SetThrow(true);
+
+  try
+    {
+      I->InterpretFile(argv[1]);
+    }
+  catch (bbtk::Exception e)
+    {
+      e.Print();
+    }
+
+  delete I;
+
+  return 0;
+}
+        
+// EOF
+
index ab0075d2e84030d01bd0ac1bd3c5a16b0adf3d46..d112dba1115b4a16ee23b9b0e056b90aa26b0b42 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/26 08:51:43 $
-  Version:   $Revision: 1.56 $
+  Date:      $Date: 2008/03/26 14:47:36 $
+  Version:   $Revision: 1.57 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -21,6 +21,8 @@
  */
 
 #include "bbtkInterpreter.h"
+#include "bbtkExecuter.h"
+#include "bbtkTranscriptor.h"
 #include "bbtkMessageManager.h"
 #include "bbtkConfigurationFile.h"
 #include "bbtkUtilities.h"
@@ -42,7 +44,7 @@ namespace bbtk
  /**
    *
    */
-  Interpreter::Interpreter() 
+  Interpreter::Interpreter(const std::string& cpp_file
     :
     mUser(0),
     mCommandLine(false),
@@ -53,7 +55,14 @@ bufferNb =0;
     bbtk::MessageManager::RegisterMessageType("Interpreter","Messages of the interpreter",0);
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::Interpreter()" <<std::endl);
  
-    mExecuter = new bbtk::Executer();
+    if (cpp_file.size()!=0)
+      {
+       mExecuter = new bbtk::Transcriptor(cpp_file);
+      }
+    else 
+      {
+       mExecuter = new bbtk::Executer();
+      }
     mExecuter->SetInterpreter(this);
     
     // For the time being, comment out previous line, and
@@ -1003,7 +1012,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
              }
            else 
              {
-               bbtkError("'"<<upath<<"' : not a valid folder"); 
+               bbtkError("'"<<upath<<"' : directory does not exist"); 
              }
          }
        // ==== relative path provided : search all bbs path appended with 
@@ -1032,13 +1041,14 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
                     script_paths.push_back(full_path);
                   }
               } 
+            if (script_paths.empty())
+              {
+                bbtkError("no '"<<upath<<"' subdir found in search paths" 
+                          << std::endl);
+              }
+
          }
        // === search paths list complete : now explore it
-       if (script_paths.empty())
-         {
-           bbtkMessage("Interpreter",1,
-                       "'"<<upath<<"' : No matching folder" << std::endl);
-         }
 
 
        std::vector<std::string>::iterator i;
index 02985af8c9253b519377785aad224fbf04fc5ef4..d7f8731cf169069164889ecf5ced8b9893dc86c2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/26 08:27:19 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2008/03/26 14:47:36 $
+  Version:   $Revision: 1.23 $
 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,8 +28,6 @@
 #define __bbtkInterpreter_h__
 
 #include "bbtkVirtualExec.h"
-#include "bbtkExecuter.h"
-#include "bbtkTranscriptor.h"
 
 #include <fstream>
 #include <deque>
@@ -131,7 +129,7 @@ namespace bbtk
 
   public:
     /// Constructor
-    Interpreter();
+    Interpreter(const std::string& cpp_file = "");
 
     /// Destructor
     ~Interpreter();
@@ -173,15 +171,13 @@ namespace bbtk
     //typedef Executer::DialogModeType DialogModeType;
     typedef VirtualExec::DialogModeType DialogModeType;
 
-       void SetDialogMode(DialogModeType t) { mExecuter->SetDialogMode(t); }
+    void SetDialogMode(DialogModeType t) { mExecuter->SetDialogMode(t); }
 
     /// Sets the bool that indicates wether we are in command line context
     void SetCommandLine(bool v = true) { mCommandLine = v; }
 
     void SetThrow(bool b) { mThrow = b; }
 
-    
 #ifdef _USE_WXWIDGETS_
     /// Sets the user of the interpreter (if any)
     void SetUser(InterpreterUser* c) { mUser = c; }
index ff0785b392013d6ce23a9ee1ebc91e20167cba8a..e5e83b59a02837338c1b58e1798a6eb3a63cdd79 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkTranscriptor.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/26 08:27:19 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2008/03/26 14:47:36 $
+  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
@@ -40,23 +40,53 @@ namespace bbtk
  *
  */
   Transcriptor::Transcriptor(std::string filename)
-    : mPackage(0),
-      mRoot(0),
+    :
       mNoExecMode(false),
       mDialogMode(NoDialog)
   {
     //VirtualExec();    
     bbtkDebugMessageInc("Kernel",9,"Transcriptor::Transcriptor()" <<std::endl);
-    Reset();
-    bbtkDebugDecTab("Kernel",9);
-
-    //std::ofstream *m_Fp = new std::ofstream();
+     //std::ofstream *m_Fp = new std::ofstream();
     m_Fp.open (filename.c_str(), std::ios::out );
 
-    m_Fp << "#include \"bbtkExecuter.h\""                   << std::endl;
+    std::string file,path;
+    file = bbtk::Utilities::ExtractScriptName(filename,path);
+    
+    m_Fp << "#include \"bbtkExecuter.h\"" << std::endl; 
+    m_Fp << "void " << file << "(bbtk::Executer* e)"<<std::endl;
+    m_Fp << "{"<<std::endl;
+
+    /*
+#ifdef _USE_WXWIDGETS_
+    m_Fp << "#ifdef _USE_WXWIDGETS_"<<std::endl;
+    m_Fp << "#include \"bbtkWx.h\""<< std::endl<<std::endl;
+    m_Fp << "class myApp : public wxApp"<<std::endl;
+    m_Fp << "{"<<std::endl;
+    m_Fp << "public:"<<std::endl;
+    m_Fp << "  bool OnInit( );"<<std::endl;
+    m_Fp << "  int  OnExit() { delete e; return true; }"<<std::endl;
+    m_Fp << "  bbtk::Executer* e;"<<std::endl;
+    m_Fp << "};"<<std::endl<<std::endl;
+    m_Fp << "IMPLEMENT_APP(myApp);"<<std::endl<<std::endl;
+    m_Fp << "bool myApp::OnInit( )"<<std::endl;
+    m_Fp << "{"<<std::endl;
+    m_Fp << "  wxApp::OnInit();"<<std::endl;
+    m_Fp << "#ifdef __WXGTK__"<<std::endl;
+    m_Fp << "  //See http://www.wxwindows.org/faqgtk.htm#locale"<<std::endl;
+    m_Fp << "  setlocale(LC_NUMERIC, \"C\");"<<std::endl;
+    m_Fp << "#endif"<<std::endl;
+    m_Fp << "  wxInitAllImageHandlers();"<<std::endl;
+    m_Fp << "  bbtk::Wx::CreateInvisibleTopWindow();"<<std::endl;
+    m_Fp << "  try {"<<std::endl;
+    m_Fp << "  e = new bbtk::Executer();"<<std::endl;
+#else
     m_Fp << "main(int argc, char *argv[]) {"                << std::endl;
     m_Fp << "  bbtk::Executer *e = new bbtk::Executer();"   << std::endl;
-  }
+#endif 
+    */
+    bbtkDebugDecTab("Kernel",9);
+ }
 
 /**
  *
@@ -64,29 +94,28 @@ namespace bbtk
   Transcriptor::~Transcriptor()
   {
   
-std::cout << "====================================================== delete Transcriptor\n";
-     bbtkDebugMessageInc("Kernel",9,"Transcriptor::~Transcriptor()" <<std::endl);
-     if (mRoot) 
-     {
-        mPackage->UnRegisterBlackBox("workspace");
-        delete mRoot;
-     }
-     if (mPackage)
-     {
-        //GetGlobalFactory()->UnLoadPackage("user");
-     }
-
-     if(m_Fp)
-     {
-        bbtkDebugDecTab("Kernel",9);
-        m_Fp << " }"   << std::endl;
-        m_Fp.close();
-       // delete m_Fp;
-     }
-  }
+    bbtkDebugMessageInc("Kernel",9,"Transcriptor::~Transcriptor()" <<std::endl);
+    /*
+#ifdef _USE_WXWIDGETS_
+    m_Fp << "  }"<<std::endl;
+    m_Fp << "  catch (bbtk::Exception err)"<<std::endl;
+    m_Fp << "  {"<<std::endl;
+    m_Fp << "    err.Print();"<<std::endl;
+    m_Fp << "  } "<<std::endl;
+    m_Fp << "  return true;"<<std::endl;
+    m_Fp << "}"   << std::endl;
+    m_Fp << "#endif"<<std::endl;
+#else 
+    m_Fp << "}"   << std::endl;
+#endif
+    */
+    m_Fp << "}"   << std::endl;
+    m_Fp.close();
 
+    bbtkDebugDecTab("Kernel",9);
+  }
+  
 
-  // ================= Begin of Battlefield =============================
   void Transcriptor::Reset()
   {
      m_Fp << "  e->Reset( );" << std::endl;
@@ -130,7 +159,7 @@ std::cout << "====================================================== delete Tran
   void Transcriptor::Create ( const std::string& nodeType, 
                               const std::string& nodeName)
   {
-    m_Fp << "  e->Add(\"" << nodeType << "\", \"" 
+    m_Fp << "  e->Create(\"" << nodeType << "\", \"" 
         <<  nodeName << "\");" << std::endl;
   }
 
@@ -162,8 +191,8 @@ std::cout << "====================================================== delete Tran
                                    const std::string& help)
   {
   
-    m_Fp << "  e->DefineInput(\""<< name << "\", " <<  box << ", "
-         << input << ", \"" << help << "\");" << std::endl;
+    m_Fp << "  e->DefineInput(\""<< name << "\", \"" <<  box << "\", \""
+         << input << "\", \"" << help << "\");" << std::endl;
   }
 
   
@@ -199,27 +228,25 @@ std::cout << "====================================================== delete Tran
   void Transcriptor::Author(const std::string &authorName)
   {
     
-    m_Fp << "  e->AddToAuthor(\"" << authorName << "\")" << std::endl;
+    m_Fp << "  e->Author(\"" << authorName << "\");" << std::endl;
   }
 
   void Transcriptor::Category(const std::string &category)
   {
-    m_Fp << "  e->AddToCategory(\"" << category << "\")" << std::endl;
+    m_Fp << "  e->Category(\"" << category << "\");" << std::endl;
   }
 
   void Transcriptor::Description(const std::string &d)
   {
-    m_Fp << "  e->AddToDescription(\"" << d << "\")" << std::endl;
+    m_Fp << "  e->Description(\"" << d << "\");" << std::endl;
   }
 
   /// prints the list of the boxes of the current descriptor
   void Transcriptor::PrintBoxes()
   {
-     m_Fp << "  e->PrintBoxes( )" << std::endl;
+     m_Fp << "  e->PrintBoxes( );" << std::endl;
  }
 
-// =========================End of Battlefield ========================================================================
-
   std::string Transcriptor::ShowGraph(const std::string &nameblackbox,
                                  const std::string &detailStr,
                                  const std::string &levelStr,
@@ -254,7 +281,7 @@ void Transcriptor::ShowRelations(const std::string &nameblackbox, const std::str
 
   void Transcriptor::Print(const std::string & message)
   {
-    m_Fp << "  e->Print(\"" <<message<<"\")"<<std::endl;
+    m_Fp << "  e->Print(\"" <<message<<"\");"<<std::endl;
   }
 
 
@@ -262,24 +289,24 @@ void Transcriptor::ShowRelations(const std::string &nameblackbox, const std::str
   void Transcriptor::SetMessageLevel(const std::string &kind,
                       int level)
   {
-    m_Fp << "  e->SetMessageLevel(\"" <<kind<<"\","<<level<<")"<<std::endl;
+    m_Fp << "  e->SetMessageLevel(\"" <<kind<<"\","<<level<<");"<<std::endl;
   }
   
 
   void Transcriptor::HelpMessages()
   {
-    m_Fp << "  e->HelpMessages()"<<std::endl;
+    m_Fp << "  e->HelpMessages();"<<std::endl;
   }
   
   void Transcriptor::LoadPackage(const std::string &name )
   {
-    m_Fp << "  e->LoadPackage(\"" <<name<<"\")"<<std::endl;
+    m_Fp << "  e->LoadPackage(\"" <<name<<"\");"<<std::endl;
   }
   
   
   void Transcriptor::UnLoadPackage(const std::string &name )
   {
-    m_Fp << "  e->UnLoadPackage(\"" <<name<<"\")"<<std::endl;
+    m_Fp << "  e->UnLoadPackage(\"" <<name<<"\");"<<std::endl;
   }
 
 
index 5df074fb59699919fdf3095a9110e945873b5a55..738850578b954481fdaa7740c39694ee0e1d0368 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkTranscriptor.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/26 08:27:19 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2008/03/26 14:47:36 $
+  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
 #include "bbtkVirtualExec.h"
 
 #include "bbtkSystem.h"
-#include "bbtkComplexBlackBox.h"
-#include "bbtkFactory.h"
-#include <string>
-#include <deque>
 #include <iostream>
 
 namespace bbtk
@@ -66,13 +62,7 @@ namespace bbtk
     }
 
     bool GetNoExecMode() const { return mNoExecMode; }
-    /*
-    bool GetNoExecMode() const
-    {
-      // cannot compile, since ethos is 'const' !
-      //m_Fp << "e->GetNoExecMode(true);" << std::endl;
-    }
-    */
+
     /// Sets the mode of dialog of the executer for Root inputs 
     void SetDialogMode(DialogModeType t) { mDialogMode = t; }
 
@@ -186,47 +176,6 @@ namespace bbtk
 
   private:
 
-    /// Gets the current working black box 
-    ComplexBlackBoxDescriptor* Current() 
-       { return mOpenDefinition.back().box; }
-    
-    /// Returns true when we are inside a define/endefine block
-    //    bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
-
-    //==================================================================
-    // 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;
     
index cb980627b859bc6687c61344d6ef456a76eb3254..928a8674708f8eb4a32b4839f147f4e51c5062cc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkVirtualExec.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/26 08:27:19 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2008/03/26 14:47:36 $
+  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
@@ -52,6 +52,8 @@ namespace bbtk
 
     VirtualExec() : mInterpreter(0) {}
 
+    virtual ~VirtualExec() {}
+
     /// Sets the interpreter who uses it 
     void SetInterpreter(Interpreter* i) { mInterpreter = i; }
     /// Gets the interpreter who uses it 
index fc42e4788c5af29040172211e5356159f30d6256..7ad8ad02785220d05bd598b69704a43d20ec1321 100644 (file)
@@ -11,7 +11,13 @@ namespace bbtk
   static int mgNbWindowsAlive  = 0;
   static int mgNbWindowsShown  = 0;
 
-
+  void Wx::CreateInvisibleTopWindow()
+  {
+    wxWindow* top = new wxFrame(0,-1,_T("TOP (YOU SHOULD NOT SEE ME !!)"));
+    top->Hide();
+    Wx::SetTopWindow(top);
+  }
   void Wx::ResetCursor() 
   {
     if (!GetTopWindow()) return;
index 7d64a023a94f22119dd08b7ad41ba1dac1bdeacf..e160c3ae7b1eecbc994674bb8c27be450bbb8230 100644 (file)
@@ -44,6 +44,7 @@ namespace bbtk
     static void EndBusyCursor();
     static int mBeginBusyCallsCount;
 
+    static void CreateInvisibleTopWindow();
     /// Returns the global parent of all bbtk windows
     static wxWindow* GetTopWindow();
     /// Sets the global parent of all bbtk windows
@@ -117,6 +118,7 @@ namespace bbtk
     static void ResetCursor() {}
     static void BeginBusyCursor() {}
     static void EndBusyCursor() {}
+    static void CreateInvisibleTopWindow() {}
     static wxWindow* GetTopWindow() { return 0; }
     static void SetTopWindow(wxWindow*) {}
     static void IncNbWindowsAlive() {}
index af65ae7aa897b9b7af07e6bb796049e05b7f5a6d..fb85734a9b71a4be1151ac0fe492ad28aeacb1f5 100755 (executable)
@@ -1,6 +1,7 @@
 #include "bbstdExecBbiCommand.h"
 #include "bbstdPackage.h"
 #include "bbtkInterpreter.h"
+#include "bbtkExecuter.h"
 
 namespace bbstd
 {
index 15021cb59a75889ab2c91eb00e5cd3bea64e628d..2b943b2edbf278d48c3cd512f8bbf58b6638a3bf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxCommandButton.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/19 14:58:14 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2008/03/26 14:47:37 $
+  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
@@ -27,6 +27,7 @@
 #include "bbwxCommandButton.h"
 #include "bbwxPackage.h"
 #include "bbtkInterpreter.h"
+#include "bbtkExecuter.h"