X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkExecuter.cxx;h=7564baf85337198a81111d65f2c6478aef454ea2;hb=76f2826fd6b67d3a15fe72c1b50d5ee1af1960a1;hp=8730b02eb2387ef7ea7bba95ce8f107e1ebea92f;hpb=2159bb535360a4085428c6121099327dd75a7b6e;p=bbtk.git diff --git a/kernel/src/bbtkExecuter.cxx b/kernel/src/bbtkExecuter.cxx index 8730b02..7564baf 100644 --- a/kernel/src/bbtkExecuter.cxx +++ b/kernel/src/bbtkExecuter.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkExecuter.cxx,v $ $ Language: C++ - Date: $Date: 2008/01/28 15:34:37 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008/02/14 11:38:58 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,11 +20,10 @@ * \brief class Executer: level 0 of script execution (code) */ -#include "bbtkExecuter.h" +#include "bbtkExecuter.h" #include "bbtkMessageManager.h" #include "bbtkFactory.h" #include "bbtkUtilities.h" - #include #ifdef _USE_WXWIDGETS_ @@ -38,9 +37,9 @@ namespace bbtk { /** - * + * */ - Executer::Executer() + Executer::Executer() : mPackage(0), mRoot(0), mNoExecMode(false), @@ -48,36 +47,36 @@ namespace bbtk { //VirtualExec(); - bbtkDebugMessageInc("Core",9,"Executer::Executer()" <UnRegisterBlackBox("workspace"); - delete mRoot; + delete mRoot; } - if (mPackage) + if (mPackage) { GetGlobalFactory()->UnLoadPackage("user"); } - bbtkDebugDecTab("Core",9); + bbtkDebugDecTab("Kernel",9); } /** - * + * */ void Executer::Reset() { - bbtkDebugMessageInc("Core",9,"Executer::Reset()" <UnRegisterBlackBox(mRoot->GetTypeName()); - delete mRoot; + delete mRoot; } if (mPackage) { @@ -110,9 +109,9 @@ namespace bbtk // Insert the user package in the factory InsertPackage(mPackage); mOpenPackage.push_back(mPackage); - bbtkDebugDecTab("Core",9); + bbtkDebugDecTab("Kernel",9); } - + /// changes the workspace name void Executer::SetWorkspaceName( const std::string& n ) { @@ -121,8 +120,8 @@ namespace bbtk void Executer::BeginPackage (const std::string &name) { - bbtkDebugMessageInc("Core",9,"Executer::BeginPackage(\""<SetScriptFileName(scriptfilename); mOpenDefinition.push_back( CBBDefinition( b, pack ) ); - bbtkDebugDecTab("Core",9); + bbtkDebugDecTab("Kernel",9); + } + + /// Sets the file name to use for the current definition + /// (Used to set it after the Define command) + void Executer::SetCurrentFileName (const std::string &name ) + { + mOpenDefinition.back().box->SetScriptFileName(name); } void Executer::EndDefine () { - bbtkDebugMessageInc("Core",9,"Executer::EndDefine(\"" + bbtkDebugMessageInc("Kernel",9,"Executer::EndDefine(\"" <GetTypeName()<<"\")" <0) + { + try { - try - { - p = GetGlobalFactory()->GetPackage(pname); + p = GetGlobalFactory()->GetPackage(pname); } - catch (Exception e) + catch (Exception e) { - p = new Package(pname, + p = new Package(pname, "", "", "", BBTK_STRINGIFY_SYMBOL(BBTK_VERSION)); - InsertPackage(p); - } - } - else - { - p = mOpenPackage.back(); + InsertPackage(p); } + } + else + { + p = mOpenPackage.back(); + } p->RegisterBlackBox(Current()); - + mOpenDefinition.pop_back(); } @@ -200,28 +205,27 @@ namespace bbtk { Current()->Add(nodeType,nodeName); } - /* void Executer::Remove (const std::string &nodeName) - { + { // Current()->RemoveBlackBox(nodeName); } - */ + */ /** - * + * */ void Executer::Connect (const std::string &nodeFrom, - const std::string &outputLabel, + const std::string &outputLabel, const std::string &nodeTo, const std::string &inputLabel) { - Current()->Connect(nodeFrom, outputLabel, nodeTo, inputLabel); + Current()->Connect(nodeFrom, outputLabel, nodeTo, inputLabel); } - + /** - * + * */ void Executer::Update (const std::string &nodeName) // would 'Execute' be more meaningfull ? { @@ -238,9 +242,9 @@ namespace bbtk Current()->AddToExecutionList(nodeName) ; } } - + /** - * + * */ void Executer::DefineInput ( const std::string &name, const std::string &box, @@ -284,17 +288,16 @@ namespace bbtk mess += ")"; std::string title(name); title += " ?"; - std::string ans = wx2std ( wxGetTextFromUser( std2wx (mess), std2wx(title))); Set(box,input,ans); } #endif } - + Current()->DefineInput(name,box,input,help); - + } - + /** * */ @@ -305,7 +308,7 @@ namespace bbtk { Current()->DefineOutput(name,box,output,help); } - + /** * */ @@ -341,10 +344,9 @@ namespace bbtk } } - /** - * - */ + * + */ std::string Executer::Get(const std::string &box, const std::string &output) { @@ -376,7 +378,7 @@ namespace bbtk a->bbDelete(); return r; } - else + else { b->bbExecute(); return b->bbGetOutput(output).unsafe_get(); @@ -393,7 +395,10 @@ namespace bbtk Current()->AddToAuthor(authorName,Current()==mRoot); } - + void Executer::Category(const std::string &category) + { + Current()->AddToCategory(category,Current()==mRoot); + } void Executer::Description(const std::string &d) { @@ -410,7 +415,6 @@ namespace bbtk bbtkDecTab("Help",1); } - std::string Executer::ShowGraph(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr, @@ -419,7 +423,6 @@ namespace bbtk const std::string &custom_title, bool system_display ) { - int detail = atoi(detailStr.c_str()); int level = atoi(levelStr.c_str()); @@ -431,52 +434,52 @@ namespace bbtk // No output provided : automatic generation if (output_html.length() == 0) { - // Don't pollute the file store with "doc_tmp" directories ... - std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_doc_tmp(); + // 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 + "doc_tmp"; + directory = directory + "temp_dir"; filename_rootHtml = directory + "/" + "User.html"; simplefilename_rootHtml = "User.html" ; // Creating directory std::string command0("mkdir \"" +directory + "\""); - system( command0.c_str() ); + system( command0.c_str() ); relative_link = false; } - + Package* p; - try - { - p = GetGlobalFactory()->GetPackage(nameblackbox); - } + try + { + p = GetGlobalFactory()->GetPackage(nameblackbox); + } catch (Exception e) - { - p = mPackage; - } + { + p = mPackage; + } // Generating documentation-help of workspace p->SetDocURL(filename_rootHtml); p->SetDocRelativeURL(simplefilename_rootHtml); p->CreateHtmlPage(filename_rootHtml,"bbi","user package",custom_header,custom_title,detail,level,relative_link); - + std::string page = filename_rootHtml; /* try - { - ShowGraphTypes(nameblackbox); - } - catch (bbtk::Exception a) - { - std::cout <<"EXC"<GetPrototype(); - } - else - { - blackbox = Current()->GetPrototype()->bbFindBlackBox(nameblackbox); - } + { + blackbox=Current()->GetPrototype(); + } + else + { + blackbox = Current()->GetPrototype()->bbFindBlackBox(nameblackbox); + } std::string page; if (blackbox) { - // Don't pollute the file store with "doc_tmp" directories ... - std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_doc_tmp(); + // 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 + "doc_tmp"; - - //std::string directory("doc_tmp"); + 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 "); @@ -537,7 +539,7 @@ namespace bbtk } blackbox->bbInsertHTMLGraph( s, detail, level, true, directory, false ); - s << "\n"; + s << "\n"; } s.close(); @@ -548,11 +550,9 @@ namespace bbtk { bbtkMessageInc("Help",1,"No black box: \"" <