]> 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/04/08 06:59:30 $
7   Version:   $Revision: 1.9 $
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     /// Sets the kind of the currently defined ComplexBlackBox
95     void Kind(const std::string& kind);
96
97     /// Creates a new black box in current complex box
98     void Create ( const std::string& boxType, const std::string& boxName);
99
100     /// Destroys a black box
101     void Destroy (const std::string &boxName);
102
103     /// Connects the output boxOutput to the input boxInput
104     void Connect (const std::string &boxfrom,
105                   const std::string &output,
106                   const std::string &boxto,
107                   const std::string &input);
108
109     /// Updates the box 
110     void Execute(const std::string &box);
111
112     /// Defines an input of the current complex box
113     void DefineInput (const std::string &name,
114                       const std::string &box,
115                       const std::string &input,
116                       const std::string &help);
117
118     /// Defines an output of the current complex box
119     void DefineOutput (const std::string &name,
120                        const std::string &box,
121                        const std::string &output,
122                        const std::string &help);     
123   
124     /// sets the input of the box with the value
125     void Set (const std::string &box, 
126               const std::string &input, 
127               const std::string &value);
128
129     /// gets the output of the box
130     std::string Get (const std::string &box, 
131                      const std::string &output);
132
133     /// changes the workspace name
134     void SetWorkspaceName( const std::string& n );
135
136     ///Adds the authorName to the Box author list
137     void Author(const std::string &authorName);
138
139     ///Adds the Categories to the Box category list
140     void Category(const std::string &category);
141
142     /// The description string which explains what does the ComplexBox
143     void Description(const std::string & d);
144
145     /// prints the list off the boxes of the current box
146     void PrintBoxes();
147
148    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
149     std::string ShowGraph(const std::string &nameblackbox, 
150                           const std::string &detailStr, 
151                           const std::string &levelStr,
152                           const std::string &output_file,
153                           const std::string &custom_header,
154                           const std::string &custom_title,
155                           bool system_display = true);
156
157    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
158     std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
159
160    /// Description of the actual pipeline
161       void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
162
163       void Reset();
164  
165   /// Sets the level of message for kind
166     void SetMessageLevel(const std::string &kind,
167                          int level);
168
169    /// Prints help on the messages
170     void HelpMessages();
171     
172     /// Prints the string ... MORE : TO EXPLAIN 
173     void Print(const std::string & message);
174
175   //  static const std::string& GetObjectDescription()
176   //  { static std::string s("Executer"); return s; }
177
178   protected:
179
180   private:
181
182     /// The input values of the Root ComplexBlackBox
183     std::map<std::string,std::string> mInputs;
184     
185     /// no exec mode flag
186     bool mNoExecMode;
187
188     /// Dialog mode
189     DialogModeType mDialogMode;
190     
191     /// File Pointer, to hold generated C++ code.
192     // std::ofstream *m_Fp;
193     std::ofstream m_Fp;
194   };
195 }
196 #endif