1 /*=========================================================================
4 Module: $RCSfile: bbtkExecuter.h,v $ $
6 Date: $Date: 2008/01/22 16:55:04 $
7 Version: $Revision: 1.2 $
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
50 // void SetFactory(Factory* f);
55 /// Sets the inputs of the workspace :
56 void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
58 /// Puts the executer in "no exec" mode,
59 /// which creates but does not execute pipelines
60 void SetNoExecMode(bool b) { mNoExecMode = b; }
62 bool GetNoExecMode() const { return mNoExecMode; }
64 /// Sets the mode of dialog of the executer for Root inputs
65 void SetDialogMode(DialogModeType t) { mDialogMode = t; }
67 /// Starts the definition of a new ComplexBlackBox in package pack
68 /// scriptfilename is the file from which the def is read
69 void Define (const std::string &name,
70 const std::string& pack,
71 const std::string &scriptfilename);
73 /// End the definition of a ComplexBlackBox
76 /// Creates a new black box in current complex box
77 void Create ( const std::string& boxType, const std::string& boxName);
79 /// Destroys a black box
80 void Destroy (const std::string &boxName);
82 /// Connects the output boxOutput to the input boxInput
83 void Connect (const std::string &boxfrom,
84 const std::string &output,
85 const std::string &boxto,
86 const std::string &input);
89 /// would 'Execute' be more meaningfull ?
90 void Update (const std::string &box);
92 /// Defines an input of the current complex box
93 void DefineInput (const std::string &name,
94 const std::string &box,
95 const std::string &input,
96 const std::string &help);
98 /// Defines an output of the current complex box
99 void DefineOutput (const std::string &name,
100 const std::string &box,
101 const std::string &output,
102 const std::string &help);
104 /// sets the input of the box with the value
105 void Set (const std::string &box,
106 const std::string &input,
107 const std::string &value);
109 /// gets the output of the box
110 std::string Get (const std::string &box,
111 const std::string &output);
113 /// changes the workspace name
114 void SetWorkspaceName( const std::string& n );
116 ///Adds the authorName to the Box's author list
117 void Author(const std::string &authorName);
119 /// The description string which explains what does the ComplexBox
120 void Description(const std::string & d);
122 /// prints the list off the boxes of the current box
125 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
126 std::string ShowGraph(const std::string &nameblackbox,
127 const std::string &detailStr,
128 const std::string &levelStr,
129 const std::string &output_file,
130 const std::string &custom_header,
131 const std::string &custom_title,
132 bool system_display = true);
134 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
135 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
137 /// Description of the actual pipeline
138 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
142 // static const std::string& GetObjectDescription()
143 // { static std::string s("Executer"); return s; }
149 /// Gets the current working black box
150 ComplexBlackBoxDescriptor* Current() { return mCurrent.back().box; }
152 /// Returns true when we are inside a define/endefine block
153 // bool InDefinitionBlock() { return (mCurrent.size()>1); }
155 //==================================================================
159 // Factory* mFactory;
164 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
165 /// Its name in bbi is 'workspace'
166 ComplexBlackBoxDescriptor* mRoot;
168 /// Struct that stores info on user defined complex black boxes
171 ComplexBlackBoxDescriptor* box;
173 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
174 : box(d), package(p) {}
177 /// The stack of current working ComplexBlackBox
178 /// (is a stack for nested definitions)
179 /// only contains the root when outside a define/endefine block
180 std::deque<CBBDefinition> mCurrent;
182 /// flag which is true when we are inside a Define/EndDefine block
185 /// The input values of the Root ComplexBlackBox
186 std::map<std::string,std::string> mInputs;
188 /// no exec mode flag
192 DialogModeType mDialogMode;