]> Creatis software - bbtk.git/blob - kernel/src/bbtkVirtualExec.h
Compil sous Windows
[bbtk.git] / kernel / src / bbtkVirtualExec.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkVirtualExec.h,v $ $
5   Language:  C++
6   Date:      $Date: 2008/05/06 13:45:12 $
7   Version:   $Revision: 1.15 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18 /**
19  *  \file 
20  *  \brief class VirtualExec: level 0 of script execution (header)
21  */
22 /**
23  *  \class bbtk::VirtualExec 
24  *  \brief class VirtualExec: level 0 of script execution 
25  */
26   
27 #ifndef __bbtkVirtualExec_h__
28 #define __bbtkVirtualExec_h__
29
30 #include "bbtkSystem.h"
31 #include "bbtkComplexBlackBoxDescriptor.h"
32 #include "bbtkFactory.h"
33
34 namespace bbtk
35 {
36
37   class Interpreter;
38   BBTK_FORWARD_DECLARE_POINTER(Interpreter);
39
40   class BBTK_EXPORT VirtualExec : public Object
41   {
42     BBTK_ABSTRACT_OBJECT_INTERFACE(VirtualExec);
43   public:
44     typedef enum
45     {
46        NoDialog,
47        TextDialog,
48        GraphicalDialog
49     }
50     DialogModeType;
51
52
53     /// Sets the interpreter who uses it 
54     void SetInterpreter(InterpreterPointer i) { mInterpreter = i; }
55     /// Gets the interpreter who uses it 
56     InterpreterPointer GetInterpreter(); // { return mInterpreter.lock(); }
57     /// Gets the interpreter who uses it (const)
58     //    const Interpreter::Pointer GetInterpreter() const { return mInterpreter; }
59
60     /// Gets the factory used by the executer
61     virtual Factory::Pointer GetFactory() { return Factory::Pointer(); }
62     /// Gets the factory used by the executer (const)
63     // virtual const Factory* GetFactory() const { return 0; }
64     
65     /// Sets the inputs of the workspace : 
66     virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
67
68     /// Puts the executer in "no exec" mode, 
69     /// which creates but does not execute pipelines 
70     virtual void SetNoExecMode(bool b) = 0;
71
72     virtual bool GetNoExecMode() const = 0;
73
74     /// Sets the mode of dialog of the executer for Root inputs 
75     virtual void SetDialogMode(DialogModeType t) = 0;
76
77     //=================================================================
78    /// Loads a package
79     virtual void LoadPackage(const std::string &name ) = 0;
80
81     /// Unloads a package
82     virtual void UnLoadPackage(const std::string &name ) = 0;
83
84     /// Starts a package block  
85     virtual void BeginPackage (const std::string &name ) = 0;
86
87     /// Ends a package block
88     virtual void EndPackage () = 0;
89
90     /// Starts the definition of a new ComplexBlackBox in package pack
91     /// scriptfilename is the file from which the def is read
92     virtual void Define (const std::string &name,
93                  const std::string& pack,
94                  const std::string &scriptfilename) = 0;
95  
96     /// Sets the file name to use for the current definition
97     /// (Used to set it after the Define command)
98     virtual void SetCurrentFileName (const std::string &name ) = 0;
99
100     /// End the definition of a ComplexBlackBox
101     virtual void EndDefine () = 0;
102
103     /// Sets the kind of the currently defined ComplexBlackBox
104     virtual void Kind(const std::string& kind) = 0;
105
106     /// Creates a new black box in current complex box
107     virtual void Create ( const std::string& boxType, const std::string&
108     boxName) = 0;
109
110     /// Destroys a black box
111     virtual void Destroy (const std::string &boxName) = 0;
112
113     /// Connects the output boxOutput to the input boxInput
114     virtual void Connect (const std::string &boxfrom,
115                   const std::string &output,
116                   const std::string &boxto,
117                   const std::string &input) = 0;
118
119     /// Executes the box 
120     virtual void Execute (const std::string &box) = 0;
121
122     /// Defines an input of the current complex box
123     virtual void DefineInput (const std::string &name,
124                       const std::string &box,
125                       const std::string &input,
126                       const std::string &help) = 0;
127
128     /// Defines an output of the current complex box
129     virtual void DefineOutput (const std::string &name,
130                        const std::string &box,
131                        const std::string &output,
132                        const std::string &help) = 0;     
133   
134     /// sets the input of the box with the value
135     virtual void Set (const std::string &box, 
136               const std::string &input, 
137               const std::string &value) = 0;
138
139     /// gets the output of the box
140     virtual std::string Get (const std::string &box, 
141                      const std::string &output) = 0;
142
143     /// changes the workspace name
144     virtual void SetWorkspaceName( const std::string& n ) = 0;
145
146     ///Adds the authorName to the Box author list
147     virtual void Author(const std::string &authorName) = 0;
148
149     ///Adds the categories to the Box categoris list
150     virtual void Category(const std::string &categories) = 0;
151
152     /// The description string which explains what does the ComplexBox
153     virtual void Description(const std::string &d) = 0;
154
155     /// prints the list off the boxes of the current box
156     virtual void PrintBoxes() = 0;
157
158    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
159     virtual std::string ShowGraph(const std::string &nameblackbox, 
160                           const std::string &detailStr, 
161                           const std::string &levelStr,
162                           const std::string &output_file,
163                           const std::string &custom_header,
164                           const std::string &custom_title,
165                           bool system_display = true) = 0;
166
167    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
168     virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0;
169
170     /// Description of the actual pipeline
171     virtual void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
172     
173     virtual void Reset() = 0;
174     
175     /// Sets the level of message for kind
176     virtual void SetMessageLevel(const std::string &kind, int level) = 0;
177     
178     /// Prints help on the messages
179     virtual void HelpMessages() = 0;
180
181     /// Prints the string ... MORE : TO EXPLAIN 
182     virtual void Print(const std::string & message) = 0;
183
184     virtual ComplexBlackBoxDescriptor::Pointer GetWorkspace() 
185     { return  ComplexBlackBoxDescriptor::Pointer(); }
186   
187   //  static const std::string& GetObjectDescription() = 0;
188   //  { static std::string s("VirtualExec"); return s; }
189   protected:
190
191   private:
192
193    /// The interpreter which uses it (0 if none)
194     InterpreterWeakPointer mInterpreter;
195
196   };
197 }
198 #endif