bbtkExecuter.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkExecuter.cxx,v $
00004   Language:  C++
00005   Date:      $Date: 2008/10/17 08:18:13 $
00006   Version:   $Revision: 1.23 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and 
00015 *  abiding by the rules of distribution of free software. You can  use, 
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability. 
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */                                                                         
00030 
00036 #include "bbtkExecuter.h"
00037 #include "bbtkMessageManager.h"
00038 #include "bbtkFactory.h"
00039 #include "bbtkUtilities.h"
00040 #include <fstream>
00041 
00042 #ifdef _USE_WXWIDGETS_
00043 #include <wx/textdlg.h>
00044 #endif
00045 
00046 #include "bbtkWxBlackBox.h"
00047 
00048 #include "bbtkConfigurationFile.h"
00049 
00050 namespace bbtk
00051 {
00052   //=======================================================================
00053   Executer::Pointer Executer::New()
00054   {
00055     bbtkDebugMessage("Kernel",9,"Executer::New()"<<std::endl);
00056     return MakePointer(new Executer());
00057   }
00058   //=======================================================================
00059 
00060   //=======================================================================
00061   Executer::Executer()
00062     : 
00063     mFactory(),
00064     mRootPackage(),
00065     mRootCBB(),
00066     mNoExecMode(false),
00067     mDialogMode(NoDialog)
00068   {
00069     bbtkDebugMessageInc("Kernel",9,"Executer::Executer()" <<std::endl);
00070     mFactory = Factory::New();
00071     // The smart pointer on this is not made yet (is made by New) 
00072     // -> create it to pass it to the factory
00073     // We have to "lock" the smart pointer because the factory
00074     // only keeps a weak pointer on the executer
00075     // -> this would auto-destroy !!
00076     mFactory->SetExecuter(MakePointer(this,true));
00077     Reset();
00078     bbtkDebugDecTab("Kernel",9);
00079   }
00080   //=======================================================================
00081 
00082   //=======================================================================
00083   Executer::~Executer()
00084   {
00085      bbtkDebugMessageInc("Kernel",9,"==> Executer::~Executer()" <<std::endl);
00086      mOpenDefinition.clear();
00087      mOpenPackage.clear();
00088      mFactory->Reset();
00089      mFactory.reset();
00090      bbtkDebugDecTab("Kernel",9);
00091   }
00092   //=======================================================================
00093 
00094   //=======================================================================
00096     void Executer::LoadPackage(const std::string &name )
00097    {
00098      GetFactory()->LoadPackage(name);
00099    }
00100   //=======================================================================
00101 
00102   //=======================================================================
00104     void Executer::UnLoadPackage(const std::string &name )
00105     {
00106       GetFactory()->UnLoadPackage(name);
00107     }
00108   //=======================================================================
00109 
00110   //=======================================================================
00111   void Executer::Reset()
00112   {
00113     bbtkDebugMessageInc("Kernel",9,"Executer::Reset()" <<std::endl);
00114 
00115     GetFactory()->CheckPackages();
00116  
00117     mOpenDefinition.clear();
00118     mOpenPackage.clear();
00119     GetFactory()->Reset();
00120 
00121     // Create user package
00122     Package::Pointer p =
00123       Package::New("user","internal",
00124                    "User defined black boxes",
00125                    "",
00126                    BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
00127     // Insert the user package in the factory
00128     GetFactory()->InsertPackage(p);
00129     // And in the list of open packages
00130     mOpenPackage.push_back(p);
00131     mRootPackage = p;
00132 
00133     // Create user workspace
00134     ComplexBlackBoxDescriptor::Pointer r = 
00135       ComplexBlackBoxDescriptor::New("workspace"); 
00136     //    mRootCBB->Reference();
00137     r->SetFactory(GetFactory());
00138     r->AddToAuthor("bbtk");
00139     r->AddToDescription("User's workspace");
00140     mOpenDefinition.push_back(CBBDefinition(r,"user"));
00141     // Register it into the user package
00142     p->RegisterBlackBox(r);
00143     mRootCBB = r;
00144 
00145     //    Object::PrintObjectListInfo();
00146     //  GetFactory()->CheckPackages();
00147 
00148     bbtkDebugDecTab("Kernel",9);
00149   }
00150   //=======================================================================
00151 
00152   //=======================================================================
00154   void Executer::SetWorkspaceName( const std::string& n )
00155   {
00156     GetUserPackage()->ChangeBlackBoxName( GetWorkspace()->GetTypeName(), n );
00157   }
00158   //=======================================================================
00159 
00160   //=======================================================================
00161   void Executer::BeginPackage (const std::string &name)
00162   {
00163      bbtkDebugMessageInc("Kernel",9,"Executer::BeginPackage(\""<<name<<"\")"
00164                         <<std::endl);
00165      Package::Pointer p;
00166      try 
00167       {
00168          p = GetFactory()->GetPackage(name);
00169       }
00170     catch (Exception e)
00171       {
00172         p = Package::New(name,
00173                          "",
00174                          "",
00175                          "",
00176                          BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
00177         GetFactory()->InsertPackage(p);
00178       }
00179      mOpenPackage.push_back(p);
00180   }
00181   //=======================================================================
00182 
00183   //=======================================================================
00184   void Executer::EndPackage()
00185   {
00186     if (mOpenPackage.size()>1) mOpenPackage.pop_back();
00187   }
00188   //=======================================================================
00189 
00190   //=======================================================================
00191   void Executer::Define (const std::string &name,
00192                          const std::string &pack,
00193                          const std::string &scriptfilename)
00194   {
00195     bbtkDebugMessageInc("Kernel",9,"Executer::Define(\""<<name<<
00196                         ","<<pack<<"\")"
00197                         <<std::endl);
00198 
00199     ComplexBlackBoxDescriptor::Pointer b 
00200       = ComplexBlackBoxDescriptor::New(name);
00201     b->SetFactory(GetFactory());
00202     b->SetScriptFileName(scriptfilename);
00203     mOpenDefinition.push_back( CBBDefinition( b, pack ) );
00204     
00205     bbtkDebugDecTab("Kernel",9);
00206   }
00207   //=======================================================================
00208 
00209   //=======================================================================
00212   void Executer::SetCurrentFileName (const std::string &name )
00213   {
00214     mOpenDefinition.back().box->SetScriptFileName(name);
00215   }
00216   //=======================================================================
00217 
00218   //=======================================================================
00219   void Executer::EndDefine ()
00220   {
00221     bbtkDebugMessageInc("Kernel",9,"Executer::EndDefine(\""
00222                         <<GetCurrentDescriptor()->GetTypeName()<<"\")" 
00223                         <<std::endl);
00224     // Does current package exist ?
00225     Package::Pointer p;
00226     std::string pname(mOpenDefinition.back().package);
00227     if (pname.size()>0)
00228       {
00229         try
00230           {
00231             p = GetFactory()->GetPackage(pname);
00232           }
00233         catch (Exception e)
00234           {
00235             p = Package::New(pname,
00236                              "",
00237                              "",
00238                              "",
00239                              BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
00240             GetFactory()->InsertPackage(p);
00241           }
00242       }
00243     else
00244       {
00245         p = mOpenPackage.back().lock();
00246       }
00247     p->RegisterBlackBox(GetCurrentDescriptor());
00248     
00249     mOpenDefinition.pop_back();
00250   }
00251   //======================================================================= 
00252 
00253   //=======================================================================  
00254   void Executer::Kind(const std::string& kind)
00255   {
00256     if (kind=="ADAPTOR")
00257       {
00258         GetCurrentDescriptor()->AddToCategory("adaptor");
00259         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::ADAPTOR);
00260       }
00261     else if (kind=="DEFAULT_ADAPTOR")
00262       {
00263         GetCurrentDescriptor()->AddToCategory("adaptor");
00264         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR);
00265       }
00266     if (kind=="GUI")
00267       {
00268         GetCurrentDescriptor()->AddToCategory("gui");
00269         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::GUI);
00270       }
00271     else if (kind=="DEFAULT_GUI")
00272       {
00273         GetCurrentDescriptor()->AddToCategory("gui");
00274         GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_GUI);
00275       }
00276     else
00277       {
00278         bbtkError("Unknown box kind : '"<<kind<<"'. "
00279                   <<"Valid kinds are 'ADAPTOR','DEFAULT_ADAPTOR',"
00280                   <<"'GUI','DEFAULT_GUI'");
00281       }
00282   }
00283   //=======================================================================
00284 
00285   //=======================================================================
00286   void Executer::Create ( const std::string& nodeType, 
00287                           const std::string& nodeName)
00288   {
00289      GetCurrentDescriptor()->Add(nodeType,nodeName);
00290   }
00291   //=======================================================================
00292 
00293   //=======================================================================
00294   void Executer::Destroy(const std::string &boxName)
00295   {
00296     GetCurrentDescriptor()->Remove(boxName,true);
00297   }
00298   //=======================================================================
00299 
00300   //=======================================================================
00301   void Executer::Connect (const std::string &nodeFrom,
00302                           const std::string &outputLabel,
00303                           const std::string &nodeTo, 
00304                           const std::string &inputLabel)
00305   {
00306     GetCurrentDescriptor()->Connect(nodeFrom, outputLabel, nodeTo, inputLabel);
00307   }
00308   //=======================================================================
00309 
00310   //=======================================================================
00311   void Executer::Execute (const std::string &nodeName) 
00312   {
00313     // if in root
00314     if (GetCurrentDescriptor()==GetWorkspace()) 
00315      {
00316         if (!mNoExecMode) 
00317         {
00318            GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(nodeName)->bbExecute(true);
00319         }
00320      }
00321      else 
00322      {
00323         GetCurrentDescriptor()->AddToExecutionList(nodeName) ;
00324      }
00325   }
00326   //=======================================================================
00327 
00328   //=======================================================================
00329   void Executer::DefineInput ( const std::string &name,
00330                                const std::string &box,
00331                                const std::string &input,
00332                                const std::string& help)
00333   {
00334     // If the input is defined in the Root box
00335     if (GetCurrentDescriptor()==GetWorkspace()) 
00336       {
00337       // If the dialog mode is set to NoDialog
00338       // and the user passed the name in the Inputs map 
00339       // then the associated value is set to the box.input
00340       // This is the way command line parameters are passed to the Root box
00341          if (mDialogMode == NoDialog) 
00342          {
00343          // find if name is in mInputs
00344             std::map<std::string,std::string>::iterator i;
00345             i = mInputs.find(name);
00346             if (i!=mInputs.end()) {
00347                Set(box,input,(*i).second);
00348             }
00349          }
00350         // If the dialog mode is set to TextDialog
00351         // The user is prompted for the value
00352         else if (mDialogMode == TextDialog) 
00353         {
00354            std::cout << name << "=";
00355            std::string ans;
00356            std::cin >> ans;
00357            Set(box,input,ans);
00358         }
00359 #ifdef _USE_WXWIDGETS_
00360        // If the dialog mode is set to GraphicalDialog
00361        // A dialog box is pop up
00362        else if (mDialogMode == GraphicalDialog) 
00363        {
00364           std::string mess("Enter the value of '");
00365           mess += name;
00366           mess += "' (";
00367           mess += help;
00368           mess += ")";
00369           std::string title(name);
00370           title += " ?";
00371           std::string ans = wx2std ( wxGetTextFromUser( std2wx (mess), std2wx(title)));
00372           Set(box,input,ans); 
00373        }
00374 #endif
00375     }
00376 
00377     GetCurrentDescriptor()->DefineInput(name,box,input,help);
00378 
00379   }
00380   //=======================================================================
00381 
00382   //=======================================================================
00383    void Executer::DefineOutput ( const std::string &name,
00384                                  const std::string &box,
00385                                  const std::string &output,
00386                                  const std::string& help)
00387   {
00388     GetCurrentDescriptor()->DefineOutput(name,box,output,help);
00389   }
00390   //=======================================================================
00391 
00392   //=======================================================================
00393   void Executer::Set (const std::string &box,
00394                       const std::string &input,
00395                       const std::string &value)
00396   {
00397     BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
00398     // Looks for the adaptor
00399 
00400     if ( b->bbGetInputType(input) !=  typeid(std::string) ) 
00401       {
00402         BlackBox::Pointer a =
00403            GetFactory()->NewAdaptor(typeid(std::string),
00404                                     b->bbGetInputType(input),
00405                                     "tmp");
00406          if (!a) 
00407            {
00408              bbtkError("No <"<<
00409                        TypeName(b->bbGetInputType(input))
00410                        <<"> to <std::string> found");
00411            }
00412          std::string v(value);
00413          a->bbSetInput("In",v);
00414          a->bbExecute();
00415          b->bbSetInput(input,a->bbGetOutput("Out"));
00416          //         a->Delete();
00417       }
00418     else 
00419       {
00420       std::string v(value);
00421       b->bbSetInput(input,v);
00422       }
00423   }
00424   //=======================================================================
00425 
00426   //=======================================================================
00427   std::string Executer::Get(const std::string &box,
00428                             const std::string &output)
00429   {
00430     BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
00431     // Looks for the adaptor
00432     if (b->bbGetOutputType(output) != typeid(std::string)) 
00433       {
00434         BlackBox::Pointer a =
00435           GetFactory()->NewAdaptor(
00436                                    b->bbGetOutputType(output),
00437                                    typeid(std::string),
00438                                    "tmp");
00439         if (!a) 
00440           {
00441             bbtkError("No <"<<
00442                       TypeName(b->bbGetOutputType(output))
00443                       <<"> to <std::string> found");
00444           }
00445         b->bbExecute();
00446         
00447         a->bbSetInput("In",b->bbGetOutput(output));
00448         a->bbExecute();
00449         std::string r = a->bbGetOutput("Out").unsafe_get<std::string>();
00450         //std::string v = *((std::string*)a->bbGetOutput("Out")) ;
00451         //   std::cout << a->bbGetOutput("Out").unsafe_get<std::string>() 
00452         //             << std::endl;
00453         //std::string v(value);
00454         //b->bbSetInput(input,a->bbGetOutput("Out"));
00455         //        a->bbDelete();
00456         return r;
00457       }
00458     else
00459       {
00460         b->bbExecute();
00461         return b->bbGetOutput(output).unsafe_get<std::string>();
00462         // std::string v = *((std::string*)b->bbGetOutput(output)) ;
00463         // std::cout << b->bbGetOutput("Out").unsafe_get<std::string>() 
00464         //   << std::endl;
00465         // b->bbSetInput(input,&v);
00466       }
00467   }
00468   //=======================================================================
00469 
00470   //=======================================================================
00471   void Executer::Author(const std::string &authorName)
00472   {
00473     GetCurrentDescriptor()->AddToAuthor(authorName,GetCurrentDescriptor()==GetWorkspace());
00474   }
00475   //=======================================================================
00476 
00477   //=======================================================================
00478   void Executer::Category(const std::string &category)
00479   {
00480     GetCurrentDescriptor()->AddToCategory(category,GetCurrentDescriptor()==GetWorkspace());
00481   }
00482   //=======================================================================
00483 
00484   //=======================================================================
00485   void Executer::Description(const std::string &d)
00486   {
00487     GetCurrentDescriptor()->AddToDescription(d,GetCurrentDescriptor()==GetWorkspace());
00488   }
00489   //=======================================================================
00490 
00491   //=======================================================================
00493   void Executer::PrintBoxes()
00494   {
00495     bbtkMessageInc("Help",1,"The black box descriptor \""
00496                    <<GetCurrentDescriptor()->GetTypeName()<<"\" contains : "<<std::endl);
00497     GetCurrentDescriptor()->PrintBlackBoxes();
00498     bbtkDecTab("Help",1);
00499  }
00500   //=======================================================================
00501 
00502   //=======================================================================
00503   std::string Executer::ShowGraph(const std::string &nameblackbox, 
00504                                   const std::string &detailStr, 
00505                                   const std::string &levelStr,
00506                                   const std::string &output_html,
00507                                   const std::string &custom_header,
00508                                   const std::string &custom_title,
00509                                   bool system_display )
00510   {
00511     int detail  =       atoi(detailStr.c_str());
00512     int level   =       atoi(levelStr.c_str());
00513 
00514     std::string filename_rootHtml (output_html) ;
00515     std::string simplefilename_rootHtml ( Utilities::get_file_name(output_html));
00516 
00517     bool relative_link = true;
00518 
00519     // No output provided : automatic generation
00520     if (output_html.length() == 0)
00521       {
00522                 // Don't pollute the file store with  "temp_dir" directories ...    
00523                 std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
00524         
00525                 char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
00526         
00527                 std::string directory = default_doc_dir; 
00528                 if (c != '/' && c !='\\') directory = directory + "/";
00529                 directory = directory +  "temp_dir";    
00530         
00531                 filename_rootHtml = directory + "/" + "User.html";
00532                 simplefilename_rootHtml = "User.html" ;
00533 
00534                 // Creating directory
00535                 std::string command0("mkdir \"" +directory + "\"");
00536                 system( command0.c_str() );
00537 
00538                 relative_link = false;
00539       }
00540 
00541     Package::Pointer p;
00542     try
00543     {
00544        p = GetFactory()->GetPackage(nameblackbox);
00545     }
00546     catch (Exception e)
00547     {
00548       p = GetUserPackage();
00549     }
00550     // Generating documentation-help of workspace
00551     p->SetDocURL(filename_rootHtml);
00552     p->SetDocRelativeURL(simplefilename_rootHtml);
00553 
00554     p->CreateHtmlPage(filename_rootHtml,"bbtk","user package",custom_header,custom_title,detail,level,relative_link);
00555 
00556     std::string page = filename_rootHtml;
00557     /*
00558     try 
00559     {
00560        ShowGraphTypes(nameblackbox);
00561     }
00562     catch (bbtk::Exception a)
00563     {
00564        std::cout <<"EXC"<<std::endl;
00565        page = ShowGraphInstances(nameblackbox,detail,level,system_display);
00566     }
00567     */
00568     return page;
00569   }
00570   //=======================================================================
00571 
00572   //=======================================================================
00574   std::string Executer::ShowGraphInstances(const std::string &nameblackbox, int detail, int level,
00575                                            bool system_display)
00576   {
00577 
00578     BlackBox::Pointer blackbox;
00579     if (nameblackbox==".")
00580     {
00581        blackbox = GetCurrentDescriptor()->GetPrototype();
00582     }
00583     else
00584     {
00585        blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
00586     }
00587     
00588     std::string page;
00589 
00590     if (blackbox)
00591       {      
00592         // Don't pollute the file store with  "temp_dir" directories ...
00593         std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
00594         char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
00595 
00596         std::string directory = default_doc_dir; 
00597         if (c != '/' && c !='\\') directory = directory + "/";
00598 
00599         directory = directory +  "temp_dir";
00600         //std::string directory("temp_dir");
00601         std::string filename(directory + "/" + "bbtk_graph_pipeline");
00602         std::string filename_html(filename+".html");
00603         std::string command0("mkdir \""+directory + "\"");
00604 
00605 #if defined(_WIN32)
00606         std::string command2("start ");
00607 #else 
00608         std::string command2("gnome-open ");
00609 #endif
00610 
00611         command2=command2+filename_html;
00612         page = filename_html;
00613         // 1. Generate Html Diagram
00614         std::ofstream s;
00615         s.open(filename_html.c_str());
00616         if (s.good()) 
00617           {
00618             s << "<html><head><title>BBtk graph diagram</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head>\n";
00619             s << "<body bgcolor=\"#FFFFFF\" text=\"#000000\"> \n\n";
00620             if ( blackbox->bbGetName()=="workspacePrototype" )
00621               {
00622                 s << "<center>Current workspace</center>";
00623               } else {
00624               s << "<center>" << blackbox->bbGetName()<< "</center>";
00625             } 
00626 
00627             blackbox->bbInsertHTMLGraph( s, detail, level, true, directory, false );
00628             s << "</body></html>\n";
00629           }
00630         s.close();
00631         
00632         // 2. Starting Browser
00633         if (system_display) system( command2.c_str() );      
00634       } 
00635     else 
00636       {
00637         bbtkMessageInc("Help",1,"No black box: \""
00638                        <<nameblackbox<<"\" " <<std::endl);
00639       }
00640     return page;
00641   }
00642   //=======================================================================
00643 
00644   //=======================================================================
00645   void Executer::ShowRelations(const std::string &nameblackbox, 
00646                                const std::string &detailStr, 
00647                                const std::string &levelStr)
00648   {
00649     bool found=false;
00650     
00651     int detail = atoi(detailStr.c_str());
00652     int level  = atoi(levelStr.c_str());
00653     BlackBox::Pointer blackbox;
00654     if (nameblackbox.compare(".")==0)
00655       {
00656         blackbox=GetCurrentDescriptor()->GetPrototype();
00657       } 
00658     else 
00659       {
00660         blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
00661       }
00662     
00663     if (blackbox)
00664       {
00665         found=true;
00666         blackbox->bbShowRelations(blackbox,detail,level); //,mFactory);
00667       }
00668     
00669     if (!found) 
00670       {
00671         bbtkError("Blackbox Name not found.. <"  <<nameblackbox<<">");
00672       }
00673   }
00674   //=======================================================================
00675 
00676   //=======================================================================
00678   void Executer::SetMessageLevel(const std::string &kind,
00679                                  int level)
00680   {
00681     bbtk::MessageManager::SetMessageLevel(kind,level);
00682   }
00683   //=======================================================================
00684 
00685   //=======================================================================
00687   void  Executer::HelpMessages()
00688   {
00689     bbtk::MessageManager::PrintInfo();
00690   }
00691   //=======================================================================
00692 
00693   //=======================================================================
00695   void Executer::Print(const std::string &str)
00696   {  
00697     if (GetNoExecMode() &&  (GetCurrentDescriptor()==GetWorkspace()) ) return;
00698     if (GetCurrentDescriptor()!=GetWorkspace()) return;
00699 
00700     bbtkDebugMessageInc("Interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
00701 
00702  // TO DO :
00703  // InterpretLine ("load std")
00704  // InterpretLine("new ConcatStrings _C_ ") -> trouver un nom unique : # commande 
00705  // InterpretLine("new Print _P_") 
00706  // InterpretLine("connect _C_.Out _P_.In")
00707  // int num = 1
00708  
00709 
00710     std::vector<std::string> chains;
00711     std::string delimiters("$");
00712 
00713     // Skip delimiters at beginning.
00714     std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
00715     bool is_text = true;
00716     if (lastPos>0) is_text = false;
00717 
00718     // Find first delimiter.
00719     std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
00720 
00721     while (std::string::npos != pos || std::string::npos != lastPos)
00722     {
00723        if (is_text) 
00724        {
00725           // Found a text token, add it to the vector.
00726           chains.push_back(str.substr(lastPos, pos - lastPos));
00727  // std::string token = str.substr(lastPos, pos - lastPos)
00728  // InterpretLine("set _C_.In%num% %token%")
00729  
00730        }
00731        else 
00732        {
00733 
00734        // is an output (between $$) : decode 
00735          std::string tok,box,output;
00736          tok = str.substr(lastPos, pos - lastPos);
00737          Utilities::SplitAroundFirstDot(tok,box,output);
00738          chains.push_back( Get(box,output) );
00739 
00740 // InterpretLine("connect %tok% _C_.In%num%") 
00741 
00742        }
00743         // Skip delimiters.  Note the "not_of"
00744        lastPos = str.find_first_not_of(delimiters, pos);
00745         // Find next delimiter
00746        pos = str.find_first_of(delimiters, lastPos);
00747     //
00748        is_text = !is_text;
00749 // num ++;
00750      }
00751 // InterpretLine("exec _P_")
00752 // if (IS_IN_WORKSPACE) InterpretLine("delete _C_; delete _P_");
00753 
00754     std::vector<std::string>::iterator i;
00755     for (i= chains.begin(); i!=chains.end(); ++i) 
00756       {
00757         Utilities::SubsBackslashN(*i);
00758         bbtkMessage("Output",1,*i);
00759       }
00760     bbtkMessage("Output",1,std::endl);
00761   }
00762   //==========================================================================
00763 
00764   //==========================================================================
00765   std::string Executer::GetObjectName() const
00766   {
00767     return std::string("Executer");
00768   }
00769   //==========================================================================
00770   
00771   //==========================================================================
00772   std::string  Executer::GetObjectInfo() const 
00773   {
00774     std::stringstream i;
00775     return i.str();
00776   }
00777   //==========================================================================
00778   //==========================================================================
00779 size_t  Executer::GetObjectSize() const 
00780 {
00781   size_t s = Superclass::GetObjectSize();
00782   s += Executer::GetObjectInternalSize();
00783   return s;
00784   }
00785   //==========================================================================
00786   //==========================================================================
00787 size_t  Executer::GetObjectInternalSize() const 
00788 {
00789   size_t s = sizeof(Executer);
00790   return s;
00791   }
00792   //==========================================================================
00793   //==========================================================================
00794   size_t  Executer::GetObjectRecursiveSize() const 
00795   {
00796     size_t s = Superclass::GetObjectRecursiveSize();
00797     s += Executer::GetObjectInternalSize();
00798     s += mFactory->GetObjectRecursiveSize();
00799     return s;
00800   }
00801   //==========================================================================
00802 }//namespace

Generated on Wed Nov 12 11:37:08 2008 for BBTK by  doxygen 1.5.6