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