]> Creatis software - bbtk.git/blob - kernel/src/bbtkVirtualExec.h
Feature #1774
[bbtk.git] / kernel / src / bbtkVirtualExec.h
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbtkVirtualExec.h,v $
31   Language:  C++
32   Date:      $Date: 2012/11/16 08:49:01 $
33   Version:   $Revision: 1.21 $
34 =========================================================================*/
35
36
37
38 /**
39  *  \file 
40  *  \brief class VirtualExec: level 0 of script execution (header)
41  */
42 /**
43  *  \class bbtk::VirtualExec 
44  *  \brief class VirtualExec: level 0 of script execution 
45  */
46   
47 #ifndef __bbtkVirtualExec_h__
48 #define __bbtkVirtualExec_h__
49
50 #include "bbtkSystem.h"
51 #include "bbtkComplexBlackBoxDescriptor.h"
52 #include "bbtkFactory.h"
53
54 namespace bbtk
55 {
56
57   class Interpreter;
58   BBTK_FORWARD_DECLARE_POINTER(Interpreter);
59
60   class BBTK_EXPORT VirtualExec : public Object
61   {
62     BBTK_ABSTRACT_OBJECT_INTERFACE(VirtualExec);
63   public:
64     typedef enum
65     {
66        NoDialog,
67        TextDialog,
68        GraphicalDialog
69     }
70     DialogModeType;
71
72
73     /// Sets the interpreter who uses it 
74     void SetInterpreter(InterpreterPointer i) { mInterpreter = i; }
75     /// Gets the interpreter who uses it 
76     InterpreterPointer GetInterpreter(); // { return mInterpreter.lock(); }
77     /// Gets the interpreter who uses it (const)
78     //    const Interpreter::Pointer GetInterpreter() const { return mInterpreter; }
79
80     /// Gets the factory used by the executer
81     virtual Factory::Pointer GetFactory() { return Factory::Pointer(); }
82     /// Gets the factory used by the executer (const)
83     // virtual const Factory* GetFactory() const { return 0; }
84     
85     /// Sets the inputs of the workspace : 
86     virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
87
88     /// Puts the executer in "no exec" mode, 
89     /// which creates but does not execute pipelines 
90     virtual void SetNoExecMode(bool b) = 0;
91
92     virtual bool GetNoExecMode() const = 0;
93
94     /// Sets the mode of dialog of the executer for Root inputs 
95     virtual void SetDialogMode(DialogModeType t) = 0;
96
97     /// Puts the executer in "no error" mode, 
98     /// Errors do not stop execution (but warnings are produced)
99     virtual void SetNoErrorMode(bool b) = 0;
100     virtual bool GetNoErrorMode() const = 0;
101     //=================================================================
102    /// Loads a package
103     virtual void LoadPackage(const std::string &name ) = 0;
104
105     /// Unloads a package
106     virtual void UnLoadPackage(const std::string &name ) = 0;
107
108     /// Starts a package block  
109     virtual void BeginPackage (const std::string &name ) = 0;
110
111     /// Ends a package block
112     virtual void EndPackage () = 0;
113
114     /// Starts the definition of a new ComplexBlackBox in package pack
115     /// scriptfilename is the file from which the def is read
116     virtual void Define (const std::string &name,
117                  const std::string& pack,
118                  const std::string &scriptfilename) = 0;
119  
120     /// Sets the file name to use for the current definition
121     /// (Used to set it after the Define command)
122     virtual void SetCurrentFileName (const std::string &name ) = 0;
123           
124           virtual void SetTypeOfScript_Application( ) = 0;
125           
126     /// End the definition of a ComplexBlackBox
127     virtual void EndDefine () = 0;
128
129     /// Sets the kind of the currently defined ComplexBlackBox
130     virtual void Kind(const std::string& kind) = 0;
131
132     /// Creates a new black box in current complex box
133     virtual void Create ( const std::string& boxType, const std::string&
134     boxName) = 0;
135
136     /// Destroys a black box
137     virtual void Destroy (const std::string &boxName) = 0;
138
139     /// Clears the currently defined ComplexBlackBox
140     virtual void Clear() = 0;
141
142     /// Connects the output boxOutput to the input boxInput
143     virtual void Connect (const std::string &boxfrom,
144                   const std::string &output,
145                   const std::string &boxto,
146                   const std::string &input) = 0;
147
148     /// Executes the box 
149     virtual void Execute (const std::string &box) = 0;
150
151     /// Defines an input of the current complex box
152     virtual void DefineInput (const std::string &name,
153                       const std::string &box,
154                       const std::string &input,
155                       const std::string &help) = 0;
156
157     /// Defines an output of the current complex box
158     virtual void DefineOutput (const std::string &name,
159                        const std::string &box,
160                        const std::string &output,
161                        const std::string &help) = 0;     
162   
163     /// sets the input of the box with the value
164     virtual void Set (const std::string &box, 
165               const std::string &input, 
166               const std::string &value) = 0;
167
168     /// gets the output of the box
169     virtual std::string Get (const std::string &box, 
170                      const std::string &output) = 0;
171
172     /// changes the workspace name
173     virtual void SetWorkspaceName( const std::string& n ) = 0;
174
175     ///Adds the authorName to the Box author list
176     virtual void Author(const std::string &authorName) = 0;
177
178     ///Adds the categories to the Box categoris list
179     virtual void Category(const std::string &categories) = 0;
180
181     /// The description string which explains what does the ComplexBox
182     virtual void Description(const std::string &d) = 0;
183
184     /// prints the list of the boxes of the current box
185     virtual void PrintHelpListBoxes() = 0;
186
187    /// Generate a HTML file with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
188     virtual std::string ShowGraph(const std::string &nameblackbox, 
189                           const std::string &detailStr, 
190                           const std::string &levelStr,
191                           const std::string &output_file,
192                           const std::string &custom_header,
193                           const std::string &custom_title,
194                           bool system_display = true) = 0;
195
196    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
197     virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0;
198
199     /// Prints help on a black box
200     virtual void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
201     
202     virtual void Reset() = 0;
203     
204     /// Sets the level of message for kind
205     virtual void SetMessageLevel(const std::string &kind, int level) = 0;
206     
207     /// Prints help on the messages
208     virtual void HelpMessages() = 0;
209
210     /// Prints the string ... MORE : TO EXPLAIN 
211     virtual void Print(const std::string & message) = 0;
212
213     virtual ComplexBlackBoxDescriptor::Pointer GetWorkspace() 
214     { return  ComplexBlackBoxDescriptor::Pointer(); }
215   
216   //  static const std::string& GetObjectDescription() = 0;
217   //  { static std::string s("VirtualExec"); return s; }
218   protected:
219
220   private:
221
222    /// The interpreter which uses it (0 if none)
223     InterpreterWeakPointer mInterpreter;
224
225   };
226 }
227 #endif