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