]> Creatis software - bbtk.git/blob - kernel/src/bbtkExecuter.cxx
bbtk now depends on crea !
[bbtk.git] / kernel / src / bbtkExecuter.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkExecuter.cxx,v $
4   Language:  C++
5   Date:      $Date: 2008/12/11 15:30:04 $
6   Version:   $Revision: 1.24 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32  *  \file 
33  *  \brief class Executer: level 0 of script execution (code)
34  */
35
36 #include "bbtkExecuter.h"
37 #include "bbtkMessageManager.h"
38 #include "bbtkFactory.h"
39 #include "bbtkUtilities.h"
40 #include <fstream>
41
42 #ifdef USE_WXWIDGETS
43 #include <wx/textdlg.h>
44 #endif
45
46 #include "bbtkWxBlackBox.h"
47
48 #include "bbtkConfigurationFile.h"
49
50 namespace bbtk
51 {
52   //=======================================================================
53   Executer::Pointer Executer::New()
54   {
55     bbtkDebugMessage("Kernel",9,"Executer::New()"<<std::endl);
56     return MakePointer(new Executer());
57   }
58   //=======================================================================
59
60   //=======================================================================
61   Executer::Executer()
62     : 
63     mFactory(),
64     mRootPackage(),
65     mRootCBB(),
66     mNoExecMode(false),
67     mDialogMode(NoDialog)
68   {
69     bbtkDebugMessageInc("Kernel",9,"Executer::Executer()" <<std::endl);
70     mFactory = Factory::New();
71     // The smart pointer on this is not made yet (is made by New) 
72     // -> create it to pass it to the factory
73     // We have to "lock" the smart pointer because the factory
74     // only keeps a weak pointer on the executer
75     // -> this would auto-destroy !!
76     mFactory->SetExecuter(MakePointer(this,true));
77     Reset();
78     bbtkDebugDecTab("Kernel",9);
79   }
80   //=======================================================================
81
82   //=======================================================================
83   Executer::~Executer()
84   {
85      bbtkDebugMessageInc("Kernel",9,"==> Executer::~Executer()" <<std::endl);
86      mOpenDefinition.clear();
87      mOpenPackage.clear();
88      mFactory->Reset();
89      mFactory.reset();
90      bbtkDebugDecTab("Kernel",9);
91   }
92   //=======================================================================
93
94   //=======================================================================
95    /// Loads a package
96     void Executer::LoadPackage(const std::string &name )
97    {
98      GetFactory()->LoadPackage(name);
99    }
100   //=======================================================================
101
102   //=======================================================================
103     /// Unloads a package
104     void Executer::UnLoadPackage(const std::string &name )
105     {
106       GetFactory()->UnLoadPackage(name);
107     }
108   //=======================================================================
109
110   //=======================================================================
111   void Executer::Reset()
112   {
113     bbtkDebugMessageInc("Kernel",9,"Executer::Reset()" <<std::endl);
114
115     GetFactory()->CheckPackages();
116  
117     mOpenDefinition.clear();
118     mOpenPackage.clear();
119     GetFactory()->Reset();
120
121     // Create user package
122     Package::Pointer p =
123       Package::New("user","internal",
124                    "User defined black boxes",
125                    "",
126                    BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
127     // Insert the user package in the factory
128     GetFactory()->InsertPackage(p);
129     // And in the list of open packages
130     mOpenPackage.push_back(p);
131     mRootPackage = p;
132
133     // Create user workspace
134     ComplexBlackBoxDescriptor::Pointer r = 
135       ComplexBlackBoxDescriptor::New("workspace"); 
136     //    mRootCBB->Reference();
137     r->SetFactory(GetFactory());
138     r->AddToAuthor("bbtk");
139     r->AddToDescription("User's workspace");
140     mOpenDefinition.push_back(CBBDefinition(r,"user"));
141     // Register it into the user package
142     p->RegisterBlackBox(r);
143     mRootCBB = r;
144
145     //    Object::PrintObjectListInfo();
146     //  GetFactory()->CheckPackages();
147
148     bbtkDebugDecTab("Kernel",9);
149   }
150   //=======================================================================
151
152   //=======================================================================
153   /// changes the workspace name
154   void Executer::SetWorkspaceName( const std::string& n )
155   {
156     GetUserPackage()->ChangeBlackBoxName( GetWorkspace()->GetTypeName(), n );
157   }
158   //=======================================================================
159
160   //=======================================================================
161   void Executer::BeginPackage (const std::string &name)
162   {
163      bbtkDebugMessageInc("Kernel",9,"Executer::BeginPackage(\""<<name<<"\")"
164                         <<std::endl);
165      Package::Pointer p;
166      try 
167       {
168          p = GetFactory()->GetPackage(name);
169       }
170     catch (Exception e)
171       {
172         p = Package::New(name,
173                          "",
174                          "",
175                          "",
176                          BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
177         GetFactory()->InsertPackage(p);
178       }
179      mOpenPackage.push_back(p);
180   }
181   //=======================================================================
182
183   //=======================================================================
184   void Executer::EndPackage()
185   {
186     if (mOpenPackage.size()>1) mOpenPackage.pop_back();
187   }
188   //=======================================================================
189
190   //=======================================================================
191   void Executer::Define (const std::string &name,
192                          const std::string &pack,
193                          const std::string &scriptfilename)
194   {
195     bbtkDebugMessageInc("Kernel",9,"Executer::Define(\""<<name<<
196                         ","<<pack<<"\")"
197                         <<std::endl);
198
199     ComplexBlackBoxDescriptor::Pointer b 
200       = ComplexBlackBoxDescriptor::New(name);
201     b->SetFactory(GetFactory());
202     b->SetScriptFileName(scriptfilename);
203     mOpenDefinition.push_back( CBBDefinition( b, pack ) );
204     
205     bbtkDebugDecTab("Kernel",9);
206   }
207   //=======================================================================
208
209   //=======================================================================
210   /// Sets the file name to use for the current definition
211   /// (Used to set it after the Define command)
212   void Executer::SetCurrentFileName (const std::string &name )
213   {
214     mOpenDefinition.back().box->SetScriptFileName(name);
215   }
216   //=======================================================================
217
218   //=======================================================================
219   void Executer::EndDefine ()
220   {
221     bbtkDebugMessageInc("Kernel",9,"Executer::EndDefine(\""
222                         <<GetCurrentDescriptor()->GetTypeName()<<"\")" 
223                         <<std::endl);
224     // Does current package exist ?
225     Package::Pointer p;
226     std::string pname(mOpenDefinition.back().package);
227     if (pname.size()>0)
228       {
229         try
230           {
231             p = GetFactory()->GetPackage(pname);
232           }
233         catch (Exception e)
234           {
235             p = Package::New(pname,
236                              "",
237                              "",
238                              "",
239                              BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
240             GetFactory()->InsertPackage(p);
241           }
242       }
243     else
244       {
245         p = mOpenPackage.back().lock();
246       }
247     p->RegisterBlackBox(GetCurrentDescriptor());
248     
249     mOpenDefinition.pop_back();
250   }
251   //======================================================================= 
252
253   //=======================================================================  
254   void Executer::Kind(const std::string& kind)
255   {
256     if (kind=="ADAPTOR")
257       {
258         GetCurrentDescriptor()->AddToCategory("adaptor");
259         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::ADAPTOR);
260       }
261     else if (kind=="DEFAULT_ADAPTOR")
262       {
263         GetCurrentDescriptor()->AddToCategory("adaptor");
264         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR);
265       }
266     if (kind=="GUI")
267       {
268         GetCurrentDescriptor()->AddToCategory("gui");
269         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::GUI);
270       }
271     else if (kind=="DEFAULT_GUI")
272       {
273         GetCurrentDescriptor()->AddToCategory("gui");
274         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_GUI);
275       }
276     else
277       {
278         bbtkError("Unknown box kind : '"<<kind<<"'. "
279                   <<"Valid kinds are 'ADAPTOR','DEFAULT_ADAPTOR',"
280                   <<"'GUI','DEFAULT_GUI'");
281       }
282   }
283   //=======================================================================
284
285   //=======================================================================
286   void Executer::Create ( const std::string& nodeType, 
287                           const std::string& nodeName)
288   {
289      GetCurrentDescriptor()->Add(nodeType,nodeName);
290   }
291   //=======================================================================
292
293   //=======================================================================
294   void Executer::Destroy(const std::string &boxName)
295   {
296     GetCurrentDescriptor()->Remove(boxName,true);
297   }
298   //=======================================================================
299
300   //=======================================================================
301   void Executer::Connect (const std::string &nodeFrom,
302                           const std::string &outputLabel,
303                           const std::string &nodeTo, 
304                           const std::string &inputLabel)
305   {
306     GetCurrentDescriptor()->Connect(nodeFrom, outputLabel, nodeTo, inputLabel);
307   }
308   //=======================================================================
309
310   //=======================================================================
311   void Executer::Execute (const std::string &nodeName) 
312   {
313     // if in root
314     if (GetCurrentDescriptor()==GetWorkspace()) 
315      {
316         if (!mNoExecMode) 
317         {
318            GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(nodeName)->bbExecute(true);
319         }
320      }
321      else 
322      {
323         GetCurrentDescriptor()->AddToExecutionList(nodeName) ;
324      }
325   }
326   //=======================================================================
327
328   //=======================================================================
329   void Executer::DefineInput ( const std::string &name,
330                                const std::string &box,
331                                const std::string &input,
332                                const std::string& help)
333   {
334     // If the input is defined in the Root box
335     if (GetCurrentDescriptor()==GetWorkspace()) 
336       {
337       // If the dialog mode is set to NoDialog
338       // and the user passed the name in the Inputs map 
339       // then the associated value is set to the box.input
340       // This is the way command line parameters are passed to the Root box
341          if (mDialogMode == NoDialog) 
342          {
343          // find if name is in mInputs
344             std::map<std::string,std::string>::iterator i;
345             i = mInputs.find(name);
346             if (i!=mInputs.end()) {
347                Set(box,input,(*i).second);
348             }
349          }
350         // If the dialog mode is set to TextDialog
351         // The user is prompted for the value
352         else if (mDialogMode == TextDialog) 
353         {
354            std::cout << name << "=";
355            std::string ans;
356            std::cin >> ans;
357            Set(box,input,ans);
358         }
359 #ifdef USE_WXWIDGETS
360        // If the dialog mode is set to GraphicalDialog
361        // A dialog box is pop up
362        else if (mDialogMode == GraphicalDialog) 
363        {
364           std::string mess("Enter the value of '");
365           mess += name;
366           mess += "' (";
367           mess += help;
368           mess += ")";
369           std::string title(name);
370           title += " ?";
371           std::string ans = wx2std ( wxGetTextFromUser( std2wx (mess), std2wx(title)));
372           Set(box,input,ans); 
373        }
374 #endif
375     }
376
377     GetCurrentDescriptor()->DefineInput(name,box,input,help);
378
379   }
380   //=======================================================================
381
382   //=======================================================================
383    void Executer::DefineOutput ( const std::string &name,
384                                  const std::string &box,
385                                  const std::string &output,
386                                  const std::string& help)
387   {
388     GetCurrentDescriptor()->DefineOutput(name,box,output,help);
389   }
390   //=======================================================================
391
392   //=======================================================================
393   void Executer::Set (const std::string &box,
394                       const std::string &input,
395                       const std::string &value)
396   {
397     BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
398     // Looks for the adaptor
399
400     if ( b->bbGetInputType(input) !=  typeid(std::string) ) 
401       {
402         BlackBox::Pointer a =
403            GetFactory()->NewAdaptor(typeid(std::string),
404                                     b->bbGetInputType(input),
405                                     "tmp");
406          if (!a) 
407            {
408              bbtkError("No <"<<
409                        TypeName(b->bbGetInputType(input))
410                        <<"> to <std::string> found");
411            }
412          std::string v(value);
413          a->bbSetInput("In",v);
414          a->bbExecute();
415          b->bbSetInput(input,a->bbGetOutput("Out"));
416          //         a->Delete();
417       }
418     else 
419       {
420       std::string v(value);
421       b->bbSetInput(input,v);
422       }
423   }
424   //=======================================================================
425
426   //=======================================================================
427   std::string Executer::Get(const std::string &box,
428                             const std::string &output)
429   {
430     BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
431     // Looks for the adaptor
432     if (b->bbGetOutputType(output) != typeid(std::string)) 
433       {
434         BlackBox::Pointer a =
435           GetFactory()->NewAdaptor(
436                                    b->bbGetOutputType(output),
437                                    typeid(std::string),
438                                    "tmp");
439         if (!a) 
440           {
441             bbtkError("No <"<<
442                       TypeName(b->bbGetOutputType(output))
443                       <<"> to <std::string> found");
444           }
445         b->bbExecute();
446         
447         a->bbSetInput("In",b->bbGetOutput(output));
448         a->bbExecute();
449         std::string r = a->bbGetOutput("Out").unsafe_get<std::string>();
450         //std::string v = *((std::string*)a->bbGetOutput("Out")) ;
451         //   std::cout << a->bbGetOutput("Out").unsafe_get<std::string>() 
452         //             << std::endl;
453         //std::string v(value);
454         //b->bbSetInput(input,a->bbGetOutput("Out"));
455         //        a->bbDelete();
456         return r;
457       }
458     else
459       {
460         b->bbExecute();
461         return b->bbGetOutput(output).unsafe_get<std::string>();
462         // std::string v = *((std::string*)b->bbGetOutput(output)) ;
463         // std::cout << b->bbGetOutput("Out").unsafe_get<std::string>() 
464         //   << std::endl;
465         // b->bbSetInput(input,&v);
466       }
467   }
468   //=======================================================================
469
470   //=======================================================================
471   void Executer::Author(const std::string &authorName)
472   {
473     GetCurrentDescriptor()->AddToAuthor(authorName,GetCurrentDescriptor()==GetWorkspace());
474   }
475   //=======================================================================
476
477   //=======================================================================
478   void Executer::Category(const std::string &category)
479   {
480     GetCurrentDescriptor()->AddToCategory(category,GetCurrentDescriptor()==GetWorkspace());
481   }
482   //=======================================================================
483
484   //=======================================================================
485   void Executer::Description(const std::string &d)
486   {
487     GetCurrentDescriptor()->AddToDescription(d,GetCurrentDescriptor()==GetWorkspace());
488   }
489   //=======================================================================
490
491   //=======================================================================
492   /// prints the list of the boxes of the current descriptor
493   void Executer::PrintBoxes()
494   {
495     bbtkMessageInc("Help",1,"The black box descriptor \""
496                    <<GetCurrentDescriptor()->GetTypeName()<<"\" contains : "<<std::endl);
497     GetCurrentDescriptor()->PrintBlackBoxes();
498     bbtkDecTab("Help",1);
499  }
500   //=======================================================================
501
502   //=======================================================================
503   std::string Executer::ShowGraph(const std::string &nameblackbox, 
504                                   const std::string &detailStr, 
505                                   const std::string &levelStr,
506                                   const std::string &output_html,
507                                   const std::string &custom_header,
508                                   const std::string &custom_title,
509                                   bool system_display )
510   {
511     int detail  =       atoi(detailStr.c_str());
512     int level   =       atoi(levelStr.c_str());
513
514     std::string filename_rootHtml (output_html) ;
515     std::string simplefilename_rootHtml ( Utilities::get_file_name(output_html));
516
517     bool relative_link = true;
518
519     // No output provided : automatic generation
520     if (output_html.length() == 0)
521       {
522                 // Don't pollute the file store with  "temp_dir" directories ...    
523                 std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
524         
525                 char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
526         
527                 std::string directory = default_doc_dir; 
528                 if (c != '/' && c !='\\') directory = directory + "/";
529                 directory = directory +  "temp_dir";    
530         
531                 filename_rootHtml = directory + "/" + "User.html";
532                 simplefilename_rootHtml = "User.html" ;
533
534                 // Creating directory
535                 std::string command0("mkdir \"" +directory + "\"");
536                 system( command0.c_str() );
537
538                 relative_link = false;
539       }
540
541     Package::Pointer p;
542     try
543     {
544        p = GetFactory()->GetPackage(nameblackbox);
545     }
546     catch (Exception e)
547     {
548       p = GetUserPackage();
549     }
550     // Generating documentation-help of workspace
551     p->SetDocURL(filename_rootHtml);
552     p->SetDocRelativeURL(simplefilename_rootHtml);
553
554     p->CreateHtmlPage(filename_rootHtml,"bbtk","user package",custom_header,custom_title,detail,level,relative_link);
555
556     std::string page = filename_rootHtml;
557     /*
558     try 
559     {
560        ShowGraphTypes(nameblackbox);
561     }
562     catch (bbtk::Exception a)
563     {
564        std::cout <<"EXC"<<std::endl;
565        page = ShowGraphInstances(nameblackbox,detail,level,system_display);
566     }
567     */
568     return page;
569   }
570   //=======================================================================
571
572   //=======================================================================
573   /// Generate a png file with the actual pipeline (Graphviz-dot needed)
574   std::string Executer::ShowGraphInstances(const std::string &nameblackbox, int detail, int level,
575                                            bool system_display)
576   {
577
578     BlackBox::Pointer blackbox;
579     if (nameblackbox==".")
580     {
581        blackbox = GetCurrentDescriptor()->GetPrototype();
582     }
583     else
584     {
585        blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
586     }
587     
588     std::string page;
589
590     if (blackbox)
591       {      
592         // Don't pollute the file store with  "temp_dir" directories ...
593         std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
594         char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
595
596         std::string directory = default_doc_dir; 
597         if (c != '/' && c !='\\') directory = directory + "/";
598
599         directory = directory +  "temp_dir";
600         //std::string directory("temp_dir");
601         std::string filename(directory + "/" + "bbtk_graph_pipeline");
602         std::string filename_html(filename+".html");
603         std::string command0("mkdir \""+directory + "\"");
604
605 #if defined(_WIN32)
606         std::string command2("start ");
607 #else 
608         std::string command2("gnome-open ");
609 #endif
610
611         command2=command2+filename_html;
612         page = filename_html;
613         // 1. Generate Html Diagram
614         std::ofstream s;
615         s.open(filename_html.c_str());
616         if (s.good()) 
617           {
618             s << "<html><head><title>BBtk graph diagram</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head>\n";
619             s << "<body bgcolor=\"#FFFFFF\" text=\"#000000\"> \n\n";
620             if ( blackbox->bbGetName()=="workspacePrototype" )
621               {
622                 s << "<center>Current workspace</center>";
623               } else {
624               s << "<center>" << blackbox->bbGetName()<< "</center>";
625             } 
626
627             blackbox->bbInsertHTMLGraph( s, detail, level, true, directory, false );
628             s << "</body></html>\n";
629           }
630         s.close();
631         
632         // 2. Starting Browser
633         if (system_display) system( command2.c_str() );      
634       } 
635     else 
636       {
637         bbtkMessageInc("Help",1,"No black box: \""
638                        <<nameblackbox<<"\" " <<std::endl);
639       }
640     return page;
641   }
642   //=======================================================================
643
644   //=======================================================================
645   void Executer::ShowRelations(const std::string &nameblackbox, 
646                                const std::string &detailStr, 
647                                const std::string &levelStr)
648   {
649     bool found=false;
650     
651     int detail = atoi(detailStr.c_str());
652     int level  = atoi(levelStr.c_str());
653     BlackBox::Pointer blackbox;
654     if (nameblackbox.compare(".")==0)
655       {
656         blackbox=GetCurrentDescriptor()->GetPrototype();
657       } 
658     else 
659       {
660         blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
661       }
662     
663     if (blackbox)
664       {
665         found=true;
666         blackbox->bbShowRelations(blackbox,detail,level); //,mFactory);
667       }
668     
669     if (!found) 
670       {
671         bbtkError("Blackbox Name not found.. <"  <<nameblackbox<<">");
672       }
673   }
674   //=======================================================================
675
676   //=======================================================================
677   /// sets the level of message
678   void Executer::SetMessageLevel(const std::string &kind,
679                                  int level)
680   {
681     bbtk::MessageManager::SetMessageLevel(kind,level);
682   }
683   //=======================================================================
684
685   //=======================================================================
686   /// Prints help on the messages
687   void  Executer::HelpMessages()
688   {
689     bbtk::MessageManager::PrintInfo();
690   }
691   //=======================================================================
692
693   //=======================================================================
694   ///
695   void Executer::Print(const std::string &str)
696   {  
697     if (GetNoExecMode() &&  (GetCurrentDescriptor()==GetWorkspace()) ) return;
698     if (GetCurrentDescriptor()!=GetWorkspace()) return;
699
700     bbtkDebugMessageInc("Interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
701
702  // TO DO :
703  // InterpretLine ("load std")
704  // InterpretLine("new ConcatStrings _C_ ") -> trouver un nom unique : # commande 
705  // InterpretLine("new Print _P_") 
706  // InterpretLine("connect _C_.Out _P_.In")
707  // int num = 1
708  
709
710     std::vector<std::string> chains;
711     std::string delimiters("$");
712
713     // Skip delimiters at beginning.
714     std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
715     bool is_text = true;
716     if (lastPos>0) is_text = false;
717
718     // Find first delimiter.
719     std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
720
721     while (std::string::npos != pos || std::string::npos != lastPos)
722     {
723        if (is_text) 
724        {
725           // Found a text token, add it to the vector.
726           chains.push_back(str.substr(lastPos, pos - lastPos));
727  // std::string token = str.substr(lastPos, pos - lastPos)
728  // InterpretLine("set _C_.In%num% %token%")
729  
730        }
731        else 
732        {
733
734        // is an output (between $$) : decode 
735          std::string tok,box,output;
736          tok = str.substr(lastPos, pos - lastPos);
737          Utilities::SplitAroundFirstDot(tok,box,output);
738          chains.push_back( Get(box,output) );
739
740 // InterpretLine("connect %tok% _C_.In%num%") 
741
742        }
743         // Skip delimiters.  Note the "not_of"
744        lastPos = str.find_first_not_of(delimiters, pos);
745         // Find next delimiter
746        pos = str.find_first_of(delimiters, lastPos);
747     //
748        is_text = !is_text;
749 // num ++;
750      }
751 // InterpretLine("exec _P_")
752 // if (IS_IN_WORKSPACE) InterpretLine("delete _C_; delete _P_");
753
754     std::vector<std::string>::iterator i;
755     for (i= chains.begin(); i!=chains.end(); ++i) 
756       {
757         Utilities::SubsBackslashN(*i);
758         bbtkMessage("Output",1,*i);
759       }
760     bbtkMessage("Output",1,std::endl);
761   }
762   //==========================================================================
763
764   //==========================================================================
765   std::string Executer::GetObjectName() const
766   {
767     return std::string("Executer");
768   }
769   //==========================================================================
770   
771   //==========================================================================
772   std::string  Executer::GetObjectInfo() const 
773   {
774     std::stringstream i;
775     return i.str();
776   }
777   //==========================================================================
778   //==========================================================================
779 size_t  Executer::GetObjectSize() const 
780 {
781   size_t s = Superclass::GetObjectSize();
782   s += Executer::GetObjectInternalSize();
783   return s;
784   }
785   //==========================================================================
786   //==========================================================================
787 size_t  Executer::GetObjectInternalSize() const 
788 {
789   size_t s = sizeof(Executer);
790   return s;
791   }
792   //==========================================================================
793   //==========================================================================
794   size_t  Executer::GetObjectRecursiveSize() const 
795   {
796     size_t s = Superclass::GetObjectRecursiveSize();
797     s += Executer::GetObjectInternalSize();
798     s += mFactory->GetObjectRecursiveSize();
799     return s;
800   }
801   //==========================================================================
802 }//namespace