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