]> Creatis software - bbtk.git/blob - kernel/src/bbtkVirtualExec.h
Recreated the complete cvs tree because the project architecture deeply changed
[bbtk.git] / kernel / src / bbtkVirtualExec.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkVirtualExec.h,v $ $
5   Language:  C++
6   Date:      $Date: 2008/01/22 15:02:00 $
7   Version:   $Revision: 1.1.1.1 $
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 "bbtkComplexBlackBox.h"
32 #include "bbtkFactory.h"
33 #include <string>
34 #include <deque>
35
36 namespace bbtk
37 {
38
39   class /*BBTK_EXPORT*/ VirtualExec   // All methods are pure virtual
40   {
41
42   public:
43     typedef enum 
44     {
45        NoDialog,
46        TextDialog,
47        GraphicalDialog
48     }
49     DialogModeType;
50     
51 /*
52     /// Constructor
53     VirtualExec();
54
55     /// 
56     //  void SetFactory(Factory* f);
57       
58     /// Destructor
59     virtual ~VirtualExec() = 0;
60 */    
61     /// Sets the inputs of the workspace : 
62     virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
63
64     /// Puts the executer in "no exec" mode, 
65     /// which creates but does not execute pipelines 
66     virtual void SetNoExecMode(bool b) = 0;
67
68     virtual bool GetNoExecMode() const = 0;
69
70     /// Sets the mode of dialog of the executer for Root inputs 
71     virtual void SetDialogMode(DialogModeType t) = 0;
72
73     /// Starts the definition of a new ComplexBlackBox in package pack
74     /// scriptfilename is the file from which the def is read
75     virtual void Define (const std::string &name,
76                  const std::string& pack,
77                  const std::string &scriptfilename) = 0;
78
79     /// End the definition of a ComplexBlackBox
80     virtual void EndDefine () = 0;
81
82     /// Creates a new black box in current complex box
83     virtual void Create ( const std::string& boxType, const std::string&
84     boxName) = 0;
85
86     /// Destroys a black box
87     //virtual void Destroy (const std::string &boxName) = 0;
88
89     /// Connects the output boxOutput to the input boxInput
90     virtual void Connect (const std::string &boxfrom,
91                   const std::string &output,
92                   const std::string &boxto,
93                   const std::string &input) = 0;
94
95     /// Updates the box 
96     /// would 'Execute' be more meaningfull ?
97     virtual void Update (const std::string &box) = 0;
98
99     /// Defines an input of the current complex box
100     virtual void DefineInput (const std::string &name,
101                       const std::string &box,
102                       const std::string &input,
103                       const std::string &help) = 0;
104
105     /// Defines an output of the current complex box
106     virtual void DefineOutput (const std::string &name,
107                        const std::string &box,
108                        const std::string &output,
109                        const std::string &help) = 0;     
110   
111     /// sets the input of the box with the value
112     virtual void Set (const std::string &box, 
113               const std::string &input, 
114               const std::string &value) = 0;
115
116    /// gets the output of the box
117     virtual std::string Get (const std::string &box, 
118                      const std::string &output) = 0;
119
120     /// changes the workspace name
121     virtual void SetWorkspaceName( const std::string& n ) = 0;
122
123     ///Adds the authorName to the Box's author list
124     virtual void Author(const std::string &authorName) = 0;
125
126     /// The description string which explains what does the ComplexBox
127     virtual void Description(const std::string & d) = 0;
128
129     /// prints the list off the boxes of the current box
130     virtual void PrintBoxes() = 0;
131
132    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
133     virtual std::string ShowGraph(const std::string &nameblackbox, 
134                           const std::string &detailStr, 
135                           const std::string &levelStr,
136                           const std::string &output_file,
137                           const std::string &custom_header,
138                           const std::string &custom_title,
139                           bool system_display = true) = 0;
140
141         /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
142     virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0;
143
144 /// Description of the actual pipeline
145         virtual void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0;
146
147         virtual void Reset() = 0;
148 /*
149   //  static const std::string& GetObjectDescription() = 0;
150   //  { static std::string s("VirtualExec"); return s; }
151 */
152   protected:
153
154   private:
155
156     /// Gets the current working black box 
157     virtual ComplexBlackBoxDescriptor* Current() = 0;
158     
159     /// Returns true when we are inside a define/endefine block
160     //    virtual bool InDefinitionBlock() = 0;
161
162     //==================================================================
163     // ATTRIBUTES
164      
165     /// The factory used
166     //   Factory* mFactory;
167
168     /// The Root Package
169     Package* mPackage;
170     
171     /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
172     /// Its name in bbi is 'workspace'  
173     ComplexBlackBoxDescriptor* mRoot;
174     
175     /// Struct that stores info on user defined complex black boxes
176     struct CBBDefinition
177     {
178       ComplexBlackBoxDescriptor* box;
179       std::string package;
180       CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
181         : box(d), package(p) {}
182     };
183
184     /// The stack of current working ComplexBlackBox
185     /// (is a stack for nested definitions)
186     /// only contains the root when outside a define/endefine block
187     std::deque<CBBDefinition> mCurrent;
188
189     /// flag which is true when we are inside a Define/EndDefine block
190     //    bool mDefineFlag;
191     
192     /// The input values of the Root ComplexBlackBox
193     std::map<std::string,std::string> mInputs;
194     
195     /// no exec mode flag
196     bool mNoExecMode;
197
198     /// Dialog mode
199     DialogModeType mDialogMode;
200   };
201 }
202 #endif