1 /*=========================================================================
4 Module: $RCSfile: bbtkExecuter.h,v $ $
6 Date: $Date: 2008/04/22 09:40:10 $
7 Version: $Revision: 1.14 $
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 Executer: level 0 of script execution (header)
23 * \class bbtk::Executer
24 * \brief class Executer: level 0 of script execution
27 #ifndef __bbtkExecuter_h__
28 #define __bbtkExecuter_h__
30 #include "bbtkVirtualExec.h"
32 #include "bbtkSystem.h"
33 #include "bbtkComplexBlackBox.h"
34 #include "bbtkFactory.h"
44 class /*BBTK_EXPORT*/ Executer : public VirtualExec
46 BBTK_OBJECT_INTERFACE(Executer);
47 typedef VirtualExec Superclass;
52 /// Gets the factory used by the executer
53 Factory::Pointer GetFactory() { return mFactory; }
54 /// Gets the factory used by the executer (const)
55 // const Factory::Pointer GetFactory() const { return mFactory; }
58 /// Sets the inputs of the workspace :
59 void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
61 /// Puts the executer in "no exec" mode,
62 /// which creates but does not execute pipelines
63 void SetNoExecMode(bool b) { mNoExecMode = b; }
65 bool GetNoExecMode() const { return mNoExecMode; }
67 /// Sets the mode of dialog of the executer for Root inputs
68 void SetDialogMode(DialogModeType t) { mDialogMode = t; }
72 //=================================================================
74 void LoadPackage(const std::string &name );
77 void UnLoadPackage(const std::string &name );
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 /// Sets the kind of the currently defined ComplexBlackBox
99 void Kind(const std::string& kind);
101 /// Creates a new black box in current complex box
102 void Create ( const std::string& boxType, const std::string& boxName);
104 /// Destroys a black box
105 void Destroy (const std::string &boxName);
107 /// Connects the output boxOutput to the input boxInput
108 void Connect (const std::string &boxfrom,
109 const std::string &output,
110 const std::string &boxto,
111 const std::string &input);
114 void Execute (const std::string &box);
116 /// Defines an input of the current complex box
117 void DefineInput (const std::string &name,
118 const std::string &box,
119 const std::string &input,
120 const std::string &help);
122 /// Defines an output of the current complex box
123 void DefineOutput (const std::string &name,
124 const std::string &box,
125 const std::string &output,
126 const std::string &help);
128 /// sets the input of the box with the value
129 void Set (const std::string &box,
130 const std::string &input,
131 const std::string &value);
133 /// gets the output of the box
134 std::string Get (const std::string &box,
135 const std::string &output);
137 /// changes the workspace name
138 void SetWorkspaceName( const std::string& n );
140 ///Adds the authorName to the Box author list
141 void Author(const std::string &authorName);
143 ///Adds the Categories to the Box category list
144 void Category(const std::string &category);
146 /// The description string which explains what does the ComplexBox
147 void Description(const std::string & d);
149 /// prints the list off the boxes of the current box
152 /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
153 std::string ShowGraph(const std::string &nameblackbox,
154 const std::string &detailStr,
155 const std::string &levelStr,
156 const std::string &output_file,
157 const std::string &custom_header,
158 const std::string &custom_title,
159 bool system_display = true);
161 /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
162 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
164 /// Description of the actual pipeline
165 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
167 /// Resets the workspace : destroys all boxes / unloads all packages
170 /// Sets the level of message for kind
171 void SetMessageLevel(const std::string &kind,
174 /// Prints help on the messages
178 void Print(const std::string & message);
180 // static const std::string& GetObjectDescription();
181 // { static std::string s("Executer"); return s; }
184 ComplexBlackBoxDescriptor::Pointer GetWorkspace()
185 { return mRootCBB.lock(); }
186 Package::Pointer GetUserPackage()
187 { return mRootPackage.lock(); }
189 /// Gets the current working black box
190 ComplexBlackBoxDescriptor::Pointer GetCurrentDescriptor()
191 { return mOpenDefinition.back().box; }
199 /// Returns true when we are inside a define/endefine block
200 // bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
202 //==================================================================
206 Factory::Pointer mFactory;
210 /// Contains the root ComplexBlabkBox
211 /// In which ComplexBlackBoxes are put by default
212 /// Its name in bbi is 'user'
213 Package::WeakPointer mRootPackage;
215 /// The root ComplexBlackBox
216 /// in which operations are done when outside a define/endefine block
217 /// Its name in bbi is 'workspace'
218 ComplexBlackBoxDescriptor::WeakPointer mRootCBB;
220 /// Struct that stores info on user defined complex black boxes
223 ComplexBlackBoxDescriptor::Pointer box;
225 CBBDefinition(ComplexBlackBoxDescriptor::Pointer d,
226 const std::string& p )
227 : box(d), package(p) {}
230 /// The stack of current working ComplexBlackBox
231 /// (is a stack for nested definitions)
232 /// only contains the root cbb when outside a define/endefine block
233 std::deque<CBBDefinition> mOpenDefinition;
235 /// The stack of current working package
236 /// (is a stack for nested definitions)
237 std::deque<Package::WeakPointer> mOpenPackage;
239 /// The input values of the Root ComplexBlackBox
240 std::map<std::string,std::string> mInputs;
242 /// no exec mode flag
246 DialogModeType mDialogMode;