1 /*=========================================================================
4 Module: $RCSfile: bbtkExecuter.h,v $ $
6 Date: $Date: 2008/03/07 08:40:14 $
7 Version: $Revision: 1.10 $
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
55 /// Gets the factory used by the executer
56 Factory* GetFactory() { return mFactory; }
57 /// Gets the factory used by the executer (const)
58 const Factory* GetFactory() const { return mFactory; }
61 /// Sets the inputs of the workspace :
62 void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
64 /// Puts the executer in "no exec" mode,
65 /// which creates but does not execute pipelines
66 void SetNoExecMode(bool b) { mNoExecMode = b; }
68 bool GetNoExecMode() const { return mNoExecMode; }
70 /// Sets the mode of dialog of the executer for Root inputs
71 void SetDialogMode(DialogModeType t) { mDialogMode = t; }
73 /// Starts a package block
74 void BeginPackage (const std::string &name );
76 /// Ends a package block
79 /// Starts the definition of a new ComplexBlackBox in package pack
80 /// scriptfilename is the file from which the def is read
81 void Define (const std::string &name,
82 const std::string& pack,
83 const std::string &scriptfilename);
85 /// Sets the file name to use for the current definition
86 /// (Used to set it after the Define command)
87 void SetCurrentFileName (const std::string &name );
89 /// End the definition of a ComplexBlackBox
92 /// Creates a new black box in current complex box
93 void Create ( const std::string& boxType, const std::string& boxName);
95 /// Destroys a black box
96 void Destroy (const std::string &boxName);
98 /// Connects the output boxOutput to the input boxInput
99 void Connect (const std::string &boxfrom,
100 const std::string &output,
101 const std::string &boxto,
102 const std::string &input);
105 /// would 'Execute' be more meaningfull ?
106 void Update (const std::string &box);
108 /// Defines an input of the current complex box
109 void DefineInput (const std::string &name,
110 const std::string &box,
111 const std::string &input,
112 const std::string &help);
114 /// Defines an output of the current complex box
115 void DefineOutput (const std::string &name,
116 const std::string &box,
117 const std::string &output,
118 const std::string &help);
120 /// sets the input of the box with the value
121 void Set (const std::string &box,
122 const std::string &input,
123 const std::string &value);
125 /// gets the output of the box
126 std::string Get (const std::string &box,
127 const std::string &output);
129 /// changes the workspace name
130 void SetWorkspaceName( const std::string& n );
132 ///Adds the authorName to the Box author list
133 void Author(const std::string &authorName);
135 ///Adds the Categories to the Box category list
136 void Category(const std::string &category);
138 /// The description string which explains what does the ComplexBox
139 void Description(const std::string & d);
141 /// prints the list off the boxes of the current box
144 /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
145 std::string ShowGraph(const std::string &nameblackbox,
146 const std::string &detailStr,
147 const std::string &levelStr,
148 const std::string &output_file,
149 const std::string &custom_header,
150 const std::string &custom_title,
151 bool system_display = true);
153 /// Generate a HTML with a gif file with the current pipeline (Graphviz-dot needed). Returns the file path
154 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
156 /// Description of the actual pipeline
157 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
161 // static const std::string& GetObjectDescription();
162 // { static std::string s("Executer"); return s; }
168 /// Gets the current working black box
169 ComplexBlackBoxDescriptor* Current()
170 { return mOpenDefinition.back().box; }
172 /// Returns true when we are inside a define/endefine block
173 // bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
175 //==================================================================
183 /// Contains the root ComplexBlabkBox
184 /// In which ComplexBlackBoxes are put by default
185 /// Its name in bbi is 'user'
186 Package* mRootPackage;
188 /// The root ComplexBlackBox
189 /// in which operations are done when outside a define/endefine block
190 /// Its name in bbi is 'workspace'
191 ComplexBlackBoxDescriptor* mRootCBB;
193 /// Struct that stores info on user defined complex black boxes
196 ComplexBlackBoxDescriptor* box;
198 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
199 : box(d), package(p) {}
202 /// The stack of current working ComplexBlackBox
203 /// (is a stack for nested definitions)
204 /// only contains the root cbb when outside a define/endefine block
205 std::deque<CBBDefinition> mOpenDefinition;
207 /// The stack of current working package
208 /// (is a stack for nested definitions)
209 std::deque<Package*> mOpenPackage;
211 /// The input values of the Root ComplexBlackBox
212 std::map<std::string,std::string> mInputs;
214 /// no exec mode flag
218 DialogModeType mDialogMode;