1 /*=========================================================================
4 Module: $RCSfile: bbtkExecuter.h,v $ $
6 Date: $Date: 2008/01/22 15:02:00 $
7 Version: $Revision: 1.1.1.1 $
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"
41 class /*BBTK_EXPORT*/ Executer : public VirtualExec
60 // void SetFactory(Factory* f);
65 /// Sets the inputs of the workspace :
66 void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
68 /// Puts the executer in "no exec" mode,
69 /// which creates but does not execute pipelines
70 void SetNoExecMode(bool b) { mNoExecMode = b; }
72 bool GetNoExecMode() const { return mNoExecMode; }
74 /// Sets the mode of dialog of the executer for Root inputs
75 void SetDialogMode(DialogModeType t) { mDialogMode = t; }
77 /// Starts the definition of a new ComplexBlackBox in package pack
78 /// scriptfilename is the file from which the def is read
79 void Define (const std::string &name,
80 const std::string& pack,
81 const std::string &scriptfilename);
83 /// End the definition of a ComplexBlackBox
86 /// Creates a new black box in current complex box
87 void Create ( const std::string& boxType, const std::string& boxName);
89 /// Destroys a black box
90 void Destroy (const std::string &boxName);
92 /// Connects the output boxOutput to the input boxInput
93 void Connect (const std::string &boxfrom,
94 const std::string &output,
95 const std::string &boxto,
96 const std::string &input);
99 /// would 'Execute' be more meaningfull ?
100 void Update (const std::string &box);
102 /// Defines an input of the current complex box
103 void DefineInput (const std::string &name,
104 const std::string &box,
105 const std::string &input,
106 const std::string &help);
108 /// Defines an output of the current complex box
109 void DefineOutput (const std::string &name,
110 const std::string &box,
111 const std::string &output,
112 const std::string &help);
114 /// sets the input of the box with the value
115 void Set (const std::string &box,
116 const std::string &input,
117 const std::string &value);
119 /// gets the output of the box
120 std::string Get (const std::string &box,
121 const std::string &output);
123 /// changes the workspace name
124 void SetWorkspaceName( const std::string& n );
126 ///Adds the authorName to the Box's author list
127 void Author(const std::string &authorName);
129 /// The description string which explains what does the ComplexBox
130 void Description(const std::string & d);
132 /// prints the list off the boxes of the current box
135 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
136 std::string ShowGraph(const std::string &nameblackbox,
137 const std::string &detailStr,
138 const std::string &levelStr,
139 const std::string &output_file,
140 const std::string &custom_header,
141 const std::string &custom_title,
142 bool system_display = true);
144 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
145 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
147 /// Description of the actual pipeline
148 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
152 // static const std::string& GetObjectDescription()
153 // { static std::string s("Executer"); return s; }
159 /// Gets the current working black box
160 ComplexBlackBoxDescriptor* Current() { return mCurrent.back().box; }
162 /// Returns true when we are inside a define/endefine block
163 // bool InDefinitionBlock() { return (mCurrent.size()>1); }
165 //==================================================================
169 // Factory* mFactory;
174 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
175 /// Its name in bbi is 'workspace'
176 ComplexBlackBoxDescriptor* mRoot;
178 /// Struct that stores info on user defined complex black boxes
181 ComplexBlackBoxDescriptor* box;
183 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
184 : box(d), package(p) {}
187 /// The stack of current working ComplexBlackBox
188 /// (is a stack for nested definitions)
189 /// only contains the root when outside a define/endefine block
190 std::deque<CBBDefinition> mCurrent;
192 /// flag which is true when we are inside a Define/EndDefine block
195 /// The input values of the Root ComplexBlackBox
196 std::map<std::string,std::string> mInputs;
198 /// no exec mode flag
202 DialogModeType mDialogMode;