]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
index ced11fa92b8f849e14231a4f293fb75c624e1ff8..28dbfe43798c7b94b7c46668c8df21f3035bdc79 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/02/18 10:41:02 $
-  Version:   $Revision: 1.33 $
+  Date:      $Date: 2008/03/03 14:55:55 $
+  Version:   $Revision: 1.39 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -172,8 +172,8 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
     info.argmax = 2;
     info.code = cIndex;
 
     info.argmax = 2;
     info.code = cIndex;
 
-    info.syntax = "index [<filename> ['Initials'(default)|'Packages'|'Categories']]";
-    info.help = "Creates an html index of known boxes. If filename is provided then save it to the file 'filename'. The default index entries are the initial letters of the names of the boxes. If 'Packages' or 'Categories' is provided then the entries are either the packages names or the categories";
+    info.syntax = "index [<filename> ['Initials'(default)|'Packages'|'Categories'|'Adaptors']]";
+    info.help = "Creates an html index of known boxes. If filename is provided then save it to the file 'filename'. The default index entries are the initial letters of the names of the boxes. If 'Packages' or 'Categories' is provided then the entries are either the packages names or the categories. If 'Adaptors' is provided then an alphabetical index of all adaptors is created.";
     mCommandDict[info.category] = info;
 
     info.category = "reset";  //EED
     mCommandDict[info.category] = info;
 
     info.category = "reset";  //EED
@@ -287,6 +287,8 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
    */
   Interpreter::~Interpreter()
   {
    */
   Interpreter::~Interpreter()
   {
+
+std::cout << "=========================================~Interpreter()" << std::endl;
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <<std::endl);
     delete mExecuter;
     //delete mFactory;
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <<std::endl);
     delete mExecuter;
     //delete mFactory;
@@ -300,20 +302,16 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
   /**
    *  
    */
   /**
    *  
    */
-  void Interpreter::InterpretFile( const std::string& filename,  
-                                   bool use_configuration_file)
+  void Interpreter::InterpretFile( const std::string& filename )
   {
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl);
 
     bool exm = mCommandLine;
     mCommandLine = false;
 
   {
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl);
 
     bool exm = mCommandLine;
     mCommandLine = false;
 
-
     try 
     {
     try 
     {
-printf("EED: Interpreter::InterpretFile 01\n");
-InterpretLine("message ALL 9", exm);
-      SwitchToFile(filename, use_configuration_file);
+      SwitchToFile(filename);
       bool insideComment = false; // for multiline comment
       while (mFile.size()>0) 
       {
       bool insideComment = false; // for multiline comment
       while (mFile.size()>0) 
       {
@@ -370,7 +368,6 @@ InterpretLine("message ALL 9", exm);
     bbtkDecTab("Interpreter",9);
 
     mCommandLine = exm;
     bbtkDecTab("Interpreter",9);
 
     mCommandLine = exm;
- printf("EED: Interpreter::InterpretFile 02\n");
   }
   //=======================================================================
 
   }
   //=======================================================================
 
@@ -488,7 +485,7 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
         break;
 
       case cPrint :
         break;
 
       case cPrint :
-        Print(words[1]); /// \todo use mExecuter 
+        Print(words[1]); /// \todo use generate command 
         break;
         
       case cExec :
         break;
         
       case cExec :
@@ -567,11 +564,11 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
       case cInclude :
         if (mCommandLine)
         {
       case cInclude :
         if (mCommandLine)
         {
-           InterpretFile(words[1], true ); // true : better pass use_config_file
+           InterpretFile(words[1]); 
         }
         else
         {
         }
         else
         {
-            SwitchToFile(words[1], true ); // true : better pass use_config_file
+            SwitchToFile(words[1]);
         }
        // if 'source' was given
        if (words.size()==3) 
         }
        // if 'source' was given
        if (words.size()==3) 
@@ -581,7 +578,7 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
         break;
 
       case cLoad:
         break;
 
       case cLoad:
-        LoadPackage(words[1], true ); // true : better pass use_config_file
+        LoadPackage(words[1]);
         break;
 
       case cUnload:
         break;
 
       case cUnload:
@@ -679,7 +676,15 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
   {
     if (mExecuter->GetNoExecMode()) return;
 
   {
     if (mExecuter->GetNoExecMode()) return;
 
-    bbtkDebugMessageInc("Interpreter",9,"Interpreter::SplitLine(\""<<str<<"\")"<<std::endl);
+    bbtkDebugMessageInc("Interpreter",9,"Interpreter::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("$");
 
     std::vector<std::string> chains;
     std::string delimiters("$");
@@ -698,14 +703,21 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
        {
           // Found a text token, add it to the vector.
           chains.push_back(str.substr(lastPos, pos - lastPos));
        {
           // 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%")
        }
        else 
        {
        }
        else 
        {
+
        // is an output (between $$) : decode 
          std::string tok,box,output;
          tok = str.substr(lastPos, pos - lastPos);
          Utilities::SplitAroundFirstDot(tok,box,output);
          chains.push_back( mExecuter->Get(box,output) );
        // is an output (between $$) : decode 
          std::string tok,box,output;
          tok = str.substr(lastPos, pos - lastPos);
          Utilities::SplitAroundFirstDot(tok,box,output);
          chains.push_back( mExecuter->Get(box,output) );
+
+// InterpretLine("connect %tok% _C_.In%num%") 
+
        }
         // Skip delimiters.  Note the "not_of"
        lastPos = str.find_first_not_of(delimiters, pos);
        }
         // Skip delimiters.  Note the "not_of"
        lastPos = str.find_first_not_of(delimiters, pos);
@@ -713,7 +725,11 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
        pos = str.find_first_of(delimiters, lastPos);
     //
        is_text = !is_text;
        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) 
      {
      std::vector<std::string>::iterator i;
      for (i= chains.begin(); i!=chains.end(); ++i) 
      {
@@ -732,8 +748,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
 
 // ===================================================================================
 
 
 // ===================================================================================
 
-  void Interpreter::SwitchToFile( const std::string& name,
-                                  bool use_configuration_file )
+  void Interpreter::SwitchToFile( const std::string& name )
   {
   // Note : in the following :
   // name : the user supplied name 
   {
   // Note : in the following :
   // name : the user supplied name 
@@ -753,16 +768,14 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
     std::string pkgname;             // e.g. <scriptname>.bbs
     std::vector<std::string> Filenames;
 
     std::string pkgname;             // e.g. <scriptname>.bbs
     std::vector<std::string> Filenames;
 
-    if (use_configuration_file)
-    {
-        // The following is *NOT* a debug time message :
-        // It's a user intended message.
-        // Please don't remove it.
-      bbtkMessage("Interpreter",1,
-                 "look for : [" << name
-                 << "] (use_configuration_file == TRUE)" << std::endl);
-      script_paths = ConfigurationFile::GetInstance().Get_bbs_paths();
-    }
+    // The following is *NOT* a debug time message :
+    // It's a user intended message.
+    // Please don't remove it.
+    bbtkMessage("Interpreter",1,
+               "look for : [" << name
+                 << "]" << std::endl);
+    script_paths = ConfigurationFile::GetInstance().Get_bbs_paths();
+
     std::string upath;
     pkgname = Utilities::ExtractScriptName(name,upath);
 
     std::string upath;
     pkgname = Utilities::ExtractScriptName(name,upath);
 
@@ -808,9 +821,9 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
 
         fullDirectoryName = Utilities::MakePkgnameFromPath(path, upath, false);
 
 
         fullDirectoryName = Utilities::MakePkgnameFromPath(path, upath, false);
 
-               //EED 18 Fev 2008
-               // without last slash "\"
-               std::string fullDirectoryNameClean = fullDirectoryName.substr(0,fullDirectoryName.size()-1);
+        //EED 18 Fev 2008
+        // without last slash "\"
+        std::string fullDirectoryNameClean = fullDirectoryName.substr(0,fullDirectoryName.size()-1);
 
       // Check if library exists
         if ( ! Utilities::IsDirectory( fullDirectoryNameClean ) )
 
       // Check if library exists
         if ( ! Utilities::IsDirectory( fullDirectoryNameClean ) )
@@ -1566,6 +1579,7 @@ void  Interpreter::Index(const std::string& filename,
   if (type=="Initials") t = Factory::Initials;
   else if (type=="Categories") t = Factory::Categories;
   else if (type=="Packages") t = Factory::Packages;
   if (type=="Initials") t = Factory::Initials;
   else if (type=="Categories") t = Factory::Categories;
   else if (type=="Packages") t = Factory::Packages;
+  else if (type=="Adaptors") t = Factory::Adaptors;
   
   GetGlobalFactory()->CreateHtmlIndex(t,filename);
 }
   
   GetGlobalFactory()->CreateHtmlIndex(t,filename);
 }