1 /*=========================================================================
4 Module: $RCSfile: bbtkTranscriptor.h,v $ $
6 Date: $Date: 2008/02/05 12:16:55 $
7 Version: $Revision: 1.3 $
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 /// End the definition of a ComplexBlackBox
91 /// Creates a new black box in current complex box
92 void Create ( const std::string& boxType, const std::string& boxName);
94 /// Destroys a black box
95 void Destroy (const std::string &boxName);
97 /// Connects the output boxOutput to the input boxInput
98 void Connect (const std::string &boxfrom,
99 const std::string &output,
100 const std::string &boxto,
101 const std::string &input);
104 /// would 'Execute' be more meaningfull ?
105 void Update (const std::string &box);
107 /// Defines an input of the current complex box
108 void DefineInput (const std::string &name,
109 const std::string &box,
110 const std::string &input,
111 const std::string &help);
113 /// Defines an output of the current complex box
114 void DefineOutput (const std::string &name,
115 const std::string &box,
116 const std::string &output,
117 const std::string &help);
119 /// sets the input of the box with the value
120 void Set (const std::string &box,
121 const std::string &input,
122 const std::string &value);
124 /// gets the output of the box
125 std::string Get (const std::string &box,
126 const std::string &output);
128 /// changes the workspace name
129 void SetWorkspaceName( const std::string& n );
131 ///Adds the authorName to the Box author list
132 void Author(const std::string &authorName);
134 ///Adds the Categories to the Box category list
135 void Category(const std::string &category);
137 /// The description string which explains what does the ComplexBox
138 void Description(const std::string & d);
140 /// prints the list off the boxes of the current box
143 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
144 std::string ShowGraph(const std::string &nameblackbox,
145 const std::string &detailStr,
146 const std::string &levelStr,
147 const std::string &output_file,
148 const std::string &custom_header,
149 const std::string &custom_title,
150 bool system_display = true);
152 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
153 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
155 /// Description of the actual pipeline
156 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
160 // static const std::string& GetObjectDescription()
161 // { static std::string s("Executer"); return s; }
167 /// Gets the current working black box
168 ComplexBlackBoxDescriptor* Current()
169 { return mOpenDefinition.back().box; }
171 /// Returns true when we are inside a define/endefine block
172 // bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
174 //==================================================================
178 // Factory* mFactory;
183 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
184 /// Its name in bbi is 'workspace'
185 ComplexBlackBoxDescriptor* mRoot;
187 /// Struct that stores info on user defined complex black boxes
190 ComplexBlackBoxDescriptor* box;
192 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
193 : box(d), package(p) {}
196 /// The stack of current working ComplexBlackBox
197 /// (is a stack for nested definitions)
198 /// only contains the root when outside a define/endefine block
199 std::deque<CBBDefinition> mOpenDefinition;
201 /// The stack of current working package
202 /// (is a stack for nested definitions)
203 std::deque<Package*> mOpenPackage;
205 /// flag which is true when we are inside a Define/EndDefine block
208 /// The input values of the Root ComplexBlackBox
209 std::map<std::string,std::string> mInputs;
211 /// no exec mode flag
215 DialogModeType mDialogMode;
217 /// File Pointer, to hold generated C++ code.
218 // std::ofstream *m_Fp;