1 /*=========================================================================
4 Module: $RCSfile: bbtkVirtualExec.h,v $ $
6 Date: $Date: 2008/03/26 14:47:36 $
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 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 virtual ~VirtualExec() {}
57 /// Sets the interpreter who uses it
58 void SetInterpreter(Interpreter* i) { mInterpreter = i; }
59 /// Gets the interpreter who uses it
60 Interpreter* GetInterpreter() { return mInterpreter; }
61 /// Gets the interpreter who uses it (const)
62 const Interpreter* GetInterpreter() const { return mInterpreter; }
64 /// Gets the factory used by the executer
65 virtual Factory* GetFactory() { return 0; }
66 /// Gets the factory used by the executer (const)
67 virtual const Factory* GetFactory() const { return 0; }
69 /// Sets the inputs of the workspace :
70 virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
72 /// Puts the executer in "no exec" mode,
73 /// which creates but does not execute pipelines
74 virtual void SetNoExecMode(bool b) = 0;
76 virtual bool GetNoExecMode() const = 0;
78 /// Sets the mode of dialog of the executer for Root inputs
79 virtual void SetDialogMode(DialogModeType t) = 0;
81 //=================================================================
83 virtual void LoadPackage(const std::string &name ) = 0;
86 virtual void UnLoadPackage(const std::string &name ) = 0;
88 /// Starts a package block
89 virtual void BeginPackage (const std::string &name ) = 0;
91 /// Ends a package block
92 virtual void EndPackage () = 0;
94 /// Starts the definition of a new ComplexBlackBox in package pack
95 /// scriptfilename is the file from which the def is read
96 virtual void Define (const std::string &name,
97 const std::string& pack,
98 const std::string &scriptfilename) = 0;
100 /// Sets the file name to use for the current definition
101 /// (Used to set it after the Define command)
102 virtual void SetCurrentFileName (const std::string &name ) = 0;
104 /// End the definition of a ComplexBlackBox
105 virtual void EndDefine () = 0;
107 /// Creates a new black box in current complex box
108 virtual void Create ( const std::string& boxType, const std::string&
111 /// Destroys a black box
112 virtual void Destroy (const std::string &boxName) = 0;
114 /// Connects the output boxOutput to the input boxInput
115 virtual void Connect (const std::string &boxfrom,
116 const std::string &output,
117 const std::string &boxto,
118 const std::string &input) = 0;
121 virtual void Execute (const std::string &box) = 0;
123 /// Defines an input of the current complex box
124 virtual void DefineInput (const std::string &name,
125 const std::string &box,
126 const std::string &input,
127 const std::string &help) = 0;
129 /// Defines an output of the current complex box
130 virtual void DefineOutput (const std::string &name,
131 const std::string &box,
132 const std::string &output,
133 const std::string &help) = 0;
135 /// sets the input of the box with the value
136 virtual void Set (const std::string &box,
137 const std::string &input,
138 const std::string &value) = 0;
140 /// gets the output of the box
141 virtual std::string Get (const std::string &box,
142 const std::string &output) = 0;
144 /// changes the workspace name
145 virtual void SetWorkspaceName( const std::string& n ) = 0;
147 ///Adds the authorName to the Box author list
148 virtual void Author(const std::string &authorName) = 0;
150 ///Adds the categories to the Box categoris list
151 virtual void Category(const std::string &categories) = 0;
153 /// The description string which explains what does the ComplexBox
154 virtual void Description(const std::string &d) = 0;
156 /// prints the list off the boxes of the current box
157 virtual void PrintBoxes() = 0;
159 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
160 virtual std::string ShowGraph(const std::string &nameblackbox,
161 const std::string &detailStr,
162 const std::string &levelStr,
163 const std::string &output_file,
164 const std::string &custom_header,
165 const std::string &custom_title,
166 bool system_display = true) = 0;
168 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
169 virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0;
171 /// Description of the actual pipeline
172 virtual void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
174 virtual void Reset() = 0;
176 /// Sets the level of message for kind
177 virtual void SetMessageLevel(const std::string &kind, int level) = 0,;
179 /// Prints help on the messages
180 virtual void HelpMessages() = 0;
182 /// Prints the string ... MORE : TO EXPLAIN
183 virtual void Print(const std::string & message) = 0;
186 // static const std::string& GetObjectDescription() = 0;
187 // { static std::string s("VirtualExec"); return s; }
192 /// The interpreter which uses it (0 if none)
193 Interpreter* mInterpreter;
195 /// Gets the current working black box
196 virtual ComplexBlackBoxDescriptor* Current() = 0;
198 /// Returns true when we are inside a define/endefine block
199 // virtual bool InDefinitionBlock() = 0;
201 //==================================================================
205 // Factory* mFactory;
210 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
211 /// Its name in bbi is 'workspace'
212 ComplexBlackBoxDescriptor* mRoot;
214 /// Struct that stores info on user defined complex black boxes
217 ComplexBlackBoxDescriptor* box;
219 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
220 : box(d), package(p) {}
223 /// The stack of current working ComplexBlackBox
224 /// (is a stack for nested definitions)
225 /// only contains the root when outside a define/endefine block
226 std::deque<CBBDefinition> mOpenDefinition;
228 /// The stack of current working package
229 /// (is a stack for nested definitions)
230 std::deque<Package*> mOpenPackage;
232 /// flag which is true when we are inside a Define/EndDefine block
235 /// The input values of the Root ComplexBlackBox
236 std::map<std::string,std::string> mInputs;
238 /// no exec mode flag
242 DialogModeType mDialogMode;