]> Creatis software - bbtk.git/commitdiff
improvements
authorjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 14 Feb 2008 20:23:51 +0000 (20:23 +0000)
committerjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 14 Feb 2008 20:23:51 +0000 (20:23 +0000)
kernel/src/bbtkTranscriptor.cxx
kernel/src/bbtkTranscriptor.h

index 5eee475d6c77c840f87b9c63e1b83255c3afd77d..65c947d7aa1fb39e7ab5c2c9c2b19672381c8f72 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkTranscriptor.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/02/14 17:40:09 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/02/14 20:23:51 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,27 +49,29 @@ namespace bbtk
     bbtkDebugMessageInc("Kernel",9,"Transcriptor::Transcriptor()" <<std::endl);
     Reset();
     bbtkDebugDecTab("Kernel",9);
-    
+
     //std::ofstream *m_Fp = new std::ofstream();
     m_Fp.open (filename.c_str(), std::ios::out );
 
     m_Fp << "#include \"bbtkExecuter.h\""                   << std::endl;
     m_Fp << "main(int argc, char *argv[]) {"                << std::endl;
     m_Fp << "  bbtk::Executer *e = new bbtk::Executer();"   << std::endl;
-  } 
+  }
 
 /**
  *
  */
   Transcriptor::~Transcriptor()
   {
+  
+std::cout << "====================================================== delete Transcriptor\n";
      bbtkDebugMessageInc("Kernel",9,"Transcriptor::~Transcriptor()" <<std::endl);
      if (mRoot) 
      {
         mPackage->UnRegisterBlackBox("workspace");
-        delete mRoot;    
+        delete mRoot;
      }
-     if (mPackage) 
+     if (mPackage)
      {
         GetGlobalFactory()->UnLoadPackage("user");
      }
@@ -84,16 +86,16 @@ namespace bbtk
   }
 
 
-// ========================= Begin of Battelfield ========================================================================
+// ========================= Begin of Battlefield ========================================================================
 
 
 /**
- *  
+ *
  */
   void Transcriptor::Reset()
   {
-
      m_Fp << "  e->Reset( );" << std::endl;
+
   /*
     bbtkDebugMessageInc("Kernel",9,"Transcriptor::Reset()" <<std::endl);
 
@@ -103,12 +105,12 @@ namespace bbtk
     // all user defined CBB otherwise any instance 
     // of a user CBB that is in the 'workspace' would try to 
     // access a user CBB descriptor which has been previously freed
-    if (mRoot) 
+    if (mRoot)
     {
        mPackage->UnRegisterBlackBox(mRoot->GetTypeName());
-       delete mRoot;    
+       delete mRoot;
     }
-    if (mPackage) 
+    if (mPackage)
     {
        GetGlobalFactory()->UnLoadPackage("user");
     }
@@ -133,16 +135,17 @@ namespace bbtk
   }
 
   /// changes the workspace name
-  void Transcriptor::SetWorkspaceName( const std::string& n )
+  void Transcriptor::SetWorkspaceName( const std::string& name )
   {
   
-     m_Fp << "// ==> SetWorkspaceName() called here" << std::endl;    
-   // mPackage->ChangeBlackBoxName( mRoot->GetTypeName(), n );
+     m_Fp << "  e->SetWorkspaceName( \"" << name << "\" );" << std::endl;
+
+   // mPackage->ChangeBlackBoxName( mRoot->GetTypeName(), name );
   }
 
   void Transcriptor::BeginPackage (const std::string &name)
   {
-     m_Fp << "// ==> BeginPackage() called here" << std::endl;  
+     m_Fp << "  e->BeginPackage( \"" << name << "\" );" << std::endl;
   /*
      bbtkDebugMessageInc("Kernel",9,"Executer::BeginPackage(\""<<name<<"\")"
                         <<std::endl);
@@ -154,10 +157,10 @@ namespace bbtk
     catch (Exception e)
       {
          p = new Package(name,
-         "",
-         "",
-         "",
-         BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
+                         "",
+                         "",
+                         "",
+                         BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
          InsertPackage(p);
       }
      mOpenPackage.push_back(p);
@@ -166,7 +169,7 @@ namespace bbtk
 
   void Transcriptor::EndPackage()
   {
-     m_Fp << "// ==> EndPackage() called here" << std::endl;    
+     m_Fp << "  e->EndPackage( );" << std::endl;
    // if (mOpenPackage.size()>1) mOpenPackage.pop_back();
   }
 
@@ -174,10 +177,11 @@ namespace bbtk
                              const std::string &pack,
                              const std::string &scriptfilename)
   {
-     m_Fp << "// on Define, Define() called here" << std::endl;   
+     m_Fp << "  e->Define(\"" << name << "\", \"" <<  pack << "\", \""
+          << scriptfilename  << "\" );" << std::endl;
   /*
     bbtkDebugMessageInc("Kernel",9,"Executer::Define(\""<<name<<
-                        ","<<pack<<"\")" 
+                        ","<<pack<<"\")"
                         <<std::endl);
 
     ComplexBlackBoxDescriptor* b = new ComplexBlackBoxDescriptor(name);
@@ -191,15 +195,14 @@ namespace bbtk
   /// Sets the file name to use for the current definition
   /// (Used to set it after the Define command)
   void Transcriptor::SetCurrentFileName (const std::string &name )
-  
   {
-    m_Fp << "// ==>on Include : SetCurrentFileName( ) called here" << std::endl;
+     m_Fp << "  e->SetCurrentFileName( \"" << name << "\" );" << std::endl;
    // mOpenDefinition.back().box->SetScriptFileName(name);
   }
 
   void Transcriptor::EndDefine ()
   {
-    m_Fp << "// ==> on EndDefine, EndDefine( ); called here " << std::endl;
+     m_Fp << "  e->EndDefine( );" << std::endl;
 
   /*
     bbtkDebugMessageInc("Kernel",9,"Executer::EndDefine(\""
@@ -251,13 +254,13 @@ namespace bbtk
     // Current()->RemoveBlackBox(nodeName);
     //  m_Fp << "  e->Remove(" <<  nodeName << ");" << std::endl;
   }
-  */ 
+  */
 
 /**
- *  
+ *
  */
-  void Transcriptor::Connect (const std::string &nodeFrom, 
-                              const std::string &outputLabel, 
+  void Transcriptor::Connect (const std::string &nodeFrom,
+                              const std::string &outputLabel,
                               const std::string &nodeTo, 
                               const std::string &inputLabel)
   {
@@ -267,10 +270,13 @@ namespace bbtk
   }
 
  /**
- *  
+ *
  */ 
   void Transcriptor::Update (const std::string &nodeName) // would 'Execute' be more meaningfull ?
   {
+  
+     m_Fp << "  e->Update(\"" << nodeName << "\");" << std::endl;
+/*     
  // if in root
      if (Current()==mRoot) 
      {
@@ -285,6 +291,7 @@ namespace bbtk
         //Current()->AddToExecutionList(nodeName) ;
         m_Fp << "  e->AddToExecutionList(\"" << nodeName << "\");" << std::endl;
      }
+*/
   }
 
 /**
@@ -295,16 +302,10 @@ namespace bbtk
                                    const std::string &input,
                                    const std::string& help)
   {
-    // If the input is defined in the Root box
-    if (Current()==mRoot)
-    {
-       m_Fp << "// ==> Some extra work to do when Current()==mRoot" << std::endl;
-
-    }
+  
     m_Fp << "  e->DefineInput(\""<< name << "\", " <<  box << ", "
          << input << ", \"" << help << "\");" << std::endl;
 
-
   /*
     // If the input is defined in the Root box
     if (Current()==mRoot) 
@@ -343,7 +344,6 @@ namespace bbtk
           mess += ")";
           std::string title(name);
           title += " ?";
-
           std::string ans = wx2std ( wxGetTextFromUser( std2wx (mess), std2wx(title)));
           Set(box,input,ans); 
        }
@@ -354,7 +354,7 @@ namespace bbtk
 */
 
   }
-  
+
  /**
  *  
  */ 
@@ -375,17 +375,16 @@ namespace bbtk
                           const std::string &input,
                           const std::string &value)
   {
-  
-    m_Fp << "// ==> Set() called here"                   << std::endl; 
-    m_Fp << "  e->GetPrototype()->bbGetBlackBox(\""<< box << "\");" << std::endl;
+    m_Fp << "  e->Set(\""<< box << "\", \"" << input<< "\", \"" << value << "\");"
+         << std::endl;
+
 /*
     BlackBox* b = Current()->GetPrototype()->bbGetBlackBox(box);
     // Looks for the adaptor
 
     if ( b->bbGetInputType(input) !=  typeid(std::string) ) 
       {
-         BlackBox* a = 
+         BlackBox* a =
          NewAdaptor(typeid(std::string),
                     b->bbGetInputType(input),
                     "tmp");
@@ -410,19 +409,20 @@ namespace bbtk
   }
 
   /**
-   *  
-   */ 
+   *
+   */
   std::string Transcriptor::Get(const std::string &box,
                                 const std::string &output)
   {
   
-    m_Fp << "// ==> Get() called here"                   << std::endl;  
+    m_Fp << "  e->Get(\""<< box << "\", \"" << output << "\");"
+         << std::endl;
 /*    
     BlackBox* b = Current()->GetPrototype()->bbGetBlackBox(box);
     // Looks for the adaptor
     if (b->bbGetOutputType(output) != typeid(std::string)) 
       {
-      BlackBox* a = 
+      BlackBox* a =
           NewAdaptor(
              b->bbGetOutputType(output),
              typeid(std::string),
@@ -446,7 +446,7 @@ namespace bbtk
         a->bbDelete();
         return r;
       }
-    else 
+    else
       {
        b->bbExecute();
        return b->bbGetOutput(output).unsafe_get<std::string>();
@@ -461,42 +461,29 @@ namespace bbtk
 
   void Transcriptor::Author(const std::string &authorName)
   {
-  m_Fp << "  e->AddToAuthor(\"" << authorName << "\", true)" << std::endl;
+
+  m_Fp << "  e->AddToAuthor(\"" << authorName << "\")" << std::endl;
   return; // just to see
+
     //Current()->AddToAuthor(authorName,Current()==mRoot);
-    if (Current()==mRoot)    
-       m_Fp << "  e->AddToAuthor(\"" << authorName << "\", true)" << std::endl;
-    else
-       m_Fp << "  e->AddToAuthor(\"" << authorName << "\", false)" << std::endl;
   }
 
   void Transcriptor::Category(const std::string &category)
   {
-   m_Fp << "  e->AddToCategory(\"" << category << "\", true)" << std::endl;
-   return; // just to see            
+      m_Fp << "  e->AddToCategory(\"" << category << "\")" << std::endl;
     //Current()->AddToCategory(category,Current()==mRoot);
-    if (Current()==mRoot)    
-       m_Fp << "  e->AddToCategory(\"" << category << "\", true)" << std::endl;
-    else
-       m_Fp << "  e->AddToCategory(\"" << category << "\", false)" << std::endl;
   }
 
   void Transcriptor::Description(const std::string &d)
   {
-  m_Fp << "  e->AddToDescription(\"" << d << "\", true)" << std::endl;
-  return; // just to see
+     m_Fp << "  e->AddToDescription(\"" << d << "\")" << std::endl;
     // Current()->AddToDescription(d,Current()==mRoot);
-    if (Current()==mRoot)    
-       m_Fp << "  e->AddToDescription(\"" << d << "\", true)" << std::endl;
-    else
-       m_Fp << "  e->AddToDescription(\"" << d << "\", false)" << std::endl;    
   }
 
-
   /// prints the list of the boxes of the current descriptor
   void Transcriptor::PrintBoxes()
-  { 
-    m_Fp << "// ==> :PrintBoxes() called here"                   << std::endl;           
+  {
+     m_Fp << "  e->PrintBoxes( )" << std::endl;
  /* 
     bbtkMessageInc("Help",1,"The black box descriptor \""
                    <<Current()->GetTypeName()<<"\" contains : "<<std::endl);
@@ -505,16 +492,25 @@ namespace bbtk
  */
  }
 
-// =========================End of Battelfield ========================================================================
+// =========================End of Battlefield ========================================================================
 
-  std::string Transcriptor::ShowGraph(const std::string &nameblackbox, 
-                                 const std::string &detailStr, 
+  std::string Transcriptor::ShowGraph(const std::string &nameblackbox,
+                                 const std::string &detailStr,
                                  const std::string &levelStr,
                                  const std::string &output_html,
                                  const std::string &custom_header,
                                  const std::string &custom_title,
                                  bool system_display )
   {
+
+       m_Fp << "  e->DefineOutput(\"" << nameblackbox  << "\", \"" 
+                                      << detailStr     << "\", \""
+                                      << levelStr      << "\", \""
+                                      << output_html   << "\", \""
+                                      << custom_header << "\", \""
+                                      <<  custom_title << "\");"                                     
+                                      << std::endl;
+  /*
     int detail =       atoi(detailStr.c_str());
     int level  =       atoi(levelStr.c_str());
 
@@ -572,7 +568,8 @@ namespace bbtk
        page = ShowGraphInstances(nameblackbox,detail,level,system_display);
     }
     */
-    return page;
+    //return page;
+    return ""; // to avoid warnings
   }
 
   /// Generate a png file with the actual pipeline (Graphviz-dot needed)
@@ -585,7 +582,7 @@ namespace bbtk
     {
        blackbox=Current()->GetPrototype();
     }
-    else 
+    else
     {
        blackbox = Current()->GetPrototype()->bbFindBlackBox(nameblackbox);
     }
@@ -594,21 +591,20 @@ namespace bbtk
 
     if (blackbox)
       {      
-       // Don't pollute the file store with  "temp_dir" directories ...    
+       // Don't pollute the file store with  "temp_dir" directories ...
        std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
        char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
-       
+
        std::string directory = default_doc_dir; 
        if (c != '/' && c !='\\') directory = directory + "/";
 
-       directory = directory +  "temp_dir"; 
-       
+       directory = directory +  "temp_dir";
        //std::string directory("temp_dir");
        std::string filename(directory + "/" + "bbtk_graph_pipeline");
        std::string filename_html(filename+".html");
        std::string command0("mkdir \""+directory + "\"");
 
-#if defined(_WIN32)  
+#if defined(_WIN32)
        std::string command2("start ");
 #else 
        std::string command2("gnome-open ");
@@ -631,7 +627,7 @@ namespace bbtk
            } 
 
            blackbox->bbInsertHTMLGraph( s, detail, level, true, directory, false );
-           s << "</body></html>\n";  
+           s << "</body></html>\n";
          }
        s.close();
        
@@ -642,7 +638,6 @@ namespace bbtk
       {
        bbtkMessageInc("Help",1,"No black box: \""
                       <<nameblackbox<<"\" " <<std::endl);
-       
       }
     return page;
   }
index edb9eb26c94950917858dd8dd4b9e6c877feefda..97eeb56f15bfd7aa1320b6f0b389e7a9e866f968 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkTranscriptor.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/02/14 11:38:59 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/02/14 20:23:51 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -59,7 +59,10 @@ namespace bbtk
     //void SetNoExecMode(bool b) { mNoExecMode = b; }
     void SetNoExecMode(bool b)
     {
-       m_Fp << "e->SetNoExecMode(true);" << std::endl;
+       if (b)
+          m_Fp << "  e->SetNoExecMode(true);" << std::endl;
+       else
+          m_Fp << "  e->SetNoExecMode(false);" << std::endl;       
     }
 
     bool GetNoExecMode() const { return mNoExecMode; }