2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkExecuter.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.20 $
34 =========================================================================*/
40 * \brief class Executer: level 0 of script execution (header)
43 * \class bbtk::Executer
44 * \brief class Executer: level 0 of script execution
47 #ifndef __bbtkExecuter_h__
48 #define __bbtkExecuter_h__
50 #include "bbtkFactory.h"
52 #include "bbtkSystem.h"
53 #include "bbtkComplexBlackBox.h"
63 class /*BBTK_EXPORT*/ Executer : public VirtualExec
65 BBTK_OBJECT_INTERFACE(Executer);
66 typedef VirtualExec Superclass;
71 /// Gets the factory used by the executer
72 Factory::Pointer GetFactory() { return mFactory; }
73 /// Gets the factory used by the executer (const)
74 // const Factory::Pointer GetFactory() const { return mFactory; }
77 /// Sets the inputs of the workspace :
78 void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
80 /// Puts the executer in "no exec" mode,
81 /// which creates but does not execute pipelines
82 void SetNoExecMode(bool b) { mNoExecMode = b; }
84 bool GetNoExecMode() const { return mNoExecMode; }
86 /// Sets the mode of dialog of the executer for Root inputs
87 void SetDialogMode(DialogModeType t) { mDialogMode = t; }
89 void SetNoErrorMode(bool b) { mNoErrorMode = b; }
91 bool GetNoErrorMode() const { return mNoErrorMode; }
94 //=================================================================
96 void LoadPackage(const std::string &name );
99 void UnLoadPackage(const std::string &name );
101 /// Starts a package block
102 void BeginPackage (const std::string &name );
104 /// Ends a package block
107 /// Starts the definition of a new ComplexBlackBox in package pack
108 /// scriptfilename is the file from which the def is read
109 void Define (const std::string &name,
110 const std::string& pack,
111 const std::string &scriptfilename);
113 /// Sets the file name to use for the current definition
114 /// (Used to set it after the Define command)
115 void SetCurrentFileName (const std::string &name );
118 void SetTypeOfScript_Application();
122 /// End the definition of a ComplexBlackBox
125 /// Sets the kind of the currently defined ComplexBlackBox
126 void Kind(const std::string& kind);
128 /// Creates a new black box in current complex box
129 void Create ( const std::string& boxType, const std::string& boxName);
131 /// Destroys a black box
132 void Destroy (const std::string &boxName);
134 /// Clears the currently defined ComplexBlackBox
137 /// Connects the output boxOutput to the input boxInput
138 void Connect (const std::string &boxfrom,
139 const std::string &output,
140 const std::string &boxto,
141 const std::string &input);
144 void Execute (const std::string &box);
146 /// Defines an input of the current complex box
147 void DefineInput (const std::string &name,
148 const std::string &box,
149 const std::string &input,
150 const std::string &help);
152 /// Defines an output of the current complex box
153 void DefineOutput (const std::string &name,
154 const std::string &box,
155 const std::string &output,
156 const std::string &help);
158 /// sets the input of the box with the value
159 void Set (const std::string &box,
160 const std::string &input,
161 const std::string &value);
163 /// gets the output of the box
164 std::string Get (const std::string &box,
165 const std::string &output);
167 /// changes the workspace name
168 void SetWorkspaceName( const std::string& n );
170 ///Adds the authorName to the Box author list
171 void Author(const std::string &authorName);
173 ///Adds the Categories to the Box category list
174 void Category(const std::string &category);
176 /// The description string which explains what does the ComplexBox
177 void Description(const std::string & d);
184 /// prints the list off the boxes of the current box
185 void PrintHelpListBoxes();
187 /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
188 std::string ShowGraph(const std::string &nameblackbox,
189 const std::string &detailStr,
190 const std::string &levelStr,
191 const std::string &output_file,
192 const std::string &custom_header,
193 const std::string &custom_title,
194 bool system_display = true);
196 /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
197 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
199 /// Prints help on a black box
200 void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
207 /// Resets the workspace : destroys all boxes / unloads all packages
210 /// Sets the level of message for kind
211 void SetMessageLevel(const std::string &kind,
214 /// Prints help on the messages
218 void Print(const std::string & message);
220 // static const std::string& GetObjectDescription();
221 // { static std::string s("Executer"); return s; }
224 ComplexBlackBoxDescriptor::Pointer GetWorkspace()
225 { return mRootCBB.lock(); }
226 Package::Pointer GetUserPackage()
227 { return mRootPackage.lock(); }
229 /// Gets the current working black box
230 ComplexBlackBoxDescriptor::Pointer GetCurrentDescriptor()
231 { return mOpenDefinition.back().box; }
239 /// Returns true when we are inside a define/endefine block
240 // bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
242 //==================================================================
246 Factory::Pointer mFactory;
250 /// Contains the root ComplexBlabkBox
251 /// In which ComplexBlackBoxes are put by default
252 /// Its name in bbi is 'user'
253 Package::WeakPointer mRootPackage;
255 /// The root ComplexBlackBox
256 /// in which operations are done when outside a define/endefine block
257 /// Its name in bbi is 'workspace'
258 ComplexBlackBoxDescriptor::WeakPointer mRootCBB;
260 /// Struct that stores info on user defined complex black boxes
263 ComplexBlackBoxDescriptor::Pointer box;
265 CBBDefinition(ComplexBlackBoxDescriptor::Pointer d,
266 const std::string& p )
267 : box(d), package(p) {}
270 /// The stack of current working ComplexBlackBox
271 /// (is a stack for nested definitions)
272 /// only contains the root cbb when outside a define/endefine block
273 std::deque<CBBDefinition> mOpenDefinition;
275 /// The stack of current working package
276 /// (is a stack for nested definitions)
277 std::deque<Package::WeakPointer> mOpenPackage;
279 /// The input values of the Root ComplexBlackBox
280 std::map<std::string,std::string> mInputs;
282 /// no exec mode flag
287 DialogModeType mDialogMode;
289 /// no error mode flag