1 /*=========================================================================
4 Module: $RCSfile: bbtkTranscriptor.h,v $ $
6 Date: $Date: 2008/02/14 11:38:59 $
7 Version: $Revision: 1.4 $
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)
62 m_Fp << "e->SetNoExecMode(true);" << std::endl;
65 bool GetNoExecMode() const { return mNoExecMode; }
67 bool GetNoExecMode() const
69 // cannot compile, since ethos is 'const' !
70 //m_Fp << "e->GetNoExecMode(true);" << std::endl;
73 /// Sets the mode of dialog of the executer for Root inputs
74 void SetDialogMode(DialogModeType t) { mDialogMode = t; }
76 /// Starts a package block
77 void BeginPackage (const std::string &name );
79 /// Ends a package block
82 /// Starts the definition of a new ComplexBlackBox in package pack
83 /// scriptfilename is the file from which the def is read
84 void Define (const std::string &name,
85 const std::string& pack,
86 const std::string &scriptfilename);
88 /// Sets the file name to use for the current definition
89 /// (Used to set it after the Define command)
90 void SetCurrentFileName (const std::string &name );
92 /// End the definition of a ComplexBlackBox
95 /// Creates a new black box in current complex box
96 void Create ( const std::string& boxType, const std::string& boxName);
98 /// Destroys a black box
99 void Destroy (const std::string &boxName);
101 /// Connects the output boxOutput to the input boxInput
102 void Connect (const std::string &boxfrom,
103 const std::string &output,
104 const std::string &boxto,
105 const std::string &input);
108 /// would 'Execute' be more meaningfull ?
109 void Update (const std::string &box);
111 /// Defines an input of the current complex box
112 void DefineInput (const std::string &name,
113 const std::string &box,
114 const std::string &input,
115 const std::string &help);
117 /// Defines an output of the current complex box
118 void DefineOutput (const std::string &name,
119 const std::string &box,
120 const std::string &output,
121 const std::string &help);
123 /// sets the input of the box with the value
124 void Set (const std::string &box,
125 const std::string &input,
126 const std::string &value);
128 /// gets the output of the box
129 std::string Get (const std::string &box,
130 const std::string &output);
132 /// changes the workspace name
133 void SetWorkspaceName( const std::string& n );
135 ///Adds the authorName to the Box author list
136 void Author(const std::string &authorName);
138 ///Adds the Categories to the Box category list
139 void Category(const std::string &category);
141 /// The description string which explains what does the ComplexBox
142 void Description(const std::string & d);
144 /// prints the list off the boxes of the current box
147 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
148 std::string ShowGraph(const std::string &nameblackbox,
149 const std::string &detailStr,
150 const std::string &levelStr,
151 const std::string &output_file,
152 const std::string &custom_header,
153 const std::string &custom_title,
154 bool system_display = true);
156 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
157 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
159 /// Description of the actual pipeline
160 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
164 // static const std::string& GetObjectDescription()
165 // { static std::string s("Executer"); return s; }
171 /// Gets the current working black box
172 ComplexBlackBoxDescriptor* Current()
173 { return mOpenDefinition.back().box; }
175 /// Returns true when we are inside a define/endefine block
176 // bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
178 //==================================================================
182 // Factory* mFactory;
187 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
188 /// Its name in bbi is 'workspace'
189 ComplexBlackBoxDescriptor* mRoot;
191 /// Struct that stores info on user defined complex black boxes
194 ComplexBlackBoxDescriptor* box;
196 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
197 : box(d), package(p) {}
200 /// The stack of current working ComplexBlackBox
201 /// (is a stack for nested definitions)
202 /// only contains the root when outside a define/endefine block
203 std::deque<CBBDefinition> mOpenDefinition;
205 /// The stack of current working package
206 /// (is a stack for nested definitions)
207 std::deque<Package*> mOpenPackage;
209 /// flag which is true when we are inside a Define/EndDefine block
212 /// The input values of the Root ComplexBlackBox
213 std::map<std::string,std::string> mInputs;
215 /// no exec mode flag
219 DialogModeType mDialogMode;
221 /// File Pointer, to hold generated C++ code.
222 // std::ofstream *m_Fp;