/*=========================================================================
-
+
Program: bbtk
Module: $RCSfile: bbtkExecuter.cxx,v $ $
Language: C++
- Date: $Date: 2008/02/06 09:27:52 $
- Version: $Revision: 1.8 $
-
+ 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
#include "bbtkConfigurationFile.h"
namespace bbtk
-{
+{
/**
- *
+ *
*/
Executer::Executer()
: mPackage(0),
bbtkDebugMessageInc("Kernel",9,"Executer::Executer()" <<std::endl);
Reset();
bbtkDebugDecTab("Kernel",9);
- }
+ }
/**
- *
+ *
*/
Executer::~Executer()
{
+std::cout << "====================================================== delete Executer\n";
bbtkDebugMessageInc("Kernel",9,"Executer::~Executer()" <<std::endl);
if (mRoot)
{
mPackage->UnRegisterBlackBox("workspace");
- delete mRoot;
+ delete mRoot;
}
- if (mPackage)
+ if (mPackage)
{
GetGlobalFactory()->UnLoadPackage("user");
}
bbtkDebugDecTab("Kernel",9);
}
-
+
/**
- *
+ *
*/
void Executer::Reset()
{
// 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");
}
mOpenPackage.push_back(mPackage);
bbtkDebugDecTab("Kernel",9);
}
-
+
/// changes the workspace name
void Executer::SetWorkspaceName( const std::string& n )
{
Package* p;
try
{
- p = GetGlobalFactory()->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);
}
}
void Executer::Define (const std::string &name,
- const std::string &pack,
- const std::string &scriptfilename)
+ const std::string &pack,
+ const std::string &scriptfilename)
{
bbtkDebugMessageInc("Kernel",9,"Executer::Define(\""<<name<<
- ","<<pack<<"\")"
+ ","<<pack<<"\")"
<<std::endl);
ComplexBlackBoxDescriptor* b = new ComplexBlackBoxDescriptor(name);
{
mOpenDefinition.back().box->SetScriptFileName(name);
}
-
void Executer::EndDefine ()
{
{
try
{
- p = GetGlobalFactory()->GetPackage(pname);
+ p = GetGlobalFactory()->GetPackage(pname);
}
catch (Exception e)
{
}
else
{
- p = mOpenPackage.back();
+ p = mOpenPackage.back();
}
p->RegisterBlackBox(Current());
{
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)
{
}
/**
- *
+ *
*/
void Executer::Update (const std::string &nodeName) // would 'Execute' be more meaningfull ?
{
Current()->AddToExecutionList(nodeName) ;
}
}
-
+
/**
- *
+ *
*/
void Executer::DefineInput ( const std::string &name,
const std::string &box,
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)
mess += ")";
std::string title(name);
title += " ?";
-
std::string ans = wx2std ( wxGetTextFromUser( std2wx (mess), std2wx(title)));
Set(box,input,ans);
}
Current()->DefineInput(name,box,input,help);
}
-
+
/**
*
*/
if ( b->bbGetInputType(input) != typeid(std::string) )
{
- BlackBox* a = /*mFactory->*/
+ BlackBox* a =
NewAdaptor(typeid(std::string),
b->bbGetInputType(input),
"tmp");
}
/**
- *
- */
+ *
+ */
std::string Executer::Get(const std::string &box,
const std::string &output)
{
// Looks for the adaptor
if (b->bbGetOutputType(output) != typeid(std::string))
{
- BlackBox* a = /*mFactory->*/
+ BlackBox* a =
NewAdaptor(
b->bbGetOutputType(output),
typeid(std::string),
a->bbDelete();
return r;
}
- else
+ else
{
b->bbExecute();
return b->bbGetOutput(output).unsafe_get<std::string>();
/// prints the list of the boxes of the current descriptor
void Executer::PrintBoxes()
- {
+ {
bbtkMessageInc("Help",1,"The black box descriptor \""
<<Current()->GetTypeName()<<"\" contains : "<<std::endl);
Current()->PrintBlackBoxes();
// 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" ;
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);
/*
try
{
- ShowGraphTypes(nameblackbox);
+ ShowGraphTypes(nameblackbox);
}
catch (bbtk::Exception a)
{
- std::cout <<"EXC"<<std::endl;
- page = ShowGraphInstances(nameblackbox,detail,level,system_display);
+ std::cout <<"EXC"<<std::endl;
+ page = ShowGraphInstances(nameblackbox,detail,level,system_display);
}
*/
return page;
/// Generate a png file with the actual pipeline (Graphviz-dot needed)
std::string Executer::ShowGraphInstances(const std::string &nameblackbox, int detail, int level,
- bool system_display)
+ bool system_display)
{
BlackBox* blackbox=NULL;
if (nameblackbox==".")
{
- blackbox=Current()->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 ");
}
blackbox->bbInsertHTMLGraph( s, detail, level, true, directory, false );
- s << "</body></html>\n";
+ s << "</body></html>\n";
}
s.close();
{
bbtkMessageInc("Help",1,"No black box: \""
<<nameblackbox<<"\" " <<std::endl);
-
}
return page;
}