1 /*=========================================================================
4 Module: $RCSfile: bbtkVirtualExec.h,v $ $
6 Date: $Date: 2008/03/26 08:27:19 $
7 Version: $Revision: 1.9 $
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 //=================================================================
81 virtual void LoadPackage(const std::string &name ) = 0;
84 virtual void UnLoadPackage(const std::string &name ) = 0;
86 /// Starts a package block
87 virtual void BeginPackage (const std::string &name ) = 0;
89 /// Ends a package block
90 virtual void EndPackage () = 0;
92 /// Starts the definition of a new ComplexBlackBox in package pack
93 /// scriptfilename is the file from which the def is read
94 virtual void Define (const std::string &name,
95 const std::string& pack,
96 const std::string &scriptfilename) = 0;
98 /// Sets the file name to use for the current definition
99 /// (Used to set it after the Define command)
100 virtual void SetCurrentFileName (const std::string &name ) = 0;
102 /// End the definition of a ComplexBlackBox
103 virtual void EndDefine () = 0;
105 /// Creates a new black box in current complex box
106 virtual void Create ( const std::string& boxType, const std::string&
109 /// Destroys a black box
110 virtual void Destroy (const std::string &boxName) = 0;
112 /// Connects the output boxOutput to the input boxInput
113 virtual void Connect (const std::string &boxfrom,
114 const std::string &output,
115 const std::string &boxto,
116 const std::string &input) = 0;
119 virtual void Execute (const std::string &box) = 0;
121 /// Defines an input of the current complex box
122 virtual void DefineInput (const std::string &name,
123 const std::string &box,
124 const std::string &input,
125 const std::string &help) = 0;
127 /// Defines an output of the current complex box
128 virtual void DefineOutput (const std::string &name,
129 const std::string &box,
130 const std::string &output,
131 const std::string &help) = 0;
133 /// sets the input of the box with the value
134 virtual void Set (const std::string &box,
135 const std::string &input,
136 const std::string &value) = 0;
138 /// gets the output of the box
139 virtual std::string Get (const std::string &box,
140 const std::string &output) = 0;
142 /// changes the workspace name
143 virtual void SetWorkspaceName( const std::string& n ) = 0;
145 ///Adds the authorName to the Box author list
146 virtual void Author(const std::string &authorName) = 0;
148 ///Adds the categories to the Box categoris list
149 virtual void Category(const std::string &categories) = 0;
151 /// The description string which explains what does the ComplexBox
152 virtual void Description(const std::string &d) = 0;
154 /// prints the list off the boxes of the current box
155 virtual void PrintBoxes() = 0;
157 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
158 virtual std::string ShowGraph(const std::string &nameblackbox,
159 const std::string &detailStr,
160 const std::string &levelStr,
161 const std::string &output_file,
162 const std::string &custom_header,
163 const std::string &custom_title,
164 bool system_display = true) = 0;
166 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
167 virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0;
169 /// Description of the actual pipeline
170 virtual void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
172 virtual void Reset() = 0;
174 /// Sets the level of message for kind
175 virtual void SetMessageLevel(const std::string &kind, int level) = 0,;
177 /// Prints help on the messages
178 virtual void HelpMessages() = 0;
180 /// Prints the string ... MORE : TO EXPLAIN
181 virtual void Print(const std::string & message) = 0;
184 // static const std::string& GetObjectDescription() = 0;
185 // { static std::string s("VirtualExec"); return s; }
190 /// The interpreter which uses it (0 if none)
191 Interpreter* mInterpreter;
193 /// Gets the current working black box
194 virtual ComplexBlackBoxDescriptor* Current() = 0;
196 /// Returns true when we are inside a define/endefine block
197 // virtual bool InDefinitionBlock() = 0;
199 //==================================================================
203 // Factory* mFactory;
208 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
209 /// Its name in bbi is 'workspace'
210 ComplexBlackBoxDescriptor* mRoot;
212 /// Struct that stores info on user defined complex black boxes
215 ComplexBlackBoxDescriptor* box;
217 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
218 : box(d), package(p) {}
221 /// The stack of current working ComplexBlackBox
222 /// (is a stack for nested definitions)
223 /// only contains the root when outside a define/endefine block
224 std::deque<CBBDefinition> mOpenDefinition;
226 /// The stack of current working package
227 /// (is a stack for nested definitions)
228 std::deque<Package*> mOpenPackage;
230 /// flag which is true when we are inside a Define/EndDefine block
233 /// The input values of the Root ComplexBlackBox
234 std::map<std::string,std::string> mInputs;
236 /// no exec mode flag
240 DialogModeType mDialogMode;