1 /*=========================================================================
4 Module: $RCSfile: bbtkTranscriptor.h,v $ $
6 Date: $Date: 2008/02/14 20:23:51 $
7 Version: $Revision: 1.5 $
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; }
79 /// Starts a package block
80 void BeginPackage (const std::string &name );
82 /// Ends a package block
85 /// Starts the definition of a new ComplexBlackBox in package pack
86 /// scriptfilename is the file from which the def is read
87 void Define (const std::string &name,
88 const std::string& pack,
89 const std::string &scriptfilename);
91 /// Sets the file name to use for the current definition
92 /// (Used to set it after the Define command)
93 void SetCurrentFileName (const std::string &name );
95 /// End the definition of a ComplexBlackBox
98 /// Creates a new black box in current complex box
99 void Create ( const std::string& boxType, const std::string& boxName);
101 /// Destroys a black box
102 void Destroy (const std::string &boxName);
104 /// Connects the output boxOutput to the input boxInput
105 void Connect (const std::string &boxfrom,
106 const std::string &output,
107 const std::string &boxto,
108 const std::string &input);
111 /// would 'Execute' be more meaningfull ?
112 void Update (const std::string &box);
114 /// Defines an input of the current complex box
115 void DefineInput (const std::string &name,
116 const std::string &box,
117 const std::string &input,
118 const std::string &help);
120 /// Defines an output of the current complex box
121 void DefineOutput (const std::string &name,
122 const std::string &box,
123 const std::string &output,
124 const std::string &help);
126 /// sets the input of the box with the value
127 void Set (const std::string &box,
128 const std::string &input,
129 const std::string &value);
131 /// gets the output of the box
132 std::string Get (const std::string &box,
133 const std::string &output);
135 /// changes the workspace name
136 void SetWorkspaceName( const std::string& n );
138 ///Adds the authorName to the Box author list
139 void Author(const std::string &authorName);
141 ///Adds the Categories to the Box category list
142 void Category(const std::string &category);
144 /// The description string which explains what does the ComplexBox
145 void Description(const std::string & d);
147 /// prints the list off the boxes of the current box
150 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
151 std::string ShowGraph(const std::string &nameblackbox,
152 const std::string &detailStr,
153 const std::string &levelStr,
154 const std::string &output_file,
155 const std::string &custom_header,
156 const std::string &custom_title,
157 bool system_display = true);
159 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
160 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
162 /// Description of the actual pipeline
163 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
167 // static const std::string& GetObjectDescription()
168 // { static std::string s("Executer"); return s; }
174 /// Gets the current working black box
175 ComplexBlackBoxDescriptor* Current()
176 { return mOpenDefinition.back().box; }
178 /// Returns true when we are inside a define/endefine block
179 // bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
181 //==================================================================
185 // Factory* mFactory;
190 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
191 /// Its name in bbi is 'workspace'
192 ComplexBlackBoxDescriptor* mRoot;
194 /// Struct that stores info on user defined complex black boxes
197 ComplexBlackBoxDescriptor* box;
199 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
200 : box(d), package(p) {}
203 /// The stack of current working ComplexBlackBox
204 /// (is a stack for nested definitions)
205 /// only contains the root when outside a define/endefine block
206 std::deque<CBBDefinition> mOpenDefinition;
208 /// The stack of current working package
209 /// (is a stack for nested definitions)
210 std::deque<Package*> mOpenPackage;
212 /// flag which is true when we are inside a Define/EndDefine block
215 /// The input values of the Root ComplexBlackBox
216 std::map<std::string,std::string> mInputs;
218 /// no exec mode flag
222 DialogModeType mDialogMode;
224 /// File Pointer, to hold generated C++ code.
225 // std::ofstream *m_Fp;