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
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");
}
}
-// ========================= Begin of Battelfield ========================================================================
+// ========================= Begin of Battlefield ========================================================================
/**
- *
+ *
*/
void Transcriptor::Reset()
{
-
m_Fp << " e->Reset( );" << std::endl;
+
/*
bbtkDebugMessageInc("Kernel",9,"Transcriptor::Reset()" <<std::endl);
// 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");
}
}
/// 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);
catch (Exception e)
{
p = new Package(name,
- "",
- "",
- "",
- BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
+ "",
+ "",
+ "",
+ BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
InsertPackage(p);
}
mOpenPackage.push_back(p);
void Transcriptor::EndPackage()
{
- m_Fp << "// ==> EndPackage() called here" << std::endl;
+ m_Fp << " e->EndPackage( );" << std::endl;
// if (mOpenPackage.size()>1) mOpenPackage.pop_back();
}
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);
/// 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(\""
// 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)
{
}
/**
- *
+ *
*/
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)
{
//Current()->AddToExecutionList(nodeName) ;
m_Fp << " e->AddToExecutionList(\"" << nodeName << "\");" << std::endl;
}
+*/
}
/**
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)
mess += ")";
std::string title(name);
title += " ?";
-
std::string ans = wx2std ( wxGetTextFromUser( std2wx (mess), std2wx(title)));
Set(box,input,ans);
}
*/
}
-
+
/**
*
*/
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");
}
/**
- *
- */
+ *
+ */
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),
a->bbDelete();
return r;
}
- else
+ else
{
b->bbExecute();
return b->bbGetOutput(output).unsafe_get<std::string>();
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);
*/
}
-// =========================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());
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)
{
blackbox=Current()->GetPrototype();
}
- else
+ else
{
blackbox = Current()->GetPrototype()->bbFindBlackBox(nameblackbox);
}
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 ");
}
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;
}