1 /*=========================================================================
4 Module: $RCSfile: bbtkExecuter.h,v $ $
6 Date: $Date: 2008/01/28 15:08:53 $
7 Version: $Revision: 1.3 $
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 a package block
68 void BeginPackage (const std::string &name );
70 /// Ends a package block
73 /// Starts the definition of a new ComplexBlackBox in package pack
74 /// scriptfilename is the file from which the def is read
75 void Define (const std::string &name,
76 const std::string& pack,
77 const std::string &scriptfilename);
79 /// End the definition of a ComplexBlackBox
82 /// Creates a new black box in current complex box
83 void Create ( const std::string& boxType, const std::string& boxName);
85 /// Destroys a black box
86 void Destroy (const std::string &boxName);
88 /// Connects the output boxOutput to the input boxInput
89 void Connect (const std::string &boxfrom,
90 const std::string &output,
91 const std::string &boxto,
92 const std::string &input);
95 /// would 'Execute' be more meaningfull ?
96 void Update (const std::string &box);
98 /// Defines an input of the current complex box
99 void DefineInput (const std::string &name,
100 const std::string &box,
101 const std::string &input,
102 const std::string &help);
104 /// Defines an output of the current complex box
105 void DefineOutput (const std::string &name,
106 const std::string &box,
107 const std::string &output,
108 const std::string &help);
110 /// sets the input of the box with the value
111 void Set (const std::string &box,
112 const std::string &input,
113 const std::string &value);
115 /// gets the output of the box
116 std::string Get (const std::string &box,
117 const std::string &output);
119 /// changes the workspace name
120 void SetWorkspaceName( const std::string& n );
122 ///Adds the authorName to the Box's author list
123 void Author(const std::string &authorName);
125 /// The description string which explains what does the ComplexBox
126 void Description(const std::string & d);
128 /// prints the list off the boxes of the current box
131 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
132 std::string ShowGraph(const std::string &nameblackbox,
133 const std::string &detailStr,
134 const std::string &levelStr,
135 const std::string &output_file,
136 const std::string &custom_header,
137 const std::string &custom_title,
138 bool system_display = true);
140 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
141 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
143 /// Description of the actual pipeline
144 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
148 // static const std::string& GetObjectDescription()
149 // { static std::string s("Executer"); return s; }
155 /// Gets the current working black box
156 ComplexBlackBoxDescriptor* Current()
157 { return mOpenDefinition.back().box; }
159 /// Returns true when we are inside a define/endefine block
160 // bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
162 //==================================================================
166 // Factory* mFactory;
171 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
172 /// Its name in bbi is 'workspace'
173 ComplexBlackBoxDescriptor* mRoot;
175 /// Struct that stores info on user defined complex black boxes
178 ComplexBlackBoxDescriptor* box;
180 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
181 : box(d), package(p) {}
184 /// The stack of current working ComplexBlackBox
185 /// (is a stack for nested definitions)
186 /// only contains the root when outside a define/endefine block
187 std::deque<CBBDefinition> mOpenDefinition;
189 /// The stack of current working package
190 /// (is a stack for nested definitions)
191 std::deque<Package*> mOpenPackage;
193 /// flag which is true when we are inside a Define/EndDefine block
196 /// The input values of the Root ComplexBlackBox
197 std::map<std::string,std::string> mInputs;
199 /// no exec mode flag
203 DialogModeType mDialogMode;