1 /*=========================================================================
4 Module: $RCSfile: bbtkVirtualExec.h,v $ $
6 Date: $Date: 2008/03/07 08:40:14 $
7 Version: $Revision: 1.8 $
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 VirtualExec: level 0 of script execution (header)
23 * \class bbtk::VirtualExec
24 * \brief class VirtualExec: level 0 of script execution
27 #ifndef __bbtkVirtualExec_h__
28 #define __bbtkVirtualExec_h__
30 #include "bbtkSystem.h"
31 //#include "bbtkComplexBlackBox.h"
32 #include "bbtkFactory.h"
41 class /*BBTK_EXPORT*/ VirtualExec // All methods are pure virtual
53 VirtualExec() : mInterpreter(0) {}
55 /// Sets the interpreter who uses it
56 void SetInterpreter(Interpreter* i) { mInterpreter = i; }
57 /// Gets the interpreter who uses it
58 Interpreter* GetInterpreter() { return mInterpreter; }
59 /// Gets the interpreter who uses it (const)
60 const Interpreter* GetInterpreter() const { return mInterpreter; }
62 /// Gets the factory used by the executer
63 virtual Factory* GetFactory() { return 0; }
64 /// Gets the factory used by the executer (const)
65 virtual const Factory* GetFactory() const { return 0; }
67 /// Sets the inputs of the workspace :
68 virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
70 /// Puts the executer in "no exec" mode,
71 /// which creates but does not execute pipelines
72 virtual void SetNoExecMode(bool b) = 0;
74 virtual bool GetNoExecMode() const = 0;
76 /// Sets the mode of dialog of the executer for Root inputs
77 virtual void SetDialogMode(DialogModeType t) = 0;
79 /// Starts a package block
80 virtual void BeginPackage (const std::string &name ) = 0;
82 /// Ends a package block
83 virtual void EndPackage () = 0;
85 /// Starts the definition of a new ComplexBlackBox in package pack
86 /// scriptfilename is the file from which the def is read
87 virtual void Define (const std::string &name,
88 const std::string& pack,
89 const std::string &scriptfilename) = 0;
91 /// Sets the file name to use for the current definition
92 /// (Used to set it after the Define command)
93 virtual void SetCurrentFileName (const std::string &name ) = 0;
95 /// End the definition of a ComplexBlackBox
96 virtual void EndDefine () = 0;
98 /// Creates a new black box in current complex box
99 virtual void Create ( const std::string& boxType, const std::string&
102 /// Destroys a black box
103 //virtual void Destroy (const std::string &boxName) = 0;
105 /// Connects the output boxOutput to the input boxInput
106 virtual void Connect (const std::string &boxfrom,
107 const std::string &output,
108 const std::string &boxto,
109 const std::string &input) = 0;
112 /// would 'Execute' be more meaningfull ?
113 virtual void Update (const std::string &box) = 0;
115 /// Defines an input of the current complex box
116 virtual void DefineInput (const std::string &name,
117 const std::string &box,
118 const std::string &input,
119 const std::string &help) = 0;
121 /// Defines an output of the current complex box
122 virtual void DefineOutput (const std::string &name,
123 const std::string &box,
124 const std::string &output,
125 const std::string &help) = 0;
127 /// sets the input of the box with the value
128 virtual void Set (const std::string &box,
129 const std::string &input,
130 const std::string &value) = 0;
132 /// gets the output of the box
133 virtual std::string Get (const std::string &box,
134 const std::string &output) = 0;
136 /// changes the workspace name
137 virtual void SetWorkspaceName( const std::string& n ) = 0;
139 ///Adds the authorName to the Box author list
140 virtual void Author(const std::string &authorName) = 0;
142 ///Adds the categories to the Box categoris list
143 virtual void Category(const std::string &categories) = 0;
145 /// The description string which explains what does the ComplexBox
146 virtual void Description(const std::string &d) = 0;
148 /// prints the list off the boxes of the current box
149 virtual void PrintBoxes() = 0;
151 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
152 virtual std::string ShowGraph(const std::string &nameblackbox,
153 const std::string &detailStr,
154 const std::string &levelStr,
155 const std::string &output_file,
156 const std::string &custom_header,
157 const std::string &custom_title,
158 bool system_display = true) = 0;
160 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
161 virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0;
163 /// Description of the actual pipeline
164 virtual void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
166 virtual void Reset() = 0;
169 // static const std::string& GetObjectDescription() = 0;
170 // { static std::string s("VirtualExec"); return s; }
175 /// The interpreter which uses it (0 if none)
176 Interpreter* mInterpreter;
178 /// Gets the current working black box
179 virtual ComplexBlackBoxDescriptor* Current() = 0;
181 /// Returns true when we are inside a define/endefine block
182 // virtual bool InDefinitionBlock() = 0;
184 //==================================================================
188 // Factory* mFactory;
193 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
194 /// Its name in bbi is 'workspace'
195 ComplexBlackBoxDescriptor* mRoot;
197 /// Struct that stores info on user defined complex black boxes
200 ComplexBlackBoxDescriptor* box;
202 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
203 : box(d), package(p) {}
206 /// The stack of current working ComplexBlackBox
207 /// (is a stack for nested definitions)
208 /// only contains the root when outside a define/endefine block
209 std::deque<CBBDefinition> mOpenDefinition;
211 /// The stack of current working package
212 /// (is a stack for nested definitions)
213 std::deque<Package*> mOpenPackage;
215 /// flag which is true when we are inside a Define/EndDefine block
218 /// The input values of the Root ComplexBlackBox
219 std::map<std::string,std::string> mInputs;
221 /// no exec mode flag
225 DialogModeType mDialogMode;