]> Creatis software - bbtk.git/blob - kernel/src/bbtkVirtualExec.h
3c3c45d866c1a2784394e2fb502ccff819b2d67f
[bbtk.git] / kernel / src / bbtkVirtualExec.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkVirtualExec.h,v $
4   Language:  C++
5   Date:      $Date: 2012/11/14 07:12:00 $
6   Version:   $Revision: 1.20 $
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           virtual void SetTypeOfScript_Application( ) = 0;
118           
119     /// End the definition of a ComplexBlackBox
120     virtual void EndDefine () = 0;
121
122     /// Sets the kind of the currently defined ComplexBlackBox
123     virtual void Kind(const std::string& kind) = 0;
124
125     /// Creates a new black box in current complex box
126     virtual void Create ( const std::string& boxType, const std::string&
127     boxName) = 0;
128
129     /// Destroys a black box
130     virtual void Destroy (const std::string &boxName) = 0;
131
132     /// Clears the currently defined ComplexBlackBox
133     virtual void Clear() = 0;
134
135     /// Connects the output boxOutput to the input boxInput
136     virtual void Connect (const std::string &boxfrom,
137                   const std::string &output,
138                   const std::string &boxto,
139                   const std::string &input) = 0;
140
141     /// Executes the box 
142     virtual void Execute (const std::string &box) = 0;
143
144     /// Defines an input of the current complex box
145     virtual void DefineInput (const std::string &name,
146                       const std::string &box,
147                       const std::string &input,
148                       const std::string &help) = 0;
149
150     /// Defines an output of the current complex box
151     virtual void DefineOutput (const std::string &name,
152                        const std::string &box,
153                        const std::string &output,
154                        const std::string &help) = 0;     
155   
156     /// sets the input of the box with the value
157     virtual void Set (const std::string &box, 
158               const std::string &input, 
159               const std::string &value) = 0;
160
161     /// gets the output of the box
162     virtual std::string Get (const std::string &box, 
163                      const std::string &output) = 0;
164
165     /// changes the workspace name
166     virtual void SetWorkspaceName( const std::string& n ) = 0;
167
168     ///Adds the authorName to the Box author list
169     virtual void Author(const std::string &authorName) = 0;
170
171     ///Adds the categories to the Box categoris list
172     virtual void Category(const std::string &categories) = 0;
173
174     /// The description string which explains what does the ComplexBox
175     virtual void Description(const std::string &d) = 0;
176
177     /// prints the list of the boxes of the current box
178     virtual void PrintHelpListBoxes() = 0;
179
180    /// Generate a HTML file with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
181     virtual std::string ShowGraph(const std::string &nameblackbox, 
182                           const std::string &detailStr, 
183                           const std::string &levelStr,
184                           const std::string &output_file,
185                           const std::string &custom_header,
186                           const std::string &custom_title,
187                           bool system_display = true) = 0;
188
189    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
190     virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0;
191
192     /// Prints help on a black box
193     virtual void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
194     
195     virtual void Reset() = 0;
196     
197     /// Sets the level of message for kind
198     virtual void SetMessageLevel(const std::string &kind, int level) = 0;
199     
200     /// Prints help on the messages
201     virtual void HelpMessages() = 0;
202
203     /// Prints the string ... MORE : TO EXPLAIN 
204     virtual void Print(const std::string & message) = 0;
205
206     virtual ComplexBlackBoxDescriptor::Pointer GetWorkspace() 
207     { return  ComplexBlackBoxDescriptor::Pointer(); }
208   
209   //  static const std::string& GetObjectDescription() = 0;
210   //  { static std::string s("VirtualExec"); return s; }
211   protected:
212
213   private:
214
215    /// The interpreter which uses it (0 if none)
216     InterpreterWeakPointer mInterpreter;
217
218   };
219 }
220 #endif