]> Creatis software - bbtk.git/blob - kernel/src/bbtkVirtualExec.h
73010f242481c732f1ca237a09115583ccdf104d
[bbtk.git] / kernel / src / bbtkVirtualExec.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkVirtualExec.h,v $
4   Language:  C++
5   Date:      $Date: 2009/06/08 14:50:04 $
6   Version:   $Revision: 1.19 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32  *  \file 
33  *  \brief class VirtualExec: level 0 of script execution (header)
34  */
35 /**
36  *  \class bbtk::VirtualExec 
37  *  \brief class VirtualExec: level 0 of script execution 
38  */
39   
40 #ifndef __bbtkVirtualExec_h__
41 #define __bbtkVirtualExec_h__
42
43 #include "bbtkSystem.h"
44 #include "bbtkComplexBlackBoxDescriptor.h"
45 #include "bbtkFactory.h"
46
47 namespace bbtk
48 {
49
50   class Interpreter;
51   BBTK_FORWARD_DECLARE_POINTER(Interpreter);
52
53   class BBTK_EXPORT VirtualExec : public Object
54   {
55     BBTK_ABSTRACT_OBJECT_INTERFACE(VirtualExec);
56   public:
57     typedef enum
58     {
59        NoDialog,
60        TextDialog,
61        GraphicalDialog
62     }
63     DialogModeType;
64
65
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; }
72
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; }
77     
78     /// Sets the inputs of the workspace : 
79     virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
80
81     /// Puts the executer in "no exec" mode, 
82     /// which creates but does not execute pipelines 
83     virtual void SetNoExecMode(bool b) = 0;
84
85     virtual bool GetNoExecMode() const = 0;
86
87     /// Sets the mode of dialog of the executer for Root inputs 
88     virtual void SetDialogMode(DialogModeType t) = 0;
89
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     //=================================================================
95    /// Loads a package
96     virtual void LoadPackage(const std::string &name ) = 0;
97
98     /// Unloads a package
99     virtual void UnLoadPackage(const std::string &name ) = 0;
100
101     /// Starts a package block  
102     virtual void BeginPackage (const std::string &name ) = 0;
103
104     /// Ends a package block
105     virtual void EndPackage () = 0;
106
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;
112  
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;
116
117     /// End the definition of a ComplexBlackBox
118     virtual void EndDefine () = 0;
119
120     /// Sets the kind of the currently defined ComplexBlackBox
121     virtual void Kind(const std::string& kind) = 0;
122
123     /// Creates a new black box in current complex box
124     virtual void Create ( const std::string& boxType, const std::string&
125     boxName) = 0;
126
127     /// Destroys a black box
128     virtual void Destroy (const std::string &boxName) = 0;
129
130     /// Clears the currently defined ComplexBlackBox
131     virtual void Clear() = 0;
132
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;
138
139     /// Executes the box 
140     virtual void Execute (const std::string &box) = 0;
141
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;
147
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;     
153   
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;
158
159     /// gets the output of the box
160     virtual std::string Get (const std::string &box, 
161                      const std::string &output) = 0;
162
163     /// changes the workspace name
164     virtual void SetWorkspaceName( const std::string& n ) = 0;
165
166     ///Adds the authorName to the Box author list
167     virtual void Author(const std::string &authorName) = 0;
168
169     ///Adds the categories to the Box categoris list
170     virtual void Category(const std::string &categories) = 0;
171
172     /// The description string which explains what does the ComplexBox
173     virtual void Description(const std::string &d) = 0;
174
175     /// prints the list of the boxes of the current box
176     virtual void PrintHelpListBoxes() = 0;
177
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;
186
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;
189
190     /// Prints help on a black box
191     virtual void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
192     
193     virtual void Reset() = 0;
194     
195     /// Sets the level of message for kind
196     virtual void SetMessageLevel(const std::string &kind, int level) = 0;
197     
198     /// Prints help on the messages
199     virtual void HelpMessages() = 0;
200
201     /// Prints the string ... MORE : TO EXPLAIN 
202     virtual void Print(const std::string & message) = 0;
203
204     virtual ComplexBlackBoxDescriptor::Pointer GetWorkspace() 
205     { return  ComplexBlackBoxDescriptor::Pointer(); }
206   
207   //  static const std::string& GetObjectDescription() = 0;
208   //  { static std::string s("VirtualExec"); return s; }
209   protected:
210
211   private:
212
213    /// The interpreter which uses it (0 if none)
214     InterpreterWeakPointer mInterpreter;
215
216   };
217 }
218 #endif