1 /*=========================================================================
3 Module: $RCSfile: bbtkVirtualExec.h,v $
5 Date: $Date: 2009/06/08 14:50:04 $
6 Version: $Revision: 1.19 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief class VirtualExec: level 0 of script execution (header)
36 * \class bbtk::VirtualExec
37 * \brief class VirtualExec: level 0 of script execution
40 #ifndef __bbtkVirtualExec_h__
41 #define __bbtkVirtualExec_h__
43 #include "bbtkSystem.h"
44 #include "bbtkComplexBlackBoxDescriptor.h"
45 #include "bbtkFactory.h"
51 BBTK_FORWARD_DECLARE_POINTER(Interpreter);
53 class BBTK_EXPORT VirtualExec : public Object
55 BBTK_ABSTRACT_OBJECT_INTERFACE(VirtualExec);
66 /// Sets the interpreter who uses it
67 void SetInterpreter(InterpreterPointer i) { mInterpreter = i; }
68 /// Gets the interpreter who uses it
69 InterpreterPointer GetInterpreter(); // { return mInterpreter.lock(); }
70 /// Gets the interpreter who uses it (const)
71 // const Interpreter::Pointer GetInterpreter() const { return mInterpreter; }
73 /// Gets the factory used by the executer
74 virtual Factory::Pointer GetFactory() { return Factory::Pointer(); }
75 /// Gets the factory used by the executer (const)
76 // virtual const Factory* GetFactory() const { return 0; }
78 /// Sets the inputs of the workspace :
79 virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
81 /// Puts the executer in "no exec" mode,
82 /// which creates but does not execute pipelines
83 virtual void SetNoExecMode(bool b) = 0;
85 virtual bool GetNoExecMode() const = 0;
87 /// Sets the mode of dialog of the executer for Root inputs
88 virtual void SetDialogMode(DialogModeType t) = 0;
90 /// Puts the executer in "no error" mode,
91 /// Errors do not stop execution (but warnings are produced)
92 virtual void SetNoErrorMode(bool b) = 0;
93 virtual bool GetNoErrorMode() const = 0;
94 //=================================================================
96 virtual void LoadPackage(const std::string &name ) = 0;
99 virtual void UnLoadPackage(const std::string &name ) = 0;
101 /// Starts a package block
102 virtual void BeginPackage (const std::string &name ) = 0;
104 /// Ends a package block
105 virtual void EndPackage () = 0;
107 /// Starts the definition of a new ComplexBlackBox in package pack
108 /// scriptfilename is the file from which the def is read
109 virtual void Define (const std::string &name,
110 const std::string& pack,
111 const std::string &scriptfilename) = 0;
113 /// Sets the file name to use for the current definition
114 /// (Used to set it after the Define command)
115 virtual void SetCurrentFileName (const std::string &name ) = 0;
117 /// End the definition of a ComplexBlackBox
118 virtual void EndDefine () = 0;
120 /// Sets the kind of the currently defined ComplexBlackBox
121 virtual void Kind(const std::string& kind) = 0;
123 /// Creates a new black box in current complex box
124 virtual void Create ( const std::string& boxType, const std::string&
127 /// Destroys a black box
128 virtual void Destroy (const std::string &boxName) = 0;
130 /// Clears the currently defined ComplexBlackBox
131 virtual void Clear() = 0;
133 /// Connects the output boxOutput to the input boxInput
134 virtual void Connect (const std::string &boxfrom,
135 const std::string &output,
136 const std::string &boxto,
137 const std::string &input) = 0;
140 virtual void Execute (const std::string &box) = 0;
142 /// Defines an input of the current complex box
143 virtual void DefineInput (const std::string &name,
144 const std::string &box,
145 const std::string &input,
146 const std::string &help) = 0;
148 /// Defines an output of the current complex box
149 virtual void DefineOutput (const std::string &name,
150 const std::string &box,
151 const std::string &output,
152 const std::string &help) = 0;
154 /// sets the input of the box with the value
155 virtual void Set (const std::string &box,
156 const std::string &input,
157 const std::string &value) = 0;
159 /// gets the output of the box
160 virtual std::string Get (const std::string &box,
161 const std::string &output) = 0;
163 /// changes the workspace name
164 virtual void SetWorkspaceName( const std::string& n ) = 0;
166 ///Adds the authorName to the Box author list
167 virtual void Author(const std::string &authorName) = 0;
169 ///Adds the categories to the Box categoris list
170 virtual void Category(const std::string &categories) = 0;
172 /// The description string which explains what does the ComplexBox
173 virtual void Description(const std::string &d) = 0;
175 /// prints the list of the boxes of the current box
176 virtual void PrintHelpListBoxes() = 0;
178 /// Generate a HTML file with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
179 virtual std::string ShowGraph(const std::string &nameblackbox,
180 const std::string &detailStr,
181 const std::string &levelStr,
182 const std::string &output_file,
183 const std::string &custom_header,
184 const std::string &custom_title,
185 bool system_display = true) = 0;
187 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
188 virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0;
190 /// Prints help on a black box
191 virtual void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
193 virtual void Reset() = 0;
195 /// Sets the level of message for kind
196 virtual void SetMessageLevel(const std::string &kind, int level) = 0;
198 /// Prints help on the messages
199 virtual void HelpMessages() = 0;
201 /// Prints the string ... MORE : TO EXPLAIN
202 virtual void Print(const std::string & message) = 0;
204 virtual ComplexBlackBoxDescriptor::Pointer GetWorkspace()
205 { return ComplexBlackBoxDescriptor::Pointer(); }
207 // static const std::string& GetObjectDescription() = 0;
208 // { static std::string s("VirtualExec"); return s; }
213 /// The interpreter which uses it (0 if none)
214 InterpreterWeakPointer mInterpreter;