bbtkTranscriptor.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkTranscriptor.cxx,v $
00004   Language:  C++
00005   Date:      $Date: 2008/10/17 08:18:14 $
00006   Version:   $Revision: 1.14 $
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 "bbtkTranscriptor.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   Transcriptor::Pointer Transcriptor::New(const std::string& filename)
00053   {
00054     return MakePointer(new Transcriptor(filename));
00055   }
00056 
00060   Transcriptor::Transcriptor(const std::string& filename)
00061     :
00062       mDialogMode(NoDialog)
00063   {
00064     //VirtualExec();    
00065     bbtkDebugMessageInc("Kernel",9,"Transcriptor::Transcriptor()" <<std::endl);
00066  
00067      //std::ofstream *m_Fp = new std::ofstream();
00068     m_Fp.open (filename.c_str(), std::ios::out );
00069 
00070     std::string file,path;
00071     file = bbtk::Utilities::ExtractScriptName(filename,path);
00072     
00073     m_Fp << "#include \"bbtkExecuter.h\"" << std::endl; 
00074     m_Fp << "void " << file << "(bbtk::Executer::Pointer e)"<<std::endl;
00075     m_Fp << "{"<<std::endl;
00076 
00077     /*
00078 #ifdef _USE_WXWIDGETS_
00079     m_Fp << "#ifdef _USE_WXWIDGETS_"<<std::endl;
00080     m_Fp << "#include \"bbtkWx.h\""<< std::endl<<std::endl;
00081     m_Fp << "class myApp : public wxApp"<<std::endl;
00082     m_Fp << "{"<<std::endl;
00083     m_Fp << "public:"<<std::endl;
00084     m_Fp << "  bool OnInit( );"<<std::endl;
00085     m_Fp << "  int  OnExit() { delete e; return true; }"<<std::endl;
00086     m_Fp << "  bbtk::Executer* e;"<<std::endl;
00087     m_Fp << "};"<<std::endl<<std::endl;
00088     m_Fp << "IMPLEMENT_APP(myApp);"<<std::endl<<std::endl;
00089     m_Fp << "bool myApp::OnInit( )"<<std::endl;
00090     m_Fp << "{"<<std::endl;
00091     m_Fp << "  wxApp::OnInit();"<<std::endl;
00092     m_Fp << "#ifdef __WXGTK__"<<std::endl;
00093     m_Fp << "  //See http://www.wxwindows.org/faqgtk.htm#locale"<<std::endl;
00094     m_Fp << "  setlocale(LC_NUMERIC, \"C\");"<<std::endl;
00095     m_Fp << "#endif"<<std::endl;
00096     m_Fp << "  wxInitAllImageHandlers();"<<std::endl;
00097     m_Fp << "  bbtk::Wx::CreateInvisibleTopWindow();"<<std::endl;
00098     m_Fp << "  try {"<<std::endl;
00099     m_Fp << "  e = new bbtk::Executer();"<<std::endl;
00100 #else
00101     m_Fp << "main(int argc, char *argv[]) {"                << std::endl;
00102     m_Fp << "  bbtk::Executer *e = new bbtk::Executer();"   << std::endl;
00103 #endif 
00104     */
00105     bbtkDebugDecTab("Kernel",9);
00106  }
00107 
00111   Transcriptor::~Transcriptor()
00112   {
00113   
00114     bbtkDebugMessageInc("Kernel",9,"Transcriptor::~Transcriptor()" <<std::endl);
00115     /*
00116 #ifdef _USE_WXWIDGETS_
00117     m_Fp << "  }"<<std::endl;
00118     m_Fp << "  catch (bbtk::Exception err)"<<std::endl;
00119     m_Fp << "  {"<<std::endl;
00120     m_Fp << "    err.Print();"<<std::endl;
00121     m_Fp << "  } "<<std::endl;
00122     m_Fp << "  return true;"<<std::endl;
00123     m_Fp << "}"   << std::endl;
00124     m_Fp << "#endif"<<std::endl;
00125 #else 
00126     m_Fp << "}"   << std::endl;
00127 #endif
00128     */
00129     m_Fp << "}"   << std::endl;
00130     m_Fp.close();
00131 
00132     bbtkDebugDecTab("Kernel",9);
00133   }
00134   
00135 
00136   void Transcriptor::Reset()
00137   {
00138      m_Fp << "  e->Reset( );" << std::endl;
00139   }
00140 
00141   void Transcriptor::SetWorkspaceName( const std::string& name )
00142   {
00143   
00144     m_Fp << "  e->SetWorkspaceName( \"" << name << "\" );" << std::endl;
00145   }
00146 
00147   void Transcriptor::BeginPackage (const std::string &name)
00148   {
00149      m_Fp << "  e->BeginPackage( \"" << name << "\" );" << std::endl;
00150   }
00151 
00152   void Transcriptor::EndPackage()
00153   {
00154      m_Fp << "  e->EndPackage( );" << std::endl;
00155   }
00156 
00157   void Transcriptor::Define (const std::string &name,
00158                              const std::string &pack,
00159                              const std::string &scriptfilename)
00160   {
00161      m_Fp << "  e->Define(\"" << name << "\", \"" <<  pack << "\", \""
00162           << scriptfilename  << "\" );" << std::endl;
00163   }
00164 
00165   void Transcriptor::SetCurrentFileName (const std::string &name )
00166   {
00167      m_Fp << "  e->SetCurrentFileName( \"" << name << "\" );" << std::endl;
00168   }
00169 
00170   void Transcriptor::EndDefine ()
00171   {
00172      m_Fp << "  e->EndDefine( );" << std::endl;
00173   }
00174 
00175   void Transcriptor::Kind(const std::string& kind)
00176   {
00177     m_Fp << "  e->Kind( \""<<kind<<"\" );" << std::endl;
00178   }
00179 
00180 
00181   void Transcriptor::Create ( const std::string& nodeType, 
00182                               const std::string& nodeName)
00183   {
00184     m_Fp << "  e->Create(\"" << nodeType << "\", \"" 
00185          <<  nodeName << "\");" << std::endl;
00186   }
00187 
00188 
00189   void Transcriptor::Destroy (const std::string &nodeName)
00190   {
00191     m_Fp << "  e->Destroy(" <<  nodeName << ");" << std::endl;
00192   }
00193 
00194   void Transcriptor::Connect (const std::string &nodeFrom,
00195                               const std::string &outputLabel,
00196                               const std::string &nodeTo, 
00197                               const std::string &inputLabel)
00198   {
00199     m_Fp << "  e->Connect(\""<< nodeFrom << "\", \"" 
00200          <<  outputLabel << "\", \""
00201          << nodeTo  << "\", \"" << inputLabel<< "\");" << std::endl;
00202   }
00203 
00204 
00205   void Transcriptor::Execute (const std::string &nodeName)
00206   {
00207      m_Fp << "  e->Execute(\"" << nodeName << "\");" << std::endl;
00208   }
00209 
00210   void Transcriptor::DefineInput ( const std::string &name,
00211                                    const std::string &box,
00212                                    const std::string &input,
00213                                    const std::string& help)
00214   {
00215   
00216     m_Fp << "  e->DefineInput(\""<< name << "\", \"" <<  box << "\", \""
00217          << input << "\", \"" << help << "\");" << std::endl;
00218   }
00219 
00220   
00221   void Transcriptor::DefineOutput ( const std::string &name,
00222                                     const std::string &box,
00223                                     const std::string &output,
00224                                     const std::string& help)
00225   {
00226     m_Fp << "  e->DefineOutput(\""<< name << "\", \"" <<  box << "\", \""
00227          << output << "\", \"" << help << "\");" << std::endl;
00228   }
00229 
00230  
00231   void Transcriptor::Set (const std::string &box,
00232                           const std::string &input,
00233                           const std::string &value)
00234   {
00235     m_Fp << "  e->Set(\""<< box << "\", \"" << input
00236          << "\", \"" << value << "\");"
00237          << std::endl;
00238   }
00239 
00240   std::string Transcriptor::Get(const std::string &box,
00241                                 const std::string &output)
00242   {
00243   
00244     m_Fp << "  e->Get(\""<< box << "\", \"" << output << "\");"
00245          << std::endl;
00246     return "";
00247   }
00248 
00249 
00250   void Transcriptor::Author(const std::string &authorName)
00251   {
00252     
00253     m_Fp << "  e->Author(\"" << authorName << "\");" << std::endl;
00254   }
00255 
00256   void Transcriptor::Category(const std::string &category)
00257   {
00258     m_Fp << "  e->Category(\"" << category << "\");" << std::endl;
00259   }
00260 
00261   void Transcriptor::Description(const std::string &d)
00262   {
00263     m_Fp << "  e->Description(\"" << d << "\");" << std::endl;
00264   }
00265 
00267   void Transcriptor::PrintBoxes()
00268   {
00269      m_Fp << "  e->PrintBoxes( );" << std::endl;
00270  }
00271 
00272   std::string Transcriptor::ShowGraph(const std::string &nameblackbox,
00273                                   const std::string &detailStr,
00274                                   const std::string &levelStr,
00275                                   const std::string &output_html,
00276                                   const std::string &custom_header,
00277                                   const std::string &custom_title,
00278                                   bool system_display )
00279   {
00280 
00281        m_Fp << "  e->ShowGraph(\"" << nameblackbox  << "\", \"" 
00282                                       << detailStr     << "\", \""
00283                                       << levelStr      << "\", \""
00284                                       << output_html   << "\", \""
00285                                       << custom_header << "\", \""
00286                                       <<  custom_title << "\");"                                     
00287                                       << std::endl;
00288 
00289     return ""; 
00290   }
00291 
00292    std::string Transcriptor::ShowGraphInstances(const std::string &nameblackbox, int detail, int level,
00293                                                bool system_display)
00294   {
00295     return "";
00296   
00297   }
00298 
00299 void Transcriptor::ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr)
00300   {
00301      
00302   }
00303 
00304   void Transcriptor::Print(const std::string & message)
00305   {
00306     m_Fp << "  e->Print(\"" <<message<<"\");"<<std::endl;
00307   }
00308 
00309 
00310   
00311   void Transcriptor::SetMessageLevel(const std::string &kind,
00312                        int level)
00313   {
00314     m_Fp << "  e->SetMessageLevel(\"" <<kind<<"\","<<level<<");"<<std::endl;
00315   }
00316   
00317 
00318   void Transcriptor::HelpMessages()
00319   {
00320     m_Fp << "  e->HelpMessages();"<<std::endl;
00321   }
00322   
00323   void Transcriptor::LoadPackage(const std::string &name )
00324   {
00325     m_Fp << "  e->LoadPackage(\"" <<name<<"\");"<<std::endl;
00326   }
00327   
00328   
00329   void Transcriptor::UnLoadPackage(const std::string &name )
00330   {
00331     m_Fp << "  e->UnLoadPackage(\"" <<name<<"\");"<<std::endl;
00332   }
00333 
00334  //==========================================================================
00335   std::string Transcriptor::GetObjectName() const
00336   {
00337     return std::string("Transcriptor");
00338   }
00339   //==========================================================================
00340   
00341   //==========================================================================
00342   std::string  Transcriptor::GetObjectInfo() const 
00343   {
00344     std::stringstream i;
00345     return i.str();
00346   }
00347   //==========================================================================
00348 
00349  //==========================================================================
00350 size_t  Transcriptor::GetObjectSize() const 
00351 {
00352   size_t s = Superclass::GetObjectSize();
00353   s += Transcriptor::GetObjectInternalSize();
00354   return s;
00355   }
00356   //==========================================================================
00357   //==========================================================================
00358 size_t  Transcriptor::GetObjectInternalSize() const 
00359 {
00360   size_t s = sizeof(Transcriptor);
00361   return s;
00362   }
00363   //==========================================================================
00364   //==========================================================================
00365   size_t  Transcriptor::GetObjectRecursiveSize() const 
00366   {
00367     size_t s = Superclass::GetObjectRecursiveSize();
00368     s += Transcriptor::GetObjectInternalSize();
00369     return s;
00370   }
00371   //==========================================================================
00372 
00373 
00374 }//namespace

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