X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkExecuter.cxx;h=7d24b70fa357ac6f29a5847e0ef11ebef1bd38c9;hb=6acada1443d66ee0de5825c90b92449a64320870;hp=fe1e36d98538b4a0a85777f6e18e2c29be6eabc9;hpb=998354bb81a4f450cae3a2263838d7d3b6024bac;p=bbtk.git diff --git a/kernel/src/bbtkExecuter.cxx b/kernel/src/bbtkExecuter.cxx index fe1e36d..7d24b70 100644 --- a/kernel/src/bbtkExecuter.cxx +++ b/kernel/src/bbtkExecuter.cxx @@ -1,19 +1,19 @@ /*========================================================================= - + Program: bbtk Module: $RCSfile: bbtkExecuter.cxx,v $ $ Language: C++ - Date: $Date: 2008/02/05 12:16:55 $ - Version: $Revision: 1.6 $ - + Date: $Date: 2008/02/14 20:57:27 $ + Version: $Revision: 1.12 $ + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. - + This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. - + =========================================================================*/ /** * \file @@ -35,9 +35,9 @@ #include "bbtkConfigurationFile.h" namespace bbtk -{ +{ /** - * + * */ Executer::Executer() : mPackage(0), @@ -47,36 +47,37 @@ 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) + if (mPackage) { GetGlobalFactory()->UnLoadPackage("user"); } @@ -109,9 +110,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 ) { @@ -120,21 +121,21 @@ namespace bbtk void Executer::BeginPackage (const std::string &name) { - bbtkDebugMessageInc("Core",9,"Executer::BeginPackage(\""<GetPackage(name); + p = GetGlobalFactory()->GetPackage(name); } catch (Exception e) { - p = new Package(name, - "", - "", - "", - BBTK_STRINGIFY_SYMBOL(BBTK_VERSION)); - InsertPackage(p); + p = new Package(name, + "", + "", + "", + BBTK_STRINGIFY_SYMBOL(BBTK_VERSION)); + InsertPackage(p); } mOpenPackage.push_back(p); } @@ -145,23 +146,30 @@ namespace bbtk } void Executer::Define (const std::string &name, - const std::string &pack, - const std::string &scriptfilename) + const std::string &pack, + const std::string &scriptfilename) { - bbtkDebugMessageInc("Core",9,"Executer::Define(\""<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()<<"\")" <GetPackage(pname); + p = GetGlobalFactory()->GetPackage(pname); } catch (Exception e) { @@ -185,7 +193,7 @@ namespace bbtk } else { - p = mOpenPackage.back(); + p = mOpenPackage.back(); } p->RegisterBlackBox(Current()); @@ -198,20 +206,19 @@ 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, + void Executer::Connect (const std::string &nodeFrom, + const std::string &outputLabel, const std::string &nodeTo, const std::string &inputLabel) { @@ -219,7 +226,7 @@ namespace bbtk } /** - * + * */ void Executer::Update (const std::string &nodeName) // would 'Execute' be more meaningfull ? { @@ -236,9 +243,9 @@ namespace bbtk Current()->AddToExecutionList(nodeName) ; } } - + /** - * + * */ void Executer::DefineInput ( const std::string &name, const std::string &box, @@ -270,7 +277,7 @@ namespace bbtk std::cin >> ans; Set(box,input,ans); } - #ifdef _USE_WXWIDGETS_ +#ifdef _USE_WXWIDGETS_ // If the dialog mode is set to GraphicalDialog // A dialog box is pop up else if (mDialogMode == GraphicalDialog) @@ -282,7 +289,6 @@ namespace bbtk mess += ")"; std::string title(name); title += " ?"; - std::string ans = wx2std ( wxGetTextFromUser( std2wx (mess), std2wx(title))); Set(box,input,ans); } @@ -292,7 +298,7 @@ namespace bbtk Current()->DefineInput(name,box,input,help); } - + /** * */ @@ -316,7 +322,7 @@ namespace bbtk if ( b->bbGetInputType(input) != typeid(std::string) ) { - BlackBox* a = /*mFactory->*/ + BlackBox* a = NewAdaptor(typeid(std::string), b->bbGetInputType(input), "tmp"); @@ -340,8 +346,8 @@ namespace bbtk } /** - * - */ + * + */ std::string Executer::Get(const std::string &box, const std::string &output) { @@ -349,7 +355,7 @@ namespace bbtk // Looks for the adaptor if (b->bbGetOutputType(output) != typeid(std::string)) { - BlackBox* a = /*mFactory->*/ + BlackBox* a = NewAdaptor( b->bbGetOutputType(output), typeid(std::string), @@ -373,7 +379,7 @@ namespace bbtk a->bbDelete(); return r; } - else + else { b->bbExecute(); return b->bbGetOutput(output).unsafe_get(); @@ -403,7 +409,7 @@ namespace bbtk /// prints the list of the boxes of the current descriptor void Executer::PrintBoxes() - { + { bbtkMessageInc("Help",1,"The black box descriptor \"" <GetTypeName()<<"\" contains : "<PrintBlackBoxes(); @@ -429,14 +435,14 @@ 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" ; @@ -448,15 +454,14 @@ namespace bbtk relative_link = false; } - Package* p; try { - p = GetGlobalFactory()->GetPackage(nameblackbox); + p = GetGlobalFactory()->GetPackage(nameblackbox); } catch (Exception e) { - p = mPackage; + p = mPackage; } // Generating documentation-help of workspace p->SetDocURL(filename_rootHtml); @@ -468,12 +473,12 @@ namespace bbtk /* try { - ShowGraphTypes(nameblackbox); + ShowGraphTypes(nameblackbox); } catch (bbtk::Exception a) { - std::cout <<"EXC"<GetPrototype(); + blackbox=Current()->GetPrototype(); } - else + else { - blackbox = Current()->GetPrototype()->bbFindBlackBox(nameblackbox); + 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 "); @@ -535,7 +539,7 @@ namespace bbtk } blackbox->bbInsertHTMLGraph( s, detail, level, true, directory, false ); - s << "\n"; + s << "\n"; } s.close(); @@ -546,7 +550,6 @@ namespace bbtk { bbtkMessageInc("Help",1,"No black box: \"" <