1 /*=========================================================================
4 Module: $RCSfile: bbtkTranscriptor.h,v $ $
6 Date: $Date: 2008/03/26 08:27:19 $
7 Version: $Revision: 1.7 $
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 C++ translation (header)
23 * \class bbtk::Transcriptor
24 * \brief class Transcriptor: level 0 of script C++ translation
27 #ifndef __bbtkTranscriptor_h__
28 #define __bbtkTranscriptor_h__
30 #include "bbtkVirtualExec.h"
32 #include "bbtkSystem.h"
33 #include "bbtkComplexBlackBox.h"
34 #include "bbtkFactory.h"
42 class /*BBTK_EXPORT*/ Transcriptor : public VirtualExec
48 Transcriptor(std::string filename);
53 /// Sets the inputs of the workspace :
54 void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
56 /// Puts the executer in "no exec" mode,
57 /// which creates but does not execute pipelines
59 //void SetNoExecMode(bool b) { mNoExecMode = b; }
60 void SetNoExecMode(bool b)
63 m_Fp << " e->SetNoExecMode(true);" << std::endl;
65 m_Fp << " e->SetNoExecMode(false);" << std::endl;
68 bool GetNoExecMode() const { return mNoExecMode; }
70 bool GetNoExecMode() const
72 // cannot compile, since ethos is 'const' !
73 //m_Fp << "e->GetNoExecMode(true);" << std::endl;
76 /// Sets the mode of dialog of the executer for Root inputs
77 void SetDialogMode(DialogModeType t) { mDialogMode = t; }
80 void LoadPackage(const std::string &name );
83 void UnLoadPackage(const std::string &name );
85 /// Starts a package block
86 void BeginPackage (const std::string &name );
88 /// Ends a package block
91 /// Starts the definition of a new ComplexBlackBox in package pack
92 /// scriptfilename is the file from which the def is read
93 void Define (const std::string &name,
94 const std::string& pack,
95 const std::string &scriptfilename);
97 /// Sets the file name to use for the current definition
98 /// (Used to set it after the Define command)
99 void SetCurrentFileName (const std::string &name );
101 /// End the definition of a ComplexBlackBox
104 /// Creates a new black box in current complex box
105 void Create ( const std::string& boxType, const std::string& boxName);
107 /// Destroys a black box
108 void Destroy (const std::string &boxName);
110 /// Connects the output boxOutput to the input boxInput
111 void Connect (const std::string &boxfrom,
112 const std::string &output,
113 const std::string &boxto,
114 const std::string &input);
117 void Execute(const std::string &box);
119 /// Defines an input of the current complex box
120 void DefineInput (const std::string &name,
121 const std::string &box,
122 const std::string &input,
123 const std::string &help);
125 /// Defines an output of the current complex box
126 void DefineOutput (const std::string &name,
127 const std::string &box,
128 const std::string &output,
129 const std::string &help);
131 /// sets the input of the box with the value
132 void Set (const std::string &box,
133 const std::string &input,
134 const std::string &value);
136 /// gets the output of the box
137 std::string Get (const std::string &box,
138 const std::string &output);
140 /// changes the workspace name
141 void SetWorkspaceName( const std::string& n );
143 ///Adds the authorName to the Box author list
144 void Author(const std::string &authorName);
146 ///Adds the Categories to the Box category list
147 void Category(const std::string &category);
149 /// The description string which explains what does the ComplexBox
150 void Description(const std::string & d);
152 /// prints the list off the boxes of the current box
155 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
156 std::string ShowGraph(const std::string &nameblackbox,
157 const std::string &detailStr,
158 const std::string &levelStr,
159 const std::string &output_file,
160 const std::string &custom_header,
161 const std::string &custom_title,
162 bool system_display = true);
164 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
165 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
167 /// Description of the actual pipeline
168 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
172 /// Sets the level of message for kind
173 void SetMessageLevel(const std::string &kind,
176 /// Prints help on the messages
179 /// Prints the string ... MORE : TO EXPLAIN
180 void Print(const std::string & message);
182 // static const std::string& GetObjectDescription()
183 // { static std::string s("Executer"); return s; }
189 /// Gets the current working black box
190 ComplexBlackBoxDescriptor* Current()
191 { return mOpenDefinition.back().box; }
193 /// Returns true when we are inside a define/endefine block
194 // bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
196 //==================================================================
200 // Factory* mFactory;
205 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
206 /// Its name in bbi is 'workspace'
207 ComplexBlackBoxDescriptor* mRoot;
209 /// Struct that stores info on user defined complex black boxes
212 ComplexBlackBoxDescriptor* box;
214 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
215 : box(d), package(p) {}
218 /// The stack of current working ComplexBlackBox
219 /// (is a stack for nested definitions)
220 /// only contains the root when outside a define/endefine block
221 std::deque<CBBDefinition> mOpenDefinition;
223 /// The stack of current working package
224 /// (is a stack for nested definitions)
225 std::deque<Package*> mOpenPackage;
227 /// flag which is true when we are inside a Define/EndDefine block
230 /// The input values of the Root ComplexBlackBox
231 std::map<std::string,std::string> mInputs;
233 /// no exec mode flag
237 DialogModeType mDialogMode;
239 /// File Pointer, to hold generated C++ code.
240 // std::ofstream *m_Fp;