]> Creatis software - bbtk.git/blob - kernel/src/bbtkExecuter.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkExecuter.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkExecuter.cxx,v $
4   Language:  C++
5   Date:      $Date: 2008/12/12 12:11:21 $
6   Version:   $Revision: 1.25 $
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   //=======================================================================
154   /// changes the workspace name
155   void Executer::SetWorkspaceName( const std::string& n )
156   {
157     GetUserPackage()->ChangeBlackBoxName( GetWorkspace()->GetTypeName(), n );
158   }
159   //=======================================================================
160
161   //=======================================================================
162   void Executer::BeginPackage (const std::string &name)
163   {
164      bbtkDebugMessageInc("Kernel",9,"Executer::BeginPackage(\""<<name<<"\")"
165                         <<std::endl);
166      Package::Pointer p;
167      try 
168       {
169          p = GetFactory()->GetPackage(name);
170       }
171     catch (Exception e)
172       {
173         p = Package::New(name,
174                          "",
175                          "",
176                          "",
177                          BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
178         GetFactory()->InsertPackage(p);
179       }
180      mOpenPackage.push_back(p);
181   }
182   //=======================================================================
183
184   //=======================================================================
185   void Executer::EndPackage()
186   {
187     if (mOpenPackage.size()>1) mOpenPackage.pop_back();
188   }
189   //=======================================================================
190
191   //=======================================================================
192   void Executer::Define (const std::string &name,
193                          const std::string &pack,
194                          const std::string &scriptfilename)
195   {
196     bbtkDebugMessageInc("Kernel",9,"Executer::Define(\""<<name<<
197                         ","<<pack<<"\")"
198                         <<std::endl);
199
200     ComplexBlackBoxDescriptor::Pointer b 
201       = ComplexBlackBoxDescriptor::New(name);
202     b->SetFactory(GetFactory());
203     b->SetScriptFileName(scriptfilename);
204     mOpenDefinition.push_back( CBBDefinition( b, pack ) );
205     
206     bbtkDebugDecTab("Kernel",9);
207   }
208   //=======================================================================
209
210   //=======================================================================
211   /// Sets the file name to use for the current definition
212   /// (Used to set it after the Define command)
213   void Executer::SetCurrentFileName (const std::string &name )
214   {
215     mOpenDefinition.back().box->SetScriptFileName(name);
216   }
217   //=======================================================================
218
219   //=======================================================================
220   void Executer::Clear()
221   {
222     bbtkDebugMessageInc("Kernel",9,"Executer::Clear()" <<std::endl);
223     GetCurrentDescriptor()->GetPrototype()->Clear();
224
225   }
226   //=======================================================================
227
228   //=======================================================================
229   void Executer::EndDefine ()
230   {
231     bbtkDebugMessageInc("Kernel",9,"Executer::EndDefine(\""
232                         <<GetCurrentDescriptor()->GetTypeName()<<"\")" 
233                         <<std::endl);
234     // Does current package exist ?
235     Package::Pointer p;
236     std::string pname(mOpenDefinition.back().package);
237     if (pname.size()>0)
238       {
239         try
240           {
241             p = GetFactory()->GetPackage(pname);
242           }
243         catch (Exception e)
244           {
245             p = Package::New(pname,
246                              "",
247                              "",
248                              "",
249                              BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
250             GetFactory()->InsertPackage(p);
251           }
252       }
253     else
254       {
255         p = mOpenPackage.back().lock();
256       }
257     p->RegisterBlackBox(GetCurrentDescriptor());
258     
259     mOpenDefinition.pop_back();
260   }
261   //======================================================================= 
262
263   //=======================================================================  
264   void Executer::Kind(const std::string& kind)
265   {
266     if (kind=="ADAPTOR")
267       {
268         GetCurrentDescriptor()->AddToCategory("adaptor");
269         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::ADAPTOR);
270       }
271     else if (kind=="DEFAULT_ADAPTOR")
272       {
273         GetCurrentDescriptor()->AddToCategory("adaptor");
274         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR);
275       }
276     if (kind=="GUI")
277       {
278         GetCurrentDescriptor()->AddToCategory("gui");
279         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::GUI);
280       }
281     else if (kind=="DEFAULT_GUI")
282       {
283         GetCurrentDescriptor()->AddToCategory("gui");
284         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_GUI);
285       }
286     else
287       {
288         bbtkError("Unknown box kind : '"<<kind<<"'. "
289                   <<"Valid kinds are 'ADAPTOR','DEFAULT_ADAPTOR',"
290                   <<"'GUI','DEFAULT_GUI'");
291       }
292   }
293   //=======================================================================
294
295   //=======================================================================
296   void Executer::Create ( const std::string& nodeType, 
297                           const std::string& nodeName)
298   {
299      GetCurrentDescriptor()->Add(nodeType,nodeName);
300   }
301   //=======================================================================
302
303   //=======================================================================
304   void Executer::Destroy(const std::string &boxName)
305   {
306     GetCurrentDescriptor()->Remove(boxName,true);
307   }
308   //=======================================================================
309
310   //=======================================================================
311   void Executer::Connect (const std::string &nodeFrom,
312                           const std::string &outputLabel,
313                           const std::string &nodeTo, 
314                           const std::string &inputLabel)
315   {
316     GetCurrentDescriptor()->Connect(nodeFrom, outputLabel, nodeTo, inputLabel);
317   }
318   //=======================================================================
319
320   //=======================================================================
321   void Executer::Execute (const std::string &nodeName) 
322   {
323     // if in root
324     if (GetCurrentDescriptor()==GetWorkspace()) 
325      {
326         if (!mNoExecMode) 
327         {
328            GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(nodeName)->bbExecute(true);
329         }
330      }
331      else 
332      {
333         GetCurrentDescriptor()->AddToExecutionList(nodeName) ;
334      }
335   }
336   //=======================================================================
337
338   //=======================================================================
339   void Executer::DefineInput ( const std::string &name,
340                                const std::string &box,
341                                const std::string &input,
342                                const std::string& help)
343   {
344     // If the input is defined in the Root box
345     if (GetCurrentDescriptor()==GetWorkspace()) 
346       {
347       // If the dialog mode is set to NoDialog
348       // and the user passed the name in the Inputs map 
349       // then the associated value is set to the box.input
350       // This is the way command line parameters are passed to the Root box
351          if (mDialogMode == NoDialog) 
352          {
353          // find if name is in mInputs
354             std::map<std::string,std::string>::iterator i;
355             i = mInputs.find(name);
356             if (i!=mInputs.end()) {
357                Set(box,input,(*i).second);
358             }
359          }
360         // If the dialog mode is set to TextDialog
361         // The user is prompted for the value
362         else if (mDialogMode == TextDialog) 
363         {
364            std::cout << name << "=";
365            std::string ans;
366            std::cin >> ans;
367            Set(box,input,ans);
368         }
369 #ifdef USE_WXWIDGETS
370        // If the dialog mode is set to GraphicalDialog
371        // A dialog box is pop up
372        else if (mDialogMode == GraphicalDialog) 
373        {
374           std::string mess("Enter the value of '");
375           mess += name;
376           mess += "' (";
377           mess += help;
378           mess += ")";
379           std::string title(name);
380           title += " ?";
381           std::string ans = wx2std ( wxGetTextFromUser( std2wx (mess), std2wx(title)));
382           Set(box,input,ans); 
383        }
384 #endif
385     }
386
387     GetCurrentDescriptor()->DefineInput(name,box,input,help);
388
389   }
390   //=======================================================================
391
392   //=======================================================================
393    void Executer::DefineOutput ( const std::string &name,
394                                  const std::string &box,
395                                  const std::string &output,
396                                  const std::string& help)
397   {
398     GetCurrentDescriptor()->DefineOutput(name,box,output,help);
399   }
400   //=======================================================================
401
402   //=======================================================================
403   void Executer::Set (const std::string &box,
404                       const std::string &input,
405                       const std::string &value)
406   {
407     BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
408     // Looks for the adaptor
409
410     if ( b->bbGetInputType(input) !=  typeid(std::string) ) 
411       {
412         BlackBox::Pointer a =
413            GetFactory()->NewAdaptor(typeid(std::string),
414                                     b->bbGetInputType(input),
415                                     "tmp");
416          if (!a) 
417            {
418              bbtkError("No <"<<
419                        TypeName(b->bbGetInputType(input))
420                        <<"> to <std::string> found");
421            }
422          std::string v(value);
423          a->bbSetInput("In",v);
424          a->bbExecute();
425          b->bbSetInput(input,a->bbGetOutput("Out"));
426          //         a->Delete();
427       }
428     else 
429       {
430       std::string v(value);
431       b->bbSetInput(input,v);
432       }
433   }
434   //=======================================================================
435
436   //=======================================================================
437   std::string Executer::Get(const std::string &box,
438                             const std::string &output)
439   {
440     BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
441     // Looks for the adaptor
442     if (b->bbGetOutputType(output) != typeid(std::string)) 
443       {
444         BlackBox::Pointer a =
445           GetFactory()->NewAdaptor(
446                                    b->bbGetOutputType(output),
447                                    typeid(std::string),
448                                    "tmp");
449         if (!a) 
450           {
451             bbtkError("No <"<<
452                       TypeName(b->bbGetOutputType(output))
453                       <<"> to <std::string> found");
454           }
455         b->bbExecute();
456         
457         a->bbSetInput("In",b->bbGetOutput(output));
458         a->bbExecute();
459         std::string r = a->bbGetOutput("Out").unsafe_get<std::string>();
460         //std::string v = *((std::string*)a->bbGetOutput("Out")) ;
461         //   std::cout << a->bbGetOutput("Out").unsafe_get<std::string>() 
462         //             << std::endl;
463         //std::string v(value);
464         //b->bbSetInput(input,a->bbGetOutput("Out"));
465         //        a->bbDelete();
466         return r;
467       }
468     else
469       {
470         b->bbExecute();
471         return b->bbGetOutput(output).unsafe_get<std::string>();
472         // std::string v = *((std::string*)b->bbGetOutput(output)) ;
473         // std::cout << b->bbGetOutput("Out").unsafe_get<std::string>() 
474         //   << std::endl;
475         // b->bbSetInput(input,&v);
476       }
477   }
478   //=======================================================================
479
480   //=======================================================================
481   void Executer::Author(const std::string &authorName)
482   {
483     GetCurrentDescriptor()->AddToAuthor(authorName,GetCurrentDescriptor()==GetWorkspace());
484   }
485   //=======================================================================
486
487   //=======================================================================
488   void Executer::Category(const std::string &category)
489   {
490     GetCurrentDescriptor()->AddToCategory(category,GetCurrentDescriptor()==GetWorkspace());
491   }
492   //=======================================================================
493
494   //=======================================================================
495   void Executer::Description(const std::string &d)
496   {
497     GetCurrentDescriptor()->AddToDescription(d,GetCurrentDescriptor()==GetWorkspace());
498   }
499   //=======================================================================
500
501   //=======================================================================
502   /// prints the list of the boxes of the current descriptor
503   void Executer::PrintBoxes()
504   {
505     bbtkMessageInc("Help",1,"The black box descriptor \""
506                    <<GetCurrentDescriptor()->GetTypeName()<<"\" contains : "<<std::endl);
507     GetCurrentDescriptor()->PrintBlackBoxes();
508     bbtkDecTab("Help",1);
509  }
510   //=======================================================================
511
512   //=======================================================================
513   std::string Executer::ShowGraph(const std::string &nameblackbox, 
514                                   const std::string &detailStr, 
515                                   const std::string &levelStr,
516                                   const std::string &output_html,
517                                   const std::string &custom_header,
518                                   const std::string &custom_title,
519                                   bool system_display )
520   {
521     int detail  =       atoi(detailStr.c_str());
522     int level   =       atoi(levelStr.c_str());
523
524     std::string filename_rootHtml (output_html) ;
525     std::string simplefilename_rootHtml ( Utilities::get_file_name(output_html));
526
527     bool relative_link = true;
528
529     // No output provided : automatic generation
530     if (output_html.length() == 0)
531       {
532                 // Don't pollute the file store with  "temp_dir" directories ...    
533                 std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
534         
535                 char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
536         
537                 std::string directory = default_doc_dir; 
538                 if (c != '/' && c !='\\') directory = directory + "/";
539                 directory = directory +  "temp_dir";    
540         
541                 filename_rootHtml = directory + "/" + "User.html";
542                 simplefilename_rootHtml = "User.html" ;
543
544                 // Creating directory
545                 std::string command0("mkdir \"" +directory + "\"");
546                 system( command0.c_str() );
547
548                 relative_link = false;
549       }
550
551     Package::Pointer p;
552     try
553     {
554        p = GetFactory()->GetPackage(nameblackbox);
555     }
556     catch (Exception e)
557     {
558       p = GetUserPackage();
559     }
560     // Generating documentation-help of workspace
561     p->SetDocURL(filename_rootHtml);
562     p->SetDocRelativeURL(simplefilename_rootHtml);
563
564     p->CreateHtmlPage(filename_rootHtml,"bbtk","user package",custom_header,custom_title,detail,level,relative_link);
565
566     std::string page = filename_rootHtml;
567     /*
568     try 
569     {
570        ShowGraphTypes(nameblackbox);
571     }
572     catch (bbtk::Exception a)
573     {
574        std::cout <<"EXC"<<std::endl;
575        page = ShowGraphInstances(nameblackbox,detail,level,system_display);
576     }
577     */
578     return page;
579   }
580   //=======================================================================
581
582   //=======================================================================
583   /// Generate a png file with the actual pipeline (Graphviz-dot needed)
584   std::string Executer::ShowGraphInstances(const std::string &nameblackbox, int detail, int level,
585                                            bool system_display)
586   {
587
588     BlackBox::Pointer blackbox;
589     if (nameblackbox==".")
590     {
591        blackbox = GetCurrentDescriptor()->GetPrototype();
592     }
593     else
594     {
595        blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
596     }
597     
598     std::string page;
599
600     if (blackbox)
601       {      
602         // Don't pollute the file store with  "temp_dir" directories ...
603         std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
604         char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
605
606         std::string directory = default_doc_dir; 
607         if (c != '/' && c !='\\') directory = directory + "/";
608
609         directory = directory +  "temp_dir";
610         //std::string directory("temp_dir");
611         std::string filename(directory + "/" + "bbtk_graph_pipeline");
612         std::string filename_html(filename+".html");
613         std::string command0("mkdir \""+directory + "\"");
614
615 #if defined(_WIN32)
616         std::string command2("start ");
617 #else 
618         std::string command2("gnome-open ");
619 #endif
620
621         command2=command2+filename_html;
622         page = filename_html;
623         // 1. Generate Html Diagram
624         std::ofstream s;
625         s.open(filename_html.c_str());
626         if (s.good()) 
627           {
628             s << "<html><head><title>BBtk graph diagram</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head>\n";
629             s << "<body bgcolor=\"#FFFFFF\" text=\"#000000\"> \n\n";
630             if ( blackbox->bbGetName()=="workspacePrototype" )
631               {
632                 s << "<center>Current workspace</center>";
633               } else {
634               s << "<center>" << blackbox->bbGetName()<< "</center>";
635             } 
636
637             blackbox->bbInsertHTMLGraph( s, detail, level, true, directory, false );
638             s << "</body></html>\n";
639           }
640         s.close();
641         
642         // 2. Starting Browser
643         if (system_display) system( command2.c_str() );      
644       } 
645     else 
646       {
647         bbtkMessageInc("Help",1,"No black box: \""
648                        <<nameblackbox<<"\" " <<std::endl);
649       }
650     return page;
651   }
652   //=======================================================================
653
654   //=======================================================================
655   void Executer::ShowRelations(const std::string &nameblackbox, 
656                                const std::string &detailStr, 
657                                const std::string &levelStr)
658   {
659     bool found=false;
660     
661     int detail = atoi(detailStr.c_str());
662     int level  = atoi(levelStr.c_str());
663     BlackBox::Pointer blackbox;
664     if (nameblackbox.compare(".")==0)
665       {
666         blackbox=GetCurrentDescriptor()->GetPrototype();
667       } 
668     else 
669       {
670         blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
671       }
672     
673     if (blackbox)
674       {
675         found=true;
676         blackbox->bbShowRelations(blackbox,detail,level); //,mFactory);
677       }
678     
679     if (!found) 
680       {
681         bbtkError("Blackbox Name not found.. <"  <<nameblackbox<<">");
682       }
683   }
684   //=======================================================================
685
686   //=======================================================================
687   /// sets the level of message
688   void Executer::SetMessageLevel(const std::string &kind,
689                                  int level)
690   {
691     bbtk::MessageManager::SetMessageLevel(kind,level);
692   }
693   //=======================================================================
694
695   //=======================================================================
696   /// Prints help on the messages
697   void  Executer::HelpMessages()
698   {
699     bbtk::MessageManager::PrintInfo();
700   }
701   //=======================================================================
702
703   //=======================================================================
704   ///
705   void Executer::Print(const std::string &str)
706   {  
707     if (GetNoExecMode() &&  (GetCurrentDescriptor()==GetWorkspace()) ) return;
708     if (GetCurrentDescriptor()!=GetWorkspace()) return;
709
710     bbtkDebugMessageInc("Interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
711
712  // TO DO :
713  // InterpretLine ("load std")
714  // InterpretLine("new ConcatStrings _C_ ") -> trouver un nom unique : # commande 
715  // InterpretLine("new Print _P_") 
716  // InterpretLine("connect _C_.Out _P_.In")
717  // int num = 1
718  
719
720     std::vector<std::string> chains;
721     std::string delimiters("$");
722
723     // Skip delimiters at beginning.
724     std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
725     bool is_text = true;
726     if (lastPos>0) is_text = false;
727
728     // Find first delimiter.
729     std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
730
731     while (std::string::npos != pos || std::string::npos != lastPos)
732     {
733        if (is_text) 
734        {
735           // Found a text token, add it to the vector.
736           chains.push_back(str.substr(lastPos, pos - lastPos));
737  // std::string token = str.substr(lastPos, pos - lastPos)
738  // InterpretLine("set _C_.In%num% %token%")
739  
740        }
741        else 
742        {
743
744        // is an output (between $$) : decode 
745          std::string tok,box,output;
746          tok = str.substr(lastPos, pos - lastPos);
747          Utilities::SplitAroundFirstDot(tok,box,output);
748          chains.push_back( Get(box,output) );
749
750 // InterpretLine("connect %tok% _C_.In%num%") 
751
752        }
753         // Skip delimiters.  Note the "not_of"
754        lastPos = str.find_first_not_of(delimiters, pos);
755         // Find next delimiter
756        pos = str.find_first_of(delimiters, lastPos);
757     //
758        is_text = !is_text;
759 // num ++;
760      }
761 // InterpretLine("exec _P_")
762 // if (IS_IN_WORKSPACE) InterpretLine("delete _C_; delete _P_");
763
764     std::vector<std::string>::iterator i;
765     for (i= chains.begin(); i!=chains.end(); ++i) 
766       {
767         Utilities::SubsBackslashN(*i);
768         bbtkMessage("Output",1,*i);
769       }
770     bbtkMessage("Output",1,std::endl);
771   }
772   //==========================================================================
773
774   //==========================================================================
775   std::string Executer::GetObjectName() const
776   {
777     return std::string("Executer");
778   }
779   //==========================================================================
780   
781   //==========================================================================
782   std::string  Executer::GetObjectInfo() const 
783   {
784     std::stringstream i;
785     return i.str();
786   }
787   //==========================================================================
788   //==========================================================================
789 size_t  Executer::GetObjectSize() const 
790 {
791   size_t s = Superclass::GetObjectSize();
792   s += Executer::GetObjectInternalSize();
793   return s;
794   }
795   //==========================================================================
796   //==========================================================================
797 size_t  Executer::GetObjectInternalSize() const 
798 {
799   size_t s = sizeof(Executer);
800   return s;
801   }
802   //==========================================================================
803   //==========================================================================
804   size_t  Executer::GetObjectRecursiveSize() const 
805   {
806     size_t s = Superclass::GetObjectRecursiveSize();
807     s += Executer::GetObjectInternalSize();
808     s += mFactory->GetObjectRecursiveSize();
809     return s;
810   }
811   //==========================================================================
812 }//namespace