]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.cxx
Global factory in course of removal... does not compile but have to commit to continu...
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
index 28dbfe43798c7b94b7c46668c8df21f3035bdc79..e9bf1e8c8cef24bb0af3c64b2162b637a33acb73 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/03 14:55:55 $
-  Version:   $Revision: 1.39 $
+  Date:      $Date: 2008/03/07 08:40:14 $
+  Version:   $Revision: 1.40 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -37,7 +37,7 @@
 namespace bbtk
 {
 
-Interpreter* Interpreter::mGlobalInterpreter = NULL;
+  //Interpreter* Interpreter::mGlobalInterpreter = NULL;
 
  //=======================================================================
  /**
@@ -45,15 +45,17 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
    */
   Interpreter::Interpreter() 
     :
+#ifdef _USE_WXWIDGETS_
+    mWxConsole(0),
+#endif
     mCommandLine(false)
   {
     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);
  
-    mGlobalInterpreter = this;
-
     mExecuter = new bbtk::Executer();
+    mExecuter->SetInterpreter(this);
     
     // For the time being, comment out previous line, and
     // uncomment next line to check Transcriptor
@@ -291,7 +293,6 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
 std::cout << "=========================================~Interpreter()" << std::endl;
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <<std::endl);
     delete mExecuter;
-    //delete mFactory;
 
     bbtkDebugDecTab("Interpreter",9);
   }
@@ -573,16 +574,16 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
        // if 'source' was given
        if (words.size()==3) 
          {
-           this->mExecuter->SetCurrentFileName(words[1]);
+           GetExecuter()->SetCurrentFileName(words[1]);
          }
         break;
 
       case cLoad:
-        LoadPackage(words[1]);
+        GetExecuter()->GetFactory()->LoadPackage(words[1]);
         break;
 
       case cUnload:
-        UnLoadPackage(words[1]);
+        GetExecuter()->GetFactory()->UnLoadPackage(words[1]);
         break;
 
       case cQuit :
@@ -1093,7 +1094,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
     {
       if (words[1]=="packages") 
       {
-         PrintPackages(true);
+         GetExecuter()->GetFactory()->PrintPackages(true);
          return;
       }
       try 
@@ -1104,16 +1105,16 @@ void Interpreter::Help(const std::vector<std::string>& words)
       {
          try 
          {
-            HelpPackage(words[1]);
+            GetExecuter()->GetFactory()->HelpPackage(words[1]);
 #ifdef _USE_WXWIDGETS_
-           if ( WxConsole::GetInstance() != 0 )
+           if ( mWxConsole != 0 )
              {
                std::string url = 
                  ConfigurationFile::GetInstance().Get_doc_path();
                url += "/bbdoc/" + words[1] + "/index.html";
                if (Utilities::FileExists(url)) 
                  {
-                   WxConsole::GetInstance()->ShowHtmlPage(url);
+                   mWxConsole->ShowHtmlPage(url);
                  }
              }
 #endif     
@@ -1123,9 +1124,9 @@ void Interpreter::Help(const std::vector<std::string>& words)
             try 
             {
              std::string package;
-             HelpBlackBox(words[1],package);
+             GetExecuter()->GetFactory()->HelpBlackBox(words[1],package);
 #ifdef _USE_WXWIDGETS_
-              if ( WxConsole::GetInstance() != 0 )
+              if ( mWxConsole != 0 )
                 {
                   std::string url = 
                     ConfigurationFile::GetInstance().Get_doc_path();
@@ -1133,7 +1134,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
                   if (Utilities::FileExists(url))
                     {
                       url += "#" + words[1];
-                      WxConsole::GetInstance()->ShowHtmlPage(url);
+                      mWxConsole->ShowHtmlPage(url);
                     }
                 }
 #endif
@@ -1142,7 +1143,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
              {
                try
                  {
-                   this->mExecuter->ShowRelations(words[1],"0","9999");
+                   GetExecuter()->ShowRelations(words[1],"0","9999");
                  }
                catch (bbtk::Exception h){
                  bbtkError("\""<<words[1].c_str()
@@ -1158,12 +1159,12 @@ void Interpreter::Help(const std::vector<std::string>& words)
       {
          if ( words[1]=="packages" )
          {
-            PrintPackages(true,true);
+            GetExecuter()->GetFactory()->PrintPackages(true,true);
             return;
           }
          try 
          {
-            HelpPackage(words[1],true);
+            GetExecuter()->GetFactory()->HelpPackage(words[1],true);
          }
          catch (bbtk::Exception f) 
          {
@@ -1531,7 +1532,7 @@ void Interpreter::Graph(const std::vector<std::string>& words)
     bool system_display = true;
 
 #ifdef _USE_WXWIDGETS_
-    if ( WxConsole::GetInstance() != 0 ) system_display = false; 
+    if ( mWxConsole != 0 ) system_display = false; 
 #endif
  
     if (words.size()==1) 
@@ -1564,8 +1565,8 @@ void Interpreter::Graph(const std::vector<std::string>& words)
       } 
     
 #ifdef _USE_WXWIDGETS_
-    if ( WxConsole::GetInstance() != 0 )
-      WxConsole::GetInstance()->ShowHtmlPage(page);
+    if ( mWxConsole != 0 )
+      mWxConsole->ShowHtmlPage(page);
 #endif
   }
 //=======================================================================
@@ -1581,7 +1582,7 @@ void  Interpreter::Index(const std::string& filename,
   else if (type=="Packages") t = Factory::Packages;
   else if (type=="Adaptors") t = Factory::Adaptors;
   
-  GetGlobalFactory()->CreateHtmlIndex(t,filename);
+  GetExecuter()->GetFactory()->CreateHtmlIndex(t,filename);
 }
 //=======================================================================