1 /*=========================================================================
4 Module: $RCSfile: bbtkTranscriptor.cxx,v $ $
6 Date: $Date: 2008/03/26 08:27:19 $
7 Version: $Revision: 1.8 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
20 * \brief class Transcriptor: level 0 of script execution (code)
23 #include "bbtkTranscriptor.h"
24 #include "bbtkMessageManager.h"
25 #include "bbtkFactory.h"
26 #include "bbtkUtilities.h"
29 //#ifdef _USE_WXWIDGETS_
30 //#include <wx/textdlg.h>
33 //#include "bbtkWxBlackBox.h"
35 #include "bbtkConfigurationFile.h"
42 Transcriptor::Transcriptor(std::string filename)
49 bbtkDebugMessageInc("Kernel",9,"Transcriptor::Transcriptor()" <<std::endl);
51 bbtkDebugDecTab("Kernel",9);
53 //std::ofstream *m_Fp = new std::ofstream();
54 m_Fp.open (filename.c_str(), std::ios::out );
56 m_Fp << "#include \"bbtkExecuter.h\"" << std::endl;
57 m_Fp << "main(int argc, char *argv[]) {" << std::endl;
58 m_Fp << " bbtk::Executer *e = new bbtk::Executer();" << std::endl;
64 Transcriptor::~Transcriptor()
67 std::cout << "====================================================== delete Transcriptor\n";
68 bbtkDebugMessageInc("Kernel",9,"Transcriptor::~Transcriptor()" <<std::endl);
71 mPackage->UnRegisterBlackBox("workspace");
76 //GetGlobalFactory()->UnLoadPackage("user");
81 bbtkDebugDecTab("Kernel",9);
82 m_Fp << " }" << std::endl;
89 // ================= Begin of Battlefield =============================
90 void Transcriptor::Reset()
92 m_Fp << " e->Reset( );" << std::endl;
95 void Transcriptor::SetWorkspaceName( const std::string& name )
98 m_Fp << " e->SetWorkspaceName( \"" << name << "\" );" << std::endl;
101 void Transcriptor::BeginPackage (const std::string &name)
103 m_Fp << " e->BeginPackage( \"" << name << "\" );" << std::endl;
106 void Transcriptor::EndPackage()
108 m_Fp << " e->EndPackage( );" << std::endl;
111 void Transcriptor::Define (const std::string &name,
112 const std::string &pack,
113 const std::string &scriptfilename)
115 m_Fp << " e->Define(\"" << name << "\", \"" << pack << "\", \""
116 << scriptfilename << "\" );" << std::endl;
119 void Transcriptor::SetCurrentFileName (const std::string &name )
121 m_Fp << " e->SetCurrentFileName( \"" << name << "\" );" << std::endl;
124 void Transcriptor::EndDefine ()
126 m_Fp << " e->EndDefine( );" << std::endl;
130 void Transcriptor::Create ( const std::string& nodeType,
131 const std::string& nodeName)
133 m_Fp << " e->Add(\"" << nodeType << "\", \""
134 << nodeName << "\");" << std::endl;
138 void Transcriptor::Destroy (const std::string &nodeName)
140 m_Fp << " e->Destroy(" << nodeName << ");" << std::endl;
143 void Transcriptor::Connect (const std::string &nodeFrom,
144 const std::string &outputLabel,
145 const std::string &nodeTo,
146 const std::string &inputLabel)
148 m_Fp << " e->Connect(\""<< nodeFrom << "\", \""
149 << outputLabel << "\", \""
150 << nodeTo << "\", \"" << inputLabel<< "\");" << std::endl;
154 void Transcriptor::Execute (const std::string &nodeName)
156 m_Fp << " e->Execute(\"" << nodeName << "\");" << std::endl;
159 void Transcriptor::DefineInput ( const std::string &name,
160 const std::string &box,
161 const std::string &input,
162 const std::string& help)
165 m_Fp << " e->DefineInput(\""<< name << "\", " << box << ", "
166 << input << ", \"" << help << "\");" << std::endl;
170 void Transcriptor::DefineOutput ( const std::string &name,
171 const std::string &box,
172 const std::string &output,
173 const std::string& help)
175 m_Fp << " e->DefineOutput(\""<< name << "\", \"" << box << "\", \""
176 << output << "\", \"" << help << "\");" << std::endl;
180 void Transcriptor::Set (const std::string &box,
181 const std::string &input,
182 const std::string &value)
184 m_Fp << " e->Set(\""<< box << "\", \"" << input
185 << "\", \"" << value << "\");"
189 std::string Transcriptor::Get(const std::string &box,
190 const std::string &output)
193 m_Fp << " e->Get(\""<< box << "\", \"" << output << "\");"
199 void Transcriptor::Author(const std::string &authorName)
202 m_Fp << " e->AddToAuthor(\"" << authorName << "\")" << std::endl;
205 void Transcriptor::Category(const std::string &category)
207 m_Fp << " e->AddToCategory(\"" << category << "\")" << std::endl;
210 void Transcriptor::Description(const std::string &d)
212 m_Fp << " e->AddToDescription(\"" << d << "\")" << std::endl;
215 /// prints the list of the boxes of the current descriptor
216 void Transcriptor::PrintBoxes()
218 m_Fp << " e->PrintBoxes( )" << std::endl;
221 // =========================End of Battlefield ========================================================================
223 std::string Transcriptor::ShowGraph(const std::string &nameblackbox,
224 const std::string &detailStr,
225 const std::string &levelStr,
226 const std::string &output_html,
227 const std::string &custom_header,
228 const std::string &custom_title,
229 bool system_display )
232 m_Fp << " e->ShowGraph(\"" << nameblackbox << "\", \""
233 << detailStr << "\", \""
234 << levelStr << "\", \""
235 << output_html << "\", \""
236 << custom_header << "\", \""
237 << custom_title << "\");"
243 std::string Transcriptor::ShowGraphInstances(const std::string &nameblackbox, int detail, int level,
250 void Transcriptor::ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr)
255 void Transcriptor::Print(const std::string & message)
257 m_Fp << " e->Print(\"" <<message<<"\")"<<std::endl;
262 void Transcriptor::SetMessageLevel(const std::string &kind,
265 m_Fp << " e->SetMessageLevel(\"" <<kind<<"\","<<level<<")"<<std::endl;
269 void Transcriptor::HelpMessages()
271 m_Fp << " e->HelpMessages()"<<std::endl;
274 void Transcriptor::LoadPackage(const std::string &name )
276 m_Fp << " e->LoadPackage(\"" <<name<<"\")"<<std::endl;
280 void Transcriptor::UnLoadPackage(const std::string &name )
282 m_Fp << " e->UnLoadPackage(\"" <<name<<"\")"<<std::endl;