]> Creatis software - bbtk.git/blob - kernel/src/bbtkInterpreter.cxx
e57717e08a78c3297dd7d34992603ee6cb47ae38
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbtkInterpreter.cxx,v $
31   Language:  C++
32   Date:      $Date: 2012/11/16 08:49:01 $
33   Version:   $Revision: 1.95 $
34 =========================================================================*/
35
36
37
38 /**
39  *  \file 
40  *  \brief class Interpreter :
41  */
42
43 #include "bbtkInterpreter.h"
44 #include "bbtkExecuter.h"
45 #include "bbtkTranscriptor.h"
46 #include "bbtkMessageManager.h"
47 #include "bbtkConfigurationFile.h"
48 #include "bbtkUtilities.h"
49 #include "bbtkAtomicBlackBox.h"
50 #include "bbtkWxBlackBox.h"
51 #include <sys/stat.h>
52 #include <algorithm>
53 #ifdef CMAKE_HAVE_TERMIOS_H
54 #include <termios.h>
55 #define BBTK_USE_TERMIOS_BASED_PROMPT
56 #endif
57
58 #include <string>
59
60 namespace bbtk
61 {
62
63  //=======================================================================
64   Interpreter::Pointer Interpreter::New(const std::string& cpp_file) 
65   {
66     bbtkDebugMessage("kernel",9,"Interpreter::New('"<<cpp_file<<"')"<<std::endl);
67     return MakePointer(new Interpreter(cpp_file));
68   }
69  //=======================================================================
70
71  //=======================================================================
72   Interpreter::Pointer Interpreter::New(VirtualExec::Pointer e) 
73   {
74     bbtkDebugMessage("kernel",9,"Interpreter::New(VirtualExec)"<<std::endl);
75     return MakePointer(new Interpreter(e));
76   }
77  //=======================================================================
78
79  //=======================================================================
80   Interpreter::Interpreter(const std::string& cpp_file) 
81   {
82     bbtkDebugMessage("object",2,"==> Interpreter("<<cpp_file<<")"<<std::endl);
83     Init(VirtualExec::Pointer(), cpp_file);
84     bbtkDebugMessage("object",2,"<== Interpreter("<<cpp_file<<")"<<std::endl);
85   }
86   //=======================================================================
87
88  //=======================================================================
89   Interpreter::Interpreter(VirtualExec::Pointer e) 
90   {
91     bbtkDebugMessage("object",2,"==> Interpreter(VirtualExec)"<<std::endl);
92     Init(e,"");
93     bbtkDebugMessage("object",2,"<== Interpreter(VirtualExec)"<<std::endl);
94   }
95   //=======================================================================
96
97   //=======================================================================
98   void Interpreter::Init(VirtualExec::Pointer e, const std::string& cpp_file) 
99   {
100     if (e)
101       {
102         mVirtualExecuter = e;
103       }
104     else if (cpp_file.size()!=0)
105       {
106         mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
107       }
108     else 
109       {
110         bbtk::Executer::Pointer exe = bbtk::Executer::New();
111         mRealExecuter = exe;
112         mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(exe);
113       }
114
115           
116           
117     // Lock this pointer or will auto-destruct !!
118     if (!e) mVirtualExecuter->SetInterpreter(MakePointer(this,true));
119
120           
121           bbtk::InterpreterVirtual::Init();
122   } 
123   //=======================================================================
124   
125   
126   
127   //=======================================================================  
128   /**
129    *  
130    */
131   Interpreter::~Interpreter()
132   {
133     bbtkDebugMessage("object",2,"==> ~Interpreter()" <<std::endl);
134     mVirtualExecuter = VirtualExec::Pointer();
135     bbtkDebugMessage("object",2,"<== ~Interpreter()" <<std::endl);
136   }
137   //=======================================================================
138
139 /*EED Borrame
140   //=======================================================================
141   InterpreterException::InterpreterException( const std::string& message,
142                                       bool in_script_file,
143                                       const std::string& script_file,
144                                       int script_line 
145                                       )
146     : Exception("interpreter",0,message),
147       mInScriptFile(in_script_file),
148       mScriptFile(script_file),
149       mScriptLine(script_line)
150   {
151   }
152   //=======================================================================
153   //=======================================================================
154   InterpreterException::InterpreterException( const Exception& excep,
155                       bool in_script_file,
156                       const std::string& script_file,
157                       int script_line 
158                       )
159     : Exception(excep),
160       mInScriptFile(in_script_file),
161       mScriptFile(script_file),
162       mScriptLine(script_line)
163   {
164   }
165   //=======================================================================
166 */
167
168   //=======================================================================
169   void Interpreter::CatchInterpreterException( const InterpreterException& e )
170   {
171     if (GetExecuter()->GetNoErrorMode()) 
172       {
173         bbtkWarning("ERROR :"<<e.GetErrorMessage()
174                     <<" ("<<e.GetScriptFile()<<":"<<e.GetScriptLine()
175                     <<" skipped");
176
177         return;
178       }
179           
180           bbtk::InterpreterVirtual::CatchInterpreterException(  e );      
181   }
182   //=======================================================================
183
184   //=======================================================================
185   void Interpreter::CatchBbtkException( const bbtk::Exception& e )
186   {
187     if (GetExecuter()->GetNoErrorMode()) 
188       {
189         std::string file("?");
190         int line = 0;
191         if (mFileName.size()) {
192           file = mFileName.back();
193           line = mLine.back();
194         }    
195         bbtkWarning("ERROR '"<<e.GetErrorMessage()
196                     <<"' ("<<file<<":"<<line<<") skipped");
197         
198         return;
199       }
200           
201           bbtk::InterpreterVirtual::CatchBbtkException(  e );     
202   }
203   //=======================================================================
204   
205   //=======================================================================
206   void Interpreter::CatchStdException( const std::exception& e )
207   {  
208         if (GetExecuter()->GetNoErrorMode()) 
209         {
210                 std::string file("?");
211                 int line = 0;
212                 if (mFileName.size()) 
213                 {
214                         file = mFileName.back();
215                         line = mLine.back();
216                 }    
217                 bbtkWarning("ERROR '"<<e.what() <<"' ("<<file<<":"<<line<<") skipped");
218                 return;
219       }
220           bbtk::InterpreterVirtual::CatchStdException(  e );      
221   }
222   //=======================================================================
223
224   //=======================================================================
225   void Interpreter::CatchUnknownException()
226   {
227         if (GetExecuter()->GetNoErrorMode()) 
228         {
229                 std::string file("?");
230                 int line = 0;
231                 if (mFileName.size()) 
232                 {
233                         file = mFileName.back();
234                         line = mLine.back();
235                 }  
236                 bbtkWarning("UNDEFINED ERROR " <<"("<<file<<":"<<line<<") skipped");
237                 return;
238         }
239
240           bbtk::InterpreterVirtual::CatchUnknownException( );     
241   }
242   //=======================================================================
243
244   //=======================================================================
245   
246 #define CATCH_MACRO                                     \
247   catch (InterpreterException e)                        \
248     {                                                   \
249       CatchInterpreterException(e);                     \
250     }                                                   \
251   catch (bbtk::Exception e)                             \
252     {                                                   \
253       CatchBbtkException(e);                            \
254     }                                                   \
255   catch (std::exception& e)                             \
256     {                                                   \
257       CatchStdException(e);                             \
258     }                                                   \
259   catch (...)                                           \
260     {                                                   \
261       CatchUnknownException();                          \
262     }                                           
263   //=======================================================================
264    
265 /*EED Borrame
266   //=======================================================================
267   Interpreter::ExitStatus Interpreter::InterpretFile( const std::string& filename, bool source )
268   {
269     bbtkDebugMessage("interpreter",4,"==> Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl);
270
271     bool exm = mCommandLine;
272     mCommandLine = false;
273
274     try 
275     {
276       mStatus = Interpreter_OK;
277       SwitchToFile(filename,source);
278       mInsideComment = false;
279       InterpretCurrentStreams();
280     } 
281     CATCH_MACRO;
282     
283     bbtkDebugMessage("interpreter",4,
284                      "<== Interpreter::InterpretFile(\""
285                      <<filename<<"\")"<<std::endl);
286
287
288     mCommandLine = exm;
289     
290     return mStatus;
291   }
292   //=======================================================================
293
294
295   //=======================================================================
296   Interpreter::ExitStatus 
297   Interpreter::InterpretBuffer( std::stringstream* buffer )
298   {
299     bbtkDebugMessage("interpreter",4,"==> Interpreter::InterpretBuffer()"<<std::endl);
300
301     bool exm = mCommandLine;
302     mCommandLine = false;
303
304     try 
305     {
306       mStatus = Interpreter_OK;
307       SwitchToStream(buffer);
308       mInsideComment = false;
309       InterpretCurrentStreams();
310     }
311     CATCH_MACRO;
312     
313     //    CloseAllFiles();
314     bbtkDebugMessage("interpreter",4,"<== Interpreter::InterpretBuffer()"<<std::endl);
315
316     
317     mCommandLine = exm;
318     return mStatus;
319   }
320   //=======================================================================
321
322   //=======================================================================
323   /// Interprets the currently open streams
324   Interpreter::ExitStatus Interpreter::InterpretCurrentStreams()
325   {
326     bbtkDebugMessage("interpreter",4,
327                      "==> Interpreter::InterpretCurrentStreams()"<<std::endl);
328
329     while (mFile.size()>0) 
330       {
331         while (!mFile.back()->eof()) {
332           mLine.back()++;
333           char buf[500];
334           mFile.back()->getline(buf,500);
335           std::string str(buf);
336           //size 0 JCP 21-09-2009
337           int size=str.length();
338           if(size != 0){
339                   if ( str[ size-1 ]==13  )
340             {
341               str.erase(size-1,1);
342             }
343                   try
344                         {
345                           DoInterpretLine(str);
346                         }
347                   CATCH_MACRO;
348           }
349           
350         } 
351         CloseCurrentFile();
352       }
353     bbtkDebugMessage("interpreter",4,
354                      "<== Interpreter::InterpretCurrentStreams()"<<std::endl);
355
356     return mStatus;
357   }
358   //=======================================================================
359
360   //=======================================================================
361   /// Runs the interpretation of a command
362   Interpreter::ExitStatus Interpreter::InterpretLine( const std::string& line )
363   {
364     bbtkDebugMessage("interpreter",5,"==> Interpreter::InterpretLine('"<<line<<"')"<<std::endl);
365
366     try 
367     {
368       mStatus = Interpreter_OK;
369       mInsideComment = false;
370 //std::cout<<"JCP bbtkInterpreter.cxx Interpreter::InterpretLine("<<std::endl;
371       DoInterpretLine(line );
372     }
373     CATCH_MACRO;
374     
375     
376    bbtkDebugMessage("interpreter",5,"<== Interpreter::InterpretLine('"<<line<<"')"<<std::endl);
377     
378     return mStatus;
379   }
380   //=======================================================================  
381 */
382         
383         
384         void Interpreter::commandNew(const std::string &boxType,const  std::string &boxName)  //virtual
385     {
386                 mVirtualExecuter->Create(boxType,boxName);
387     }
388         
389         void Interpreter::commandDelete(const std::string &boxName)  //virtual
390     {
391                 mVirtualExecuter->Destroy(boxName);
392     }
393
394         void Interpreter::commandConnection(const std::string &nodeFrom,const  std::string &outputLabel,const  std::string &nodeTo,const  std::string &inputLabel) //virtual
395     {
396                 mVirtualExecuter->Connect(nodeFrom,outputLabel,nodeTo,inputLabel);
397     }
398                 
399         void Interpreter::commandPackage(const std::string &packageName) //virtual
400     {
401                 mVirtualExecuter->BeginPackage(packageName);
402     }
403         
404         void Interpreter::commandEndPackage() //virtual
405     {
406                 mVirtualExecuter->EndPackage();
407     }
408         
409         void Interpreter::commandDefine(const std::string &name,const  std::string &pack,const  std::string &scriptfilename) //virtual
410     {
411                 mVirtualExecuter->Define(name,pack,scriptfilename);
412     }
413
414         void Interpreter::commandEndDefine() //virtual
415     {
416                 mVirtualExecuter->EndDefine();
417     }
418
419         void Interpreter::commandKind(const std::string &kind) //virtual
420     {
421                 mVirtualExecuter->Kind(kind);
422     }
423         
424         void Interpreter::commandPrint(const std::string &value) //virtual
425     {
426                 mVirtualExecuter->Print(value);
427     }
428         
429         
430         void Interpreter::commandExec(const std::string &word) //virtual
431     {
432                 if (word=="freeze") 
433                 {
434                         mVirtualExecuter->SetNoExecMode(true);
435                         mThrow = false;
436                 }
437                 else if (word=="freeze_no_error") 
438                 {
439                         mVirtualExecuter->SetNoExecMode(true);
440                         mVirtualExecuter->SetNoErrorMode(true);
441                         mThrow = false;
442                 }
443                 else if (word=="unfreeze") 
444                 {
445                         mVirtualExecuter->SetNoExecMode(false);
446                         mVirtualExecuter->SetNoErrorMode(false);
447                 }
448                 else
449                 {
450                         mVirtualExecuter->Execute(word);
451                 } // if
452     }
453         
454         
455         void Interpreter::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string  &help) //virtual
456     {
457                 mVirtualExecuter->DefineInput(name,box,input,help);
458     }
459         
460         void Interpreter::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string  &help) //virtual
461     {
462                 mVirtualExecuter->DefineOutput(name,box,output,help);
463     }
464         
465         void Interpreter::commandSet(const std::string &box,const std::string &input,const std::string &value) //virtual
466     {
467                 mVirtualExecuter->Set(box,input,value);
468     }
469
470         void Interpreter::commandAuthor(const std::string &author) //virtual
471     {
472                 mVirtualExecuter->Author(author);
473     }
474
475         void Interpreter::commandCategory(const std::string &categorytype) //virtual
476     {
477                 mVirtualExecuter->Category(categorytype);
478     }
479         
480         void Interpreter::commandDescription(const std::string &description) //virtual
481     {
482                 mVirtualExecuter->Description(description);
483     }
484
485         
486         void Interpreter::commandClear() //virtual
487     {
488                 mVirtualExecuter->Clear();
489     }
490         
491         void Interpreter::commandInclude(const std::string &word, bool ok) //virtual
492     {
493                 // if 'source' was given (words.size()==3) then tell to set the 
494                 // source file name of the current complex box with the full file name included
495                 if (mCommandLine)
496                 {
497                         InterpretFile(word, ok ); 
498                 }
499                 else
500                 {
501                         SwitchToFile(word , ok );
502                 }
503     }
504         
505         
506         void Interpreter::commandLoad(const std::string &packageName) //virtual
507     {
508                 GetExecuter()->LoadPackage(packageName);
509     }
510
511         void Interpreter::commandUnload(const std::string &packageName) //virtual
512     {
513                 GetExecuter()->UnLoadPackage(packageName);
514     }
515         
516         void Interpreter::commandBreak() //virtual
517     {
518             /*
519                  std::cout << "BreakException(" 
520                  <<in_script<<","
521                  <<file<<","
522                  <<line<<")"<<std::endl;
523                  */
524                 bbtkError("break");//,in_script,file,line);
525             //      throw BreakException(in_script,file,line);
526     }
527         
528         void Interpreter::commandQuit() //virtual
529     {
530                 bbtkError("quit");//,in_script,file,line);
531                 //throw QuitException(in_script,file,line);
532     }
533         
534         void Interpreter::commandMessage() //virtual
535     {
536                 mVirtualExecuter->HelpMessages();
537     }
538         
539         void Interpreter::commandMessage(const std::string &kind,const std::string &levelstr) //virtual
540     {
541                 int level=0;
542                 sscanf(levelstr.c_str(),"%d",&level);
543                 mVirtualExecuter->SetMessageLevel(kind,level);
544
545     }
546         
547         
548 /*EED Borrame   
549   //=======================================================================  
550   void Interpreter::DoInterpretLine( const std::string& line ) //virtual
551    {
552     bbtkDebugMessage("interpreter",6,"==> Interpreter::DoInterpretLine(\""
553                      <<line<<"\")"<<std::endl);
554     std::vector<std::string> words;
555     SplitLine(line,words);
556
557     // Empty line
558     if (words.size()<1) 
559     {
560        bbtkDebugDecTab("interpreter",9);
561        return;
562     }
563
564     // Single line comment : # or //
565     if ( words[0][0]=='#' || (words[0][0]=='/' && words[0][1]=='/') ) 
566     {  
567        bbtkDebugDecTab("interpreter",9);
568        bbtkMessage("interpreter",9,"Comment"<<std::endl);
569        return;
570     }
571
572     // Multi line comment ( / * ... * / ) -delimiters on different lines !-   <<<<<<<  / *     * /
573     
574     if (words[0][0]=='/' && words[0][1]=='*') 
575     {  
576        bbtkDebugDecTab("interpreter",9);
577        bbtkMessage("interpreter",9,"In multiline comment"<<std::endl);
578        mInsideComment = true;
579        return;
580     }
581
582     if (words[0][0]=='*' && words[0][1]=='/') 
583     {  
584        bbtkDebugDecTab("interpreter",9);
585        bbtkMessage("interpreter",9,"Out multiline comment"<<std::endl);
586        if ( !mInsideComment ) {
587           bbtkDebugDecTab("interpreter",9);
588           bbtkMessage("interpreter",9,"Comment mismatch : '* /' with no matching '/ *'"<<std::endl);        <<<<<<<<< * /       / * 
589        }
590        mInsideComment = false;
591        return;
592     }
593
594     if (mInsideComment) 
595     {  
596        bbtkDebugDecTab("interpreter",9);
597        bbtkMessage("interpreter",9,"Multiline Comment"<<std::endl);
598        return;
599     }
600
601     // Command 
602     CommandInfoType command;
603     InterpretCommand(words,command);
604 //std::cout<<"JCP bbtkInterpreter command.keyword ="<<command.keyword<<std::endl;
605     bbtkDebugMessage("interpreter",9,
606                      "Command='"<<command.keyword
607                       <<"' code="<<command.code<<std::endl); 
608           
609     std::string left,right,left2,right2;
610     std::string filename;
611
612 //ups1 EED borrame        
613     // message command
614     if (command.code==cMessage)
615       {
616         if (words.size()<3)
617           {
618                   commandMessage();
619 //EED Borrame       mVirtualExecuter->HelpMessages();
620           }
621         else
622           {
623                 commandMessage(words[1],words[2]);
624 //EED Borrame           sscanf(words[2].c_str(),"%d",&level);
625 //EED Borrame       mVirtualExecuter->SetMessageLevel(words[1],level);
626           }
627         return;
628       }
629     else 
630       {
631         bbtkMessage("echo",2,line<<std::endl);
632       }
633
634     // break and quit commands
635     if ((command.code==cBreak) || (command.code==cQuit))
636       {
637         bool in_script = false;
638         std::string file("");
639         int line = 0;
640
641         if (mFileName.size()) 
642           {
643             std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
644             if (fs!=0) in_script = true;          
645             file = mFileName.back();
646             line = mLine.back();
647           } 
648         if (command.code==cBreak)
649           {
650 //          std::cout << "BreakException(" 
651 //                    <<in_script<<","
652 //                    <<file<<","
653 //                    <<line<<")"<<std::endl;
654                   commandBreak();
655 //EED Borrame       bbtkError("break");//,in_script,file,line);
656             //      throw BreakException(in_script,file,line);
657           }       
658         else 
659           {
660                   commandQuit();
661 //EED Borrame       bbtkError("quit");//,in_script,file,line);
662               //throw QuitException(in_script,file,line);
663           }
664         return;
665       }   
666 //std::cout<<" mVirtualExecuter->Create(words[1],words[2]); "<<line<<std::endl;
667     // other cammands
668
669     switch (command.code) 
670       {
671       case cNew :
672                 commandNew(words[1],words[2]);
673 //EED Borrame        mVirtualExecuter->Create(words[1],words[2]);
674         break;
675
676       case cDelete :
677                           commandDelete(words[1]);
678 //EED Borrame   mVirtualExecuter->Destroy(words[1]);
679         break;
680
681       case cConnect :
682         Utilities::SplitAroundFirstDot(words[1],left,right);
683         Utilities::SplitAroundFirstDot(words[2],left2,right2);      
684         commandConnection(left,right,left2,right2);
685 //EED Borrame        mVirtualExecuter->Connect(left,right,left2,right2);
686         break;
687
688       case cPackage :
689                           commandPackage(words[1]);
690 //EED Borrame                mVirtualExecuter->BeginPackage(words[1]);
691         break;
692
693       case cEndPackage :
694                           commandEndPackage();
695 //EED Borrame        mVirtualExecuter->EndPackage();
696         break;
697
698       case cDefine :
699         if (mFileName.size()>0) 
700         {
701 //???                   commandDefine(????);
702                    filename = mFileName.back(); //mIncludeFileName.back(); //Utilities::get_file_name(mFileName.back());
703         }
704         if (words.size()==2) 
705         {
706                         commandDefine(words[1],"",filename);
707 //EED Borrame           mVirtualExecuter->Define(words[1],"",filename);
708         }
709         else
710         {
711                         commandDefine(words[1],words[2],filename);
712 //EED Borrame           mVirtualExecuter->Define(words[1],words[2],filename);
713         }
714         break;
715
716       case cEndDefine :
717                 commandEndDefine();
718 //EED Borrame        mVirtualExecuter->EndDefine();
719         break;
720
721       case cKind :
722                         commandKind(words[1]);
723 //EED Borrame        mVirtualExecuter->Kind(words[1]);
724         break;
725
726       case cPrint :
727                           commandPrint(words[1]);
728 //EED Borrame        mVirtualExecuter->Print(words[1]);
729         break;
730                           
731       case cExec :
732                           commandExec(words[1]);
733 //EED Borrame        if (words[1]=="freeze") 
734 //EED Borrame     {
735 //EED Borrame       mVirtualExecuter->SetNoExecMode(true);
736 //EED Borrame       mThrow = false;
737 //EED Borrame     }
738 //EED Borrame   else if (words[1]=="freeze_no_error") 
739 //EED Borrame     {
740 //EED Borrame       mVirtualExecuter->SetNoExecMode(true);
741 //EED Borrame       mVirtualExecuter->SetNoErrorMode(true);
742 //EED Borrame       mThrow = false;
743 //EED Borrame     }
744 //EED Borrame   else if (words[1]=="unfreeze") 
745 //EED Borrame     {
746 //EED Borrame       mVirtualExecuter->SetNoExecMode(false);
747 //EED Borrame       mVirtualExecuter->SetNoErrorMode(false);
748 //EED Borrame     }
749 //EED Borrame   else
750 //EED Borrame     {
751 //EED Borrame       mVirtualExecuter->Execute(words[1]);
752 //EED Borrame     }
753                           
754         break;
755
756       case cInput :
757         Utilities::SplitAroundFirstDot(words[2],left,right);
758                           commandInput(words[1],left,right,words[3]);
759 //EED Borrame        mVirtualExecuter->DefineInput(words[1],left,right,words[3]);
760         break;
761
762       case cOutput :
763         Utilities::SplitAroundFirstDot(words[2],left,right);
764                 commandOutput(words[1],left,right,words[3]);
765 //EED Borrame         mVirtualExecuter->DefineOutput(words[1],left,right,words[3]);
766         break;
767
768       case cSet :
769         Utilities::SplitAroundFirstDot(words[1],left,right);
770                 commandSet(left,right,words[2]);
771 //EED Borrame        mVirtualExecuter->Set(left,right,words[2]);
772         break;
773
774       case cAuthor :
775                 commandAuthor(words[1]);
776 //EED Borrame        mVirtualExecuter->Author(words[1]);
777         break;
778
779       case cNewGUI :
780                 commandNewGUI(words[1],words[2]);
781         break;
782
783       case cCategory :
784                 commandCategory(words[1]);
785 //EED Borrame   mVirtualExecuter->Category(words[1]);
786         break;
787
788       case cIndex :
789         if (words.size()==1)
790                         commandIndex("tmp_index.html");
791         else if (words.size()==2)
792                         commandIndex(words[1]);
793         else if (words.size()==3)
794                         commandIndex(words[1],words[2]);
795         break;
796
797       case cDescription :
798                 commandDescription(words[1]);
799 //EED Borrame        mVirtualExecuter->Description(words[1]);
800         break;
801
802       case cHelp :
803         commandHelp(words);
804         break;
805
806
807       case cGraph :
808         commandGraph(words);
809         break;
810
811       case cConfig :
812         commandConfig();
813         break;
814
815       case cReset :  
816         commandReset();
817         break;
818         
819       case cClear :  
820                 commandClear();
821 //EED Borrame           mVirtualExecuter->Clear();
822         break;
823
824       case cInclude :
825                           commandInclude( words[1] , (words.size()==3) );
826 //EED Borrame           // if 'source' was given (words.size()==3) then tell to set the 
827 //EED Borrame           // source file name of the current complex box with the full file name included
828 //EED Borrame           if (mCommandLine)
829 //EED Borrame        {
830 //EED Borrame           InterpretFile(words[1],(words.size()==3)); 
831 //EED Borrame        } else{
832 //EED Borrame            SwitchToFile(words[1],(words.size()==3) );
833 //EED Borrame        }
834                 break;
835
836       case cLoad:
837                 commandLoad( words[1] );
838 //EED Borrame        GetExecuter()->LoadPackage(words[1]);
839         break;
840
841       case cUnload:
842                 commandUnload( words[1] );
843 //EED Borrame        GetExecuter()->UnLoadPackage(words[1]);
844         break;
845
846       case cDebug :
847                           if (words.size()==2) commandDebug(words[1]);
848                                 else commandDebug("");
849         break;
850                           
851         // obsolete
852     //  case cWorkspace :
853     //    if (words.size() == 2) 
854     //    {
855     //       if (words[1]=="freeze")        mVirtualExecuter->SetNoExecMode(true);
856     //       else if (words[1]=="unfreeze") mVirtualExecuter->SetNoExecMode(false);
857     //    }
858     //    else
859     //    {
860     //       mVirtualExecuter->SetWorkspaceName(words[2]);
861     //    }
862     //    break;
863
864                 default:
865         bbtkInternalError("should not reach here !!!");
866    }
867
868     bbtkDebugMessage("interpreter",6,"<== Interpreter::DoInterpretLine(\""
869                      <<line<<"\")"<<std::endl);
870     
871   }
872   //=======================================================================  
873
874
875
876
877   //=======================================================================
878   void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>& tokens)
879 {
880     bbtkDebugMessage("interpreter",9,"==> Interpreter::SplitLine(\""<<str<<"\")"<<std::endl);
881
882     std::string delimiters = "\"";
883     std::vector<std::string> quote;
884     Utilities::SplitString(str,delimiters,quote);
885
886     delimiters = " \t";
887     std::vector<std::string>::iterator i;
888     for (i=quote.begin(); i!=quote.end(); ) 
889     {
890        Utilities::SplitString(*i,delimiters,tokens);
891        ++i;
892        if (i!=quote.end()) 
893        {
894         //    bbtkDebugMessage("interpreter",0,"\""<<*i<<"\""<<std::endl);
895           tokens.push_back(*i);
896           ++i;
897        }
898     }
899
900     for (i=tokens.begin(); i!=tokens.end(); ++i) 
901     {
902       bbtkDebugMessage("interpreter",9,"--["<<*i<<"]"<<std::endl);
903     }
904     bbtkDebugMessage("interpreter",9,"<== Interpreter::SplitLine(\""<<str<<"\")"<<std::endl);
905
906  }
907   //=======================================================================
908 */
909
910
911   //=======================================================================
912   void Interpreter::commandReset()  // virtual
913   {
914     // Cannot close all files if the reset command is read from a file !
915     CloseAllFiles();
916     mFileNameHistory.clear();
917     this->mVirtualExecuter->Reset();
918   }
919   //=======================================================================
920
921   //=======================================================================
922   /**
923    *
924    */
925   /*
926   void Interpreter::Print( const std::string& str)
927   {
928     if (mVirtualExecuter->GetNoExecMode()) return;
929
930     bbtkDebugMessageInc("interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
931
932  // TO DO :
933  // InterpretLine ("load std")
934  // InterpretLine("new ConcatStrings _C_ ") -> trouver un nom unique : # commande 
935  // InterpretLine("new Print _P_") 
936  // InterpretLine("connect _C_.Out _P_.In")
937  // int num = 1
938  
939
940     std::vector<std::string> chains;
941     std::string delimiters("$");
942
943     // Skip delimiters at beginning.
944     std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
945     bool is_text = true;
946     if (lastPos>0) is_text = false;
947
948     // Find first delimiter.
949     std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
950
951     while (std::string::npos != pos || std::string::npos != lastPos)
952     {
953        if (is_text) 
954        {
955           // Found a text token, add it to the vector.
956           chains.push_back(str.substr(lastPos, pos - lastPos));
957  // std::string token = str.substr(lastPos, pos - lastPos)
958  // InterpretLine("set _C_.In%num% %token%")
959  
960        }
961        else 
962        {
963
964        // is an output (between $$) : decode 
965          std::string tok,box,output;
966          tok = str.substr(lastPos, pos - lastPos);
967          Utilities::SplitAroundFirstDot(tok,box,output);
968          chains.push_back( mVirtualExecuter->Get(box,output) );
969
970 // InterpretLine("connect %tok% _C_.In%num%") 
971
972        }
973         // Skip delimiters.  Note the "not_of"
974        lastPos = str.find_first_not_of(delimiters, pos);
975         // Find next delimiter
976        pos = str.find_first_of(delimiters, lastPos);
977     //
978        is_text = !is_text;
979 // num ++;
980      }
981 // InterpretLine("exec _P_")
982 // if (IS_IN_WORKSPACE) InterpretLine("delete _C_; delete _P_");
983
984      std::vector<std::string>::iterator i;
985      for (i= chains.begin(); i!=chains.end(); ++i) 
986      {
987
988        Utilities::SubsBackslashN(*i);
989        std::cout << *i;
990      }
991      std::cout << std::endl;
992      bbtkDebugDecTab("interpreter",9);
993  }
994 */
995
996   //=======================================================================
997   /**
998    *
999    */
1000 /*EED Borrame
1001   // =========================================================================
1002   void Interpreter::SwitchToFile( const std::string& name , bool source )
1003   {
1004   // Note : in the following :
1005   // name : the user supplied name 
1006   //      - abreviated name    e.g.       scr   scr.bbs
1007   //      - relative full name e.g.       ./scr.bbs   ../../scr.bbs 
1008   //      - absolute full name e.g.       /home/usrname/proj/dir/scr.bbs
1009   //          same for Windows, with      c:, d: ...
1010   //
1011   // use ./directory/subdir/scrname.bbs
1012   //
1013
1014     bbtkDebugMessage("interpreter",4,"==> Interpreter::SwitchToFile( \""
1015                      <<name<<"\")"<<std::endl);
1016
1017     std::vector<std::string> script_paths;
1018     std::string fullPathScriptName;  // full path script name
1019     std::string pkgname;             // e.g. <scriptname>.bbs
1020     std::vector<std::string> Filenames;
1021
1022     // The following is *NOT* a debug time message :
1023     // It's a user intended message.
1024     // Please don't remove it.
1025     bbtkMessage("interpreter",1,
1026         "look for : [" << name
1027         << "]" << std::endl);
1028
1029
1030     std::string upath;
1031     pkgname = Utilities::ExtractScriptName(name,upath);
1032
1033     bbtkMessage("interpreter",3,
1034                 "package name:[" << pkgname
1035                  << "] path:[" << upath << "]" << std::endl);
1036     bool fullnameGiven = false; 
1037     bool foundFile     = false;
1038
1039     // ==== "*" provided : load all scripts in given path 
1040     // relative (e.g. std/boxes/ *) or absolute      <<<<<<<< / *
1041     if (pkgname == "*") 
1042       {
1043
1044         std::stringstream* stream = new std::stringstream;
1045         //if (upath.size()!=0) // avoid troubles for "*"
1046         
1047         // ==== no path provided : look in root bbs path
1048         if (upath.size()==0)
1049           {
1050             //      bbtkMessage("interpreter",1,
1051             // LG : add all bbs path
1052             //  script_paths.push_back(  ConfigurationFile::GetInstance().Get_root_bbs_path() );
1053             std::vector<std::string>::const_iterator i;
1054             for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin();
1055                  i!=ConfigurationFile::GetInstance().Get_bbs_paths().end();
1056                  i++)
1057               {
1058                 script_paths.push_back(*i);
1059               }
1060           }
1061         // ==== absolute path provided 
1062         else if (upath[0]=='/' || upath[1] == ':' ) 
1063           {
1064             if ( Utilities::IsDirectory( upath ) )
1065               {
1066                 script_paths.push_back(upath);
1067               }
1068             else 
1069               {
1070                 bbtkError("'"<<upath<<"' : directory does not exist"); 
1071               }
1072           }
1073         // ==== relative path provided : search all bbs path appended with 
1074         // the relative path provided
1075         else
1076           {    
1077             std::vector<std::string>::const_iterator i;
1078             for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin();
1079                  i!=ConfigurationFile::GetInstance().Get_bbs_paths().end();
1080                  i++)
1081               {
1082                 std::string full_path(*i);
1083                 // we *really* want '.' to be the current working directory
1084                 if (full_path == ".") 
1085                   {
1086                     char buf[2048]; // for getcwd
1087                     char * currentDir = getcwd(buf, 2048);
1088                     std::string cwd(currentDir);
1089                     full_path = currentDir;
1090                   } // if full_path
1091                 
1092                 full_path += ConfigurationFile::GetInstance().Get_file_separator();
1093                 full_path += upath;
1094                 
1095                 if ( Utilities::IsDirectory( full_path ) )
1096                   {
1097                     script_paths.push_back(full_path);
1098                   }
1099               } 
1100             if (script_paths.empty())
1101               {
1102                 bbtkError("no '"<<upath<<"' subdir found in search paths" 
1103                           << std::endl);
1104               }
1105           }
1106         
1107         
1108         // === search paths list complete : now explore it
1109         int nbBssFiles = 0;     
1110         // ==== relative name, iterate + load all .bbs/.bbp files
1111         std::vector<std::string>::iterator i;
1112         for (i=script_paths.begin();i!=script_paths.end();i++)
1113           {
1114             bbtkMessage("interpreter",1,
1115                         "--> Looking in '" << *i << "'" << std::endl);
1116             
1117             Filenames.clear();
1118             //int nbFiles = 
1119             Utilities::Explore(*i, false, Filenames);
1120             
1121             for (std::vector<std::string>::iterator j = Filenames.begin(); 
1122                  j!= Filenames.end(); ++j)
1123               {
1124                 int lgr = (*j).size();
1125                 if (lgr < 5) continue;  
1126                 // ignore non .bbp file
1127                 if ( (*j).substr(lgr-4, 4) != ".bbp") continue; 
1128                 
1129                 (*stream) << "include \"" << *j << "\"\n";
1130                 bbtkMessage("interpreter",2,"  --> Found '" << *j << "'" << std::endl);
1131                 
1132                 nbBssFiles++;
1133               } // for (std::vector...
1134           } // for (i=script_...
1135
1136         // === Result ...
1137         if (nbBssFiles==0)
1138           {
1139             bbtkMessage("interpreter",1,
1140                         "  --> No .bbp found"<< std::endl);
1141           } 
1142         else 
1143           {
1144             bbtkMessage("interpreter",1,
1145                         "  --> "<<nbBssFiles<<" .bbp found"<< std::endl);
1146             SwitchToStream(stream);
1147           }
1148         return;
1149       }  
1150     //=============== end pkgname=="*" ===========
1151     
1152     
1153     // if name starts with a / or a . or contains : user is assumed to have passed a relative/absolute name
1154     // (not only a plain script name)
1155     // we trust him, and try to expland the directory name
1156     // WARNING : starting from current local directory :  ./whatYouWant  (./ mandatory!)
1157
1158     if (name[0]=='/' || name[1] == ':' || name[0]=='.')  // absolute path (linux/windows) or relative path
1159     { 
1160
1161       // ===========================================================check user supplied location
1162       fullnameGiven = true;
1163
1164       fullPathScriptName =  Utilities::ExpandLibName(name, false);
1165
1166       // allow user to always forget ".bbs"
1167       int l = fullPathScriptName.size();
1168
1169       if (l!=0) 
1170           {
1171          if ((fullPathScriptName.substr(l-4, 4) != ".bbs")&&
1172                          (fullPathScriptName.substr(l-4, 4) != ".bbp"))
1173          {
1174                         std::string tfullPathScriptName = fullPathScriptName + ".bbs";
1175                         if ( Utilities::FileExists(tfullPathScriptName) )
1176                         {
1177                                 fullPathScriptName = tfullPathScriptName;
1178                                 foundFile = true;
1179                         }
1180                         else 
1181                         {
1182                                 tfullPathScriptName = fullPathScriptName + ".bbp";
1183                                 if ( Utilities::FileExists(tfullPathScriptName) )
1184                                 {
1185                                         fullPathScriptName = tfullPathScriptName;
1186                                         foundFile = true;
1187                                 }
1188                         }
1189                  }
1190                  else 
1191                  {
1192                         if ( Utilities::FileExists(fullPathScriptName) )
1193                         {
1194                                 foundFile = true;
1195                         }
1196                  }
1197           } // endif l != 0
1198   }
1199   else
1200   // =============================== iterate on the paths
1201   {
1202       script_paths = ConfigurationFile::GetInstance().Get_bbs_paths();
1203       std::string path;
1204       std::vector<std::string>::iterator i;
1205       for (i=script_paths.begin();i!=script_paths.end();++i)
1206           {
1207                 path = *i;
1208                 // we *really* want '.' to be the current working directory
1209                 if (path == ".") 
1210                 {
1211                         char buf[2048]; // for getcwd
1212                         char * currentDir = getcwd(buf, 2048);
1213                         std::string cwd(currentDir);
1214                         path = currentDir;
1215                 }
1216           
1217                 std::string tfullPathScriptName = Utilities::MakePkgnameFromPath(path, name, false);
1218 //Addition JCP tfullPathScriptName.size()>=4 
1219                 if(tfullPathScriptName.size()>=4){
1220                         if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb")
1221                         {
1222                           fullPathScriptName = tfullPathScriptName;
1223                                 if ( ! Utilities::FileExists(fullPathScriptName) )
1224                                 {
1225                                         // The following is *NOT* a debug time message :
1226                                         // It's a user intended message.
1227                                         // Please don't remove it.
1228                                         bbtkMessage("interpreter",2,
1229                                   "   [" <<fullPathScriptName <<"] : does not exist" 
1230                                   <<std::endl);
1231                                         continue;  // try next path
1232                                 }
1233                                 bbtkMessage("interpreter",2,
1234                                           "   [" <<fullPathScriptName 
1235                                           <<"] : found" <<std::endl);
1236                                 foundFile = true;
1237                                 break; // a script was found; we stop iterating
1238                         }
1239                         else 
1240                         {
1241                                 fullPathScriptName = tfullPathScriptName + ".bbs";
1242                                 // Check if library exists
1243                                 if ( ! Utilities::FileExists(fullPathScriptName) )
1244                                 {
1245                                         fullPathScriptName = tfullPathScriptName + ".bbp";
1246                                         if ( ! Utilities::FileExists(fullPathScriptName) )
1247                                         {
1248                                                 // The following is *NOT* a debug time message :
1249                                                 // It's a user intended message.
1250                                                 // Please don't remove it.
1251                                                 bbtkMessage("interpreter",2,
1252                                                 "   [" <<tfullPathScriptName <<".bbs/.bbp] : do not exist" 
1253                                                 <<std::endl);
1254                                                 continue;  // try next path
1255                                         }
1256                                 }
1257                                 bbtkMessage("interpreter",2,
1258                                   "   [" <<fullPathScriptName 
1259                                   <<"] : found" <<std::endl);
1260                                 foundFile = true;
1261                                 break; // a script was found; we stop iterating
1262                         }
1263                 }               
1264         } //------------------ // end for ( package_paths.begin();i!=package_paths.end() )
1265   }
1266
1267     if (!foundFile)
1268       {
1269         if (fullnameGiven)
1270           if(fullPathScriptName == "")
1271             bbtkError("Path ["<<upath<<"] doesn't exist");
1272           else
1273             bbtkError("Script ["<<fullPathScriptName<<"] not found");
1274         else
1275           bbtkError("No ["<<pkgname<<".bbs/.bbp] script found");
1276         return;
1277       }
1278     else
1279         {
1280       LoadScript(fullPathScriptName,name);
1281           if (source) SetCurrentFileName(fullPathScriptName);
1282         }
1283     
1284     return;
1285   }
1286   //=======================================================================
1287 */
1288
1289         //=======================================================================
1290         void Interpreter::SetCurrentFileName(const std::string &fullPathScriptName)  // virtual 
1291         {
1292                 GetExecuter()->SetCurrentFileName(fullPathScriptName);
1293         }       
1294         //=======================================================================
1295         
1296         
1297         void Interpreter::SetTypeOfScript_Application()
1298         {
1299                 GetExecuter()->SetTypeOfScript_Application();
1300         }
1301
1302         
1303         
1304 /*EED Borrame   
1305   //=======================================================================
1306 void Interpreter::SwitchToStream( std::stringstream* stream )
1307 {
1308   bbtkDebugMessage("interpreter",4,"==> Interpreter::SwitchToStream()"
1309                    <<std::endl);
1310    mFile.push_back(stream);
1311     std::ostringstream buffer_name;
1312     bufferNb++;
1313     buffer_name << "buffer_" ;
1314
1315     if (mFileName.size()>0 )
1316     {
1317        buffer_name << mFileName.back() << "_" << mLine.back();
1318     }
1319     mFileName.push_back(buffer_name.str());
1320     mIncludeFileName.push_back(buffer_name.str());
1321     mLine.push_back(0);
1322 }
1323   //=======================================================================
1324 */
1325         
1326 /*      
1327   //=======================================================================
1328   void Interpreter::LoadScript( std::string fullPathScriptName,
1329                                 std::string includeScriptName)
1330   {
1331     bbtkDebugMessage("interpreter",4,"==> Interpreter::LoadScript("
1332                      <<fullPathScriptName<<")"
1333                      <<std::endl);
1334
1335     Utilities::replace( fullPathScriptName , 
1336                          INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
1337    
1338      if (find(mFileNameHistory.begin(),
1339               mFileNameHistory.end(),
1340               fullPathScriptName)!=mFileNameHistory.end())
1341      {
1342         return;
1343      }
1344
1345     std::ifstream* s;
1346     s = new std::ifstream;
1347     s->open(fullPathScriptName.c_str());
1348     if (!s->good())
1349     {
1350         bbtkError("Could not open file ["<<fullPathScriptName<<"]");
1351         return;
1352     }
1353
1354     bbtkMessage("interpreter",1,"   -->[" << fullPathScriptName 
1355                 << "] found" << std::endl);
1356
1357     mFile.push_back(s);
1358     mFileName.push_back(fullPathScriptName);
1359     mFileNameHistory.push_back(fullPathScriptName);
1360     mIncludeFileName.push_back(includeScriptName);
1361     mLine.push_back(0);
1362
1363     return;
1364   }
1365   //=======================================================================
1366 */
1367
1368 /*EED Borrame
1369   //=======================================================================
1370   void Interpreter::CloseCurrentFile()
1371   {
1372     bbtkDebugMessage("interpreter",9,"==> Interpreter::CloseCurrentFile()"
1373                       <<std::endl);
1374
1375     if (mFile.size()==0)
1376     {
1377       bbtkDebugMessage("interpreter",9," -> no file left open"<<std::endl);
1378       return;
1379     }
1380
1381     bbtkDebugMessage("interpreter",9," Closing file '"<<mFileName.back()<<"'"<<std::endl);
1382
1383     std::ifstream* file = dynamic_cast<std::ifstream*>(mFile.back());
1384     if (file!=0) file->close();
1385
1386     delete mFile.back();
1387     mFile.pop_back();
1388     mFileName.pop_back();
1389     mIncludeFileName.pop_back();
1390     mLine.pop_back();
1391
1392     bbtkDebugMessage("interpreter",9," Remains "
1393                      <<mFile.size()
1394                      <<" open"<<std::endl);
1395     bbtkDebugMessage("interpreter",9,"<== Interpreter::CloseCurrentFile()"
1396                      <<std::endl);
1397   }
1398   //=======================================================================
1399
1400  //=======================================================================
1401   void Interpreter::CloseAllFiles()
1402   {
1403     bbtkDebugMessage("interpreter",9,"==> Interpreter::CloseAllFiles()"
1404                       <<std::endl);
1405
1406     while (mFile.size() != 0) 
1407     {
1408        CloseCurrentFile();
1409     }
1410     bbtkDebugMessage("interpreter",9,"<== Interpreter::CloseAllFiles()"
1411                       <<std::endl);
1412   }
1413   //=======================================================================
1414
1415
1416   //=======================================================================
1417   void Interpreter::InterpretCommand( const std::vector<std::string>& words,
1418                                       CommandInfoType& info )
1419   {
1420     bbtkDebugMessage("interpreter",9,"==> Interpreter::InterpretCommand(...)"<<std::endl);
1421
1422     // searches the command keyword
1423     CommandDictType::iterator c;
1424     c = mCommandDict.find(words[0]);
1425     if ( c == mCommandDict.end() ) {
1426       bbtkError(words[0]<<" : unknown command");
1427     }
1428
1429     // tests the number of args 
1430     if ( ( ((int)words.size())-1 < c->second.argmin ) ||
1431          ( ((int)words.size())-1 > c->second.argmax ) )
1432     {
1433        commandHelp(words[0]);
1434        bbtkError(words[0]<<" : wrong number of arguments");
1435     }
1436 //std::cout<<"Interpreter::InterpretCommand( const std::vector<std::string>& words,"<<std::endl;
1437     info = c->second;
1438
1439     bbtkDebugMessage("interpreter",9,"<== Interpreter::InterpretCommand(...)"<<std::endl);
1440
1441   }
1442   //=======================================================================
1443  */
1444
1445
1446   //=======================================================================
1447   /// Displays help on all the commands
1448 void Interpreter::commandHelp(const std::vector<std::string>& words)
1449 {
1450     unsigned int nbarg = words.size()-1;
1451
1452     if (nbarg==0) 
1453     {
1454        HelpCommands();
1455     }
1456     else if (nbarg==1) 
1457     {
1458       if (words[1]=="packages") 
1459       {
1460          GetExecuter()->GetFactory()->PrintHelpListPackages(true);
1461          return;
1462       }
1463       try 
1464       {
1465           commandHelp(words[1]);
1466       }
1467       catch (bbtk::Exception e) 
1468       {
1469          try 
1470          {
1471             GetExecuter()->GetFactory()->PrintHelpPackage(words[1]);
1472             if ( mUser != 0 )
1473               {
1474                 std::string url = 
1475                   ConfigurationFile::GetInstance().Get_doc_path();
1476                 url += "/bbdoc/" + words[1] + "/index.html";
1477                 if (Utilities::FileExists(url)) 
1478                   {
1479                     mUser->InterpreterUserViewHtmlPage(url);
1480                   }
1481               }
1482          }
1483          catch (bbtk::Exception f) 
1484          {
1485            try 
1486              {
1487                std::string package;
1488                GetExecuter()->GetFactory()->PrintHelpDescriptor(words[1],
1489                                                                 package);
1490                if ( mUser != 0 )
1491                  {
1492                    std::string url = 
1493                      ConfigurationFile::GetInstance().Get_doc_path();
1494                    url += "/bbdoc/" + package + "/index.html";
1495                    if (Utilities::FileExists(url)) 
1496                      {
1497                        url += "#" + words[1];
1498                        mUser->InterpreterUserViewHtmlPage(url);
1499                      }
1500                  }
1501              }
1502            catch (bbtk::Exception g) 
1503              {
1504                try
1505                  {
1506                    GetExecuter()->PrintHelpBlackBox(words[1],"0","9999");
1507                  }
1508                catch (bbtk::Exception h){
1509                  bbtkError("\""<<words[1].c_str()
1510                            <<"\" is not a known command, package, black box type or black box name");
1511                }
1512              }
1513          }
1514       }
1515     }
1516     else if (nbarg==2) 
1517     {
1518       if (words[2]=="all")
1519       {
1520          if ( words[1]=="packages" )
1521          {
1522             GetExecuter()->GetFactory()->PrintHelpListPackages(true,true);
1523             return;
1524           }
1525          try 
1526          {
1527             GetExecuter()->GetFactory()->PrintHelpPackage(words[1],true);
1528          }
1529          catch (bbtk::Exception f) 
1530          {
1531          }
1532      }
1533      else 
1534      {
1535         commandHelp(words[0]);
1536         bbtkError(words[0]<<" : syntax error");
1537      }
1538   }
1539   else 
1540   {
1541      bbtkError("Should not reach here !!!");
1542   }
1543 }
1544   //=======================================================================
1545
1546    //===================================================================    
1547   /// Displays the Configuration
1548   void Interpreter::commandConfig() const
1549   {
1550     ConfigurationFile::GetInstance().GetHelp(1);
1551   }  
1552    //===================================================================    
1553
1554   //=======================================================================
1555   /// Displays help on all the commands
1556   void Interpreter::HelpCommands()
1557   {
1558     std::cout << "Available commands :" << std::endl;
1559     CommandDictType::iterator i;
1560     for ( i =  mCommandDict.begin();
1561           i != mCommandDict.end();
1562         ++i) {
1563               std::cout << " " << i->first << std::endl;
1564       //      std::cout << "   usage : " << i->second.syntax << std::endl;
1565       //     std::cout << "    " << i->second.help << std::endl;
1566
1567     }
1568   }
1569   //=======================================================================
1570
1571
1572         
1573   //=======================================================================
1574   /// Displays help on a particular commands
1575   void Interpreter::commandHelp(const std::string& s)
1576   {
1577     CommandDictType::iterator c;
1578     c = mCommandDict.find(s);
1579     if ( c == mCommandDict.end() ) {
1580       bbtkError(s<<" : Unknown command");
1581     }   
1582     //    std::cout << " " << s << " : "<<  std::endl;
1583     //    CommandParamDictType::iterator i;
1584     //    for ( i =  c->second.begin();
1585     //      i != c->second.end();
1586     //      ++i) {
1587     std::cout << " usage : " << c->second.syntax << std::endl;
1588     std::cout << "  " << c->second.help << std::endl;
1589
1590   }
1591   //=======================================================================
1592
1593 /*EED Borrame
1594   //=======================================================================
1595   /// Fills the vector commands with the commands which 
1596   /// have the first n chars of buf for prefix
1597   /// TODO : skip initial spaces in buf and also return the position of first
1598   /// non blank char in buf
1599   void Interpreter::FindCommandsWithPrefix( char* buf,
1600                                             int n,
1601                                             std::vector<std::string>& commands )
1602   {
1603     CommandDictType::const_iterator i;
1604     for (i=mCommandDict.begin(); i!=mCommandDict.end(); ++i)
1605     {
1606       if ((i->first).find(buf,0,n) == 0) 
1607         commands.push_back(i->first);
1608     }
1609   }
1610   //=======================================================================
1611 */
1612  
1613
1614 /*EED Borrame
1615   //=======================================================================
1616 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT
1617   
1618   inline void PrintChar(char c) { write(STDOUT_FILENO,&c,1); }
1619   inline void BackSpace() { write(STDOUT_FILENO,"\b \b",3); }
1620   
1621   // LG : KEYBOARD CODES AS SCANNED ON MY TTY : UNIVERSAL ?
1622   // IF NOT THE USER SHOULD BE ABLE TO CONFIGURE IT
1623   // E.G. STORE THIS IN bbtk_config.xml
1624 #define BBTK_UP_ARROW_KBCODE    0x00415B1B
1625 #define BBTK_DOWN_ARROW_KBCODE  0x00425B1B
1626 #define BBTK_RIGHT_ARROW_KBCODE 0x00435B1B
1627 #define BBTK_LEFT_ARROW_KBCODE  0x00445B1B
1628 #define BBTK_BACKSPACE_KBCODE   0x00000008
1629 #define BBTK_DEL_KBCODE         0x0000007F
1630 #define BBTK_SPACE_KBCODE       0x00000020 
1631
1632   //=======================================================================
1633   void Interpreter::GetLineFromPrompt(std::string& s)
1634   {
1635     int c;
1636     unsigned int ind=0;
1637
1638     unsigned int MAX_LINE_SIZE = 160;
1639     unsigned int MAX_HISTORY_SIZE = 100;
1640
1641     char* newline = new char[MAX_LINE_SIZE];
1642     memset(newline,0,MAX_LINE_SIZE);
1643     char* histline = new char[MAX_LINE_SIZE];
1644     memset(histline,0,MAX_LINE_SIZE);
1645
1646     char* line = newline;
1647     unsigned int hist = mHistory.size();
1648
1649     write(1,"> ",2);
1650     while(1)
1651     {
1652        c=0;
1653        read ( STDIN_FILENO, &c, 4) ;
1654
1655        bbtkDebugMessage("debug",9,"[0x"<<std::hex<<c<<"]\n");
1656
1657        // Printable character
1658        if ( (ind<MAX_LINE_SIZE-1) &&
1659             ( c >= BBTK_SPACE_KBCODE ) && 
1660             ( c <  BBTK_DEL_KBCODE )) 
1661        {
1662           PrintChar(c);
1663           line[ind++]=c;
1664        }
1665       // CR
1666        else if (c=='\n')
1667        {
1668        // delete the unused line
1669           if (line==newline)
1670               delete histline;
1671           else
1672               delete newline;
1673    
1674     // empty lines are not stored in from history
1675           if (strlen(line)) 
1676           {
1677              // if history too long : delete oldest command
1678              if (mHistory.size()>MAX_HISTORY_SIZE) 
1679              {
1680                 delete mHistory.front();
1681                 mHistory.pop_front();
1682              }
1683              mHistory.push_back(line);
1684           }
1685           break;
1686         }
1687        // Backspace
1688         else if ( (ind>0) && 
1689                   ((c == BBTK_BACKSPACE_KBCODE) ||
1690                    (c == BBTK_DEL_KBCODE)) )
1691           {
1692             line[ind--]=' ';
1693             BackSpace();
1694           }
1695         // Tab 
1696         else if (c=='\t')
1697           {
1698             // TODO : Command completion  
1699             std::vector<std::string> commands;
1700             FindCommandsWithPrefix( line,ind,commands);
1701             if (commands.size()==1) 
1702               {
1703                 std::string com = *commands.begin();
1704                 for (; ind<com.size(); ++ind) 
1705                   {
1706                     PrintChar(com[ind]); 
1707                     line[ind]=com[ind];
1708                   }
1709                 PrintChar(' '); 
1710                 line[ind++]=' ';
1711               }
1712             else if (commands.size()>1) 
1713               {
1714                 std::vector<std::string>::iterator i;
1715                 write(1,"\n",1);
1716                 for (i=commands.begin();i!=commands.end();++i) 
1717                   {
1718                     write(STDOUT_FILENO,(*i).c_str(),strlen((*i).c_str()));
1719                     PrintChar(' ');
1720                   }
1721                 write(STDOUT_FILENO,"\n> ",3);
1722                 //for (int j=0;j<ind;++j) 
1723                   //{
1724                     write(STDOUT_FILENO,line,ind); 
1725                     //  }
1726               }
1727           }
1728         // Arrow up : back in history
1729         else if (c==BBTK_UP_ARROW_KBCODE)
1730           {
1731             if (hist) 
1732               {
1733                 // erase current line
1734                 while (ind--) BackSpace();
1735                 // 
1736                 hist--;
1737                 // 
1738                 strcpy(histline,mHistory[hist]);
1739                 line = histline;
1740                 ind = strlen(line);
1741                 
1742                 write(STDOUT_FILENO,line,ind);
1743               }
1744           }
1745         // Arrow down : down in history
1746         else if (c==BBTK_DOWN_ARROW_KBCODE)
1747           {
1748             if (hist<mHistory.size()-1) 
1749               {
1750                 // erase current line
1751                 while (ind--) BackSpace();
1752                 // 
1753                 hist++;
1754                 // 
1755                 strcpy(histline,mHistory[hist]);
1756                 line = histline;
1757                 ind = strlen(line);
1758                 
1759                 write(STDOUT_FILENO,line,ind);
1760               }
1761             // end of history : switch back to newline
1762             else if (hist==mHistory.size()-1)
1763               {
1764                 // erase current line
1765                 while (ind--) BackSpace();
1766                 // 
1767                 hist++;
1768                 // 
1769                 line = newline;
1770                 ind = strlen(line);
1771                 
1772                 write(STDOUT_FILENO,line,ind);
1773               }
1774           }
1775         // Arrow right
1776         else if (line[ind]!=0 && c==BBTK_RIGHT_ARROW_KBCODE)
1777           {
1778             PrintChar(line[ind]);
1779             ind++;
1780           }
1781
1782         // Arrow left
1783         else if (ind>0 && c==BBTK_LEFT_ARROW_KBCODE)
1784           {
1785             PrintChar('\b');
1786             ind--;
1787     
1788           }
1789
1790       }
1791     write(STDOUT_FILENO,"\n\r",2);
1792     
1793     
1794     s = line;
1795     
1796   }
1797 #else
1798
1799   //=======================================================================
1800   void Interpreter::GetLineFromPrompt(std::string& s)
1801   {  
1802     s.clear();
1803
1804     putchar('>');
1805     putchar(' ');
1806
1807     do 
1808     {
1809       char c = getchar();
1810       if (c=='\n') 
1811       {
1812         putchar('\n');
1813         break;
1814       }
1815       if (c=='\t') 
1816       {
1817         // putchar('T');
1818         continue;
1819       }
1820       // putchar(c);
1821       s += c;
1822     } 
1823     while (true);  
1824     
1825   }
1826   //=======================================================================  
1827
1828 #endif
1829 */
1830
1831         
1832         
1833         
1834         
1835         
1836 /*EED Borrame
1837   //=======================================================================
1838   void Interpreter::CommandLineInterpreter()
1839   {
1840     bbtkDebugMessageInc("interpreter",9,
1841                         "Interpreter::CommandLineInterpreter()"<<std::endl);
1842
1843 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT  
1844     // Initialise the tty in non canonical mode with no echo
1845     // oter remembers the previous settings to restore them after 
1846     struct termios ter,oter;
1847     tcgetattr(0,&ter);
1848     oter=ter;
1849     ter.c_lflag &= ~ECHO;
1850     ter.c_lflag &= ~ICANON;
1851     ter.c_cc[VMIN]=1;
1852     ter.c_cc[VTIME]=0;
1853     tcsetattr(0,TCSANOW,&ter);
1854 #endif
1855     
1856     mCommandLine = true;
1857     bool again = true;
1858     // bool insideComment = false; // for multiline comment  
1859     mInsideComment = false;
1860     do 
1861     {
1862       try
1863       {
1864         std::string line;
1865         GetLineFromPrompt(line);
1866         DoInterpretLine(line); //, insideComment);
1867       }
1868  //     catch (QuitException e)
1869  //     {
1870  //     bbtkMessage("interpreter",1,"Interpreter : Quit"<<std::endl);
1871  //        again = false;
1872       }
1873       catch (bbtk::Exception e) 
1874       {
1875         e.Print();
1876       }
1877         catch (std::exception& e) 
1878       {
1879         std::cerr << "* ERROR :: "<<e.what()<<" (not in bbtk)"<<std::endl;
1880       }
1881       catch (...)
1882       {
1883         std::cerr << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
1884       }
1885     }
1886     while (again);
1887
1888 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT
1889     tcsetattr(0,TCSANOW,&oter);
1890 #endif
1891
1892     std::cout << "Good bye !" << std::endl;
1893
1894     bbtkDebugDecTab("interpreter",9);
1895   }
1896 */
1897                   
1898 //=======================================================================
1899 void Interpreter::commandGraph(const std::vector<std::string>& words)
1900 {
1901   std::string page;
1902     bool system_display = true;
1903
1904     if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) )
1905       system_display = false; 
1906  
1907     if (words.size()==1) 
1908     {
1909       page = mVirtualExecuter->ShowGraph(".","0","0","","","",system_display);
1910     }
1911     else if (words.size()==2) 
1912     {
1913       page = mVirtualExecuter->ShowGraph(words[1],"0","0","","","",system_display);
1914     }
1915     else if (words.size()==3) 
1916     {
1917       page = mVirtualExecuter->ShowGraph(words[1],words[2],"0","","","",system_display);
1918     }
1919     else if (words.size()==4) 
1920     {
1921       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],"","","",system_display);
1922     } 
1923     else if (words.size()==5) 
1924     {
1925       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],"","",system_display);
1926     } 
1927     else if (words.size()==6) 
1928     {
1929       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],"",system_display);
1930     } 
1931     else if (words.size()==7) 
1932       {
1933         page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display);
1934       } 
1935     
1936     if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) )
1937       mUser->InterpreterUserViewHtmlPage(page);
1938
1939   }
1940 //=======================================================================
1941
1942
1943 //=======================================================================
1944 void  Interpreter::commandIndex(const std::string& filename, 
1945                          const std::string& type)
1946 {
1947   Factory::IndexEntryType t;
1948   if (type=="Initials") t = Factory::Initials;
1949   else if (type=="Categories") t = Factory::Categories;
1950   else if (type=="Packages") t = Factory::Packages;
1951   else if (type=="Adaptors") t = Factory::Adaptors;
1952   
1953   GetExecuter()->GetFactory()->CreateHtmlIndex(t,filename);
1954 }
1955 //=======================================================================
1956
1957
1958 //=======================================================================
1959 void  Interpreter::commandNewGUI(const std::string& boxname,
1960                              const std::string& instanceName)
1961 {
1962   if (mRealExecuter.expired())
1963     {
1964       bbtkError("command 'newgui' cannot be compiled yet");
1965     }
1966
1967   std::string typeName = instanceName+"Type";
1968   std::stringstream* s = new std::stringstream;
1969   // create the complex box
1970   (*s) << "define "<<typeName<<std::endl;
1971   //  (*s) << "  description 'Automatically generated user interface for the box "
1972   //       << boxname << "'" <<std::endl;
1973   // create the Layout box
1974   (*s) << "  load wx"<<std::endl;
1975   (*s) << "  new LayoutLine layout"<<std::endl;
1976   // create the output 'Widget'
1977   (*s) << "  output Widget layout.Widget Widget"<<std::endl;
1978   // the box change output 
1979   (*s) << "  new MultipleInputs change"<<std::endl;
1980   (*s) << "  output BoxChange change.Out BoxChange"<<std::endl;
1981
1982   // Browse the inputs of the box in order to find which ones are not 
1983   // connected and can be adapted from a widget adaptor
1984   // vector which stores the list of inputs of the box which must be connected
1985   std::vector<std::string> in;
1986  
1987   Factory::Pointer F = mVirtualExecuter->GetFactory();
1988   /*
1989   Package::Pointer user = F->GetPackage("user");
1990   */
1991   ComplexBlackBoxDescriptor::Pointer workspace = 
1992     mRealExecuter.lock()->GetCurrentDescriptor();
1993
1994   if (workspace==0)
1995     {
1996       delete s;
1997       bbtkError("interpreter::CreateGUI : could not access the executer currently defined complex box");
1998     }
1999  
2000
2001   /*
2002     (ComplexBlackBoxDescriptor::Pointer)(user->GetBlackBoxMap().find("workspace")->second.get());
2003   */
2004
2005   BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname);
2006   //  BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap();
2007   // int nb = 0;
2008   BlackBox::InputConnectorMapType::iterator i;
2009   for (i=box->bbGetInputConnectorMap().begin();
2010        i!=box->bbGetInputConnectorMap().end();
2011        ++i)
2012     {
2013       // If the input is connected : continue
2014       if (i->second->IsConnected()) continue;
2015       // Get the input descriptor 
2016       const BlackBoxInputDescriptor* d = box->bbGetDescriptor()->GetInputDescriptor(i->first);
2017       // If it is a "system" input : skip it
2018 #ifdef USE_WXWIDGETS
2019       if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) ||
2020            ( d->GetCreatorTypeInfo() == typeid(WxBlackBoxDescriptor)) )
2021         continue;
2022 #else
2023 // JFGA 12/12/2014 Adding WT options for compile with it.
2024
2025 /*#if USE_WT
2026
2027         if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) ||
2028            ( d->GetCreatorTypeInfo() == typeid(WtBlackBoxDescriptor)) )
2029         continue;
2030         
2031
2032 #else
2033 */
2034       if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) )
2035         continue;
2036 //#endif
2037
2038 #endif
2039       bool widok = true;
2040       std::string widget,adaptor;
2041       // try to find a widget adaptor
2042       if (F->FindWidgetAdaptor(DataInfo(d->GetTypeInfo(),""),
2043                                d->GetDataInfo(),
2044                                adaptor))
2045         {
2046           // command to create the adaptor
2047           (*s) << "  new "<<adaptor<<" "<<i->first<<std::endl;
2048           // Sets the label of the widget adaptor to the name of the input
2049           (*s) << "  set "<<i->first<<".Label "<<i->first<<std::endl;
2050           // Sets the initial value of the widget to the value of the input
2051           (*s) << "  set "<<i->first<<".In \" "
2052                <<box->bbGetInputAsString(i->first)<<"\""
2053                << std::endl;
2054           // store the input name
2055           in.push_back(i->first);
2056           (*s) << "  connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
2057             //<i->first<<"'"<<std::endl;
2058           (*s) << "  connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
2059         }
2060       // try to find a two pieces adaptor
2061       else if (F->FindWidgetAdaptor2(DataInfo(d->GetTypeInfo(),""),
2062                                      d->GetDataInfo(),
2063                                      widget,adaptor) )
2064         {
2065           // command to create the widget
2066           (*s) << "  new "<<widget<<" "<<i->first<<"Widget"<<std::endl;
2067           // command to create the adaptor
2068           (*s) << "  new "<<adaptor<<" "<<i->first<<std::endl;
2069           // connect the two
2070           (*s) << "  connect "<<i->first<<"Widget.Out "
2071                <<i->first<<".In"<<std::endl;
2072           // Sets the label of the widget adaptor to the name of the input
2073           (*s) << "  set "<<i->first<<"Widget.Label "<<i->first<<std::endl;
2074           // Sets the initial value of the widget to the value of the input
2075           (*s) << "  set "<<i->first<<"Widget.In \" "
2076                <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
2077           // store the input name
2078           in.push_back(i->first);
2079           (*s) << "  connect "<<i->first<<"Widget.Widget layout.Widget"<<in.size()<<std::endl;
2080             //<i->first<<"'"<<std::endl;
2081           (*s) << "  connect "<<i->first<<"Widget.BoxChange change.In"<<in.size()<<std::endl;
2082
2083         }
2084       // try to find an adaptor from string 
2085       // If found then can create a text input which 
2086       // will be automatically adapted 
2087       else if (F->FindAdaptor(DataInfo(typeid(std::string),""),
2088                                d->GetDataInfo(),
2089                                adaptor))
2090         {
2091           // command to create the adaptor
2092           (*s) << "  new InputText "<<i->first<<std::endl;
2093           // Sets the label of the widget adaptor to the name of the input
2094           (*s) << "  set "<<i->first<<".Title "<<i->first<<std::endl;
2095           // Sets the initial value of the widget to the value of the input
2096           (*s) << "  set "<<i->first<<".In \" "
2097                <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
2098           // store the input name
2099           in.push_back(i->first);
2100           (*s) << "  connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
2101             //<i->first<<"'"<<std::endl;
2102           (*s) << "  connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
2103
2104         }
2105       else 
2106         {
2107           widok = false;
2108         }
2109       if (widok)
2110         {
2111           // command to create the output
2112           (*s) << "  output "<<i->first<<" "
2113                <<i->first<<".Out "<<i->first<<std::endl;
2114             //         <<" Output of the widget which allows to set "
2115           
2116         }
2117     }   
2118   // Inputs for window properties
2119   (*s) << "  input WinTitle layout.WinTitle Title"<<std::endl;
2120   (*s) << "  input WinWidth layout.WinWidth Width"<<std::endl;
2121   (*s) << "  input WinHeight layout.WinHeight Height"<<std::endl;
2122   (*s) << "  input WinDialog layout.WinDialog Dialog"<<std::endl;
2123   (*s) << "  input WinHide layout.WinHide Hide"<<std::endl;
2124
2125   
2126   
2127   // Execute the box executes the layout
2128   (*s) << "  exec layout" << std::endl;
2129   (*s) << "endefine" << std::endl;
2130   // (*s) << "help "<< typeName<< std::endl;
2131   // instanciate the box and connect it
2132   (*s) << "new "<<typeName<<" "<<instanceName<<std::endl;
2133   // connections
2134   std::vector<std::string>::iterator j;
2135   for (j=in.begin();j!=in.end();++j)
2136     {
2137       // connect
2138       (*s) << "connect "<<instanceName<<"."<<*j<<" "
2139            << boxname<<"."<<*j<<std::endl;
2140     }
2141   // That's all folks ! now execute the commands :
2142   SwitchToStream(s);
2143 }
2144 //=======================================================================
2145
2146
2147
2148  //==========================================================================
2149   void Interpreter::commandDebug(const std::string& name)
2150   {
2151     if ((name.length()==2)&&(name[0]=='-'))
2152       {
2153         if (name[1]=='D')
2154           {
2155             bbtk::StaticInitTime::PrintObjectListInfo = true;
2156           }
2157         if (name[1]=='C')
2158           {
2159             //      int o = MessageManager::GetMessageLevel("debug");
2160             //      if (o<2) MessageManager::SetMessageLevel("debug",2);
2161             mVirtualExecuter->GetFactory()->Check();
2162             //      MessageManager::SetMessageLevel("debug",o);
2163           }
2164       }
2165     else 
2166       {
2167         Object:: PrintObjectListInfo(name);
2168       }
2169   }
2170  //==========================================================================
2171
2172   /*
2173   //==========================================================================
2174   // Adds a callback when 'break' command issued
2175   void Interpreter::AddBreakObserver( BreakCallbackType c )
2176   {
2177     mBreakSignal.connect(c);
2178   }
2179  //==========================================================================
2180  */
2181
2182  //==========================================================================
2183   std::string Interpreter::GetObjectName() const
2184   {
2185     return std::string("Interpreter");
2186   }
2187   //==========================================================================
2188   
2189   //==========================================================================
2190   std::string  Interpreter::GetObjectInfo() const 
2191   {
2192     std::stringstream i;
2193     return i.str();
2194   }
2195   //==========================================================================
2196
2197   //==========================================================================
2198 size_t  Interpreter::GetObjectSize() const 
2199 {
2200   size_t s = Superclass::GetObjectSize();
2201   s += Interpreter::GetObjectInternalSize();
2202   return s;
2203   }
2204   //==========================================================================
2205   //==========================================================================
2206 size_t  Interpreter::GetObjectInternalSize() const 
2207 {
2208   size_t s = sizeof(Interpreter);
2209   return s;
2210   }
2211   //==========================================================================
2212   //==========================================================================
2213   size_t  Interpreter::GetObjectRecursiveSize() const 
2214   {
2215     size_t s = Superclass::GetObjectRecursiveSize();
2216     s += Interpreter::GetObjectInternalSize();
2217     s += mVirtualExecuter->GetObjectRecursiveSize();
2218     return s;
2219   }
2220   //==========================================================================
2221 }//namespace
2222
2223