]> Creatis software - bbtk.git/blob - kernel/src/bbtkTranscriptor.h
=== MAJOR RELEASE ====
[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/18 12:59:16 $
7   Version:   $Revision: 1.10 $
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     bool GetNoExecMode() const { return mNoExecMode; }
62
63     /// Sets the mode of dialog of the executer for Root inputs 
64     void SetDialogMode(DialogModeType t) { mDialogMode = t; }
65
66     /// Loads a package
67     void LoadPackage(const std::string &name );
68
69     /// Unloads a package
70     void UnLoadPackage(const std::string &name );
71
72     /// Starts a package block  
73     void BeginPackage (const std::string &name );
74
75     /// Ends a package block
76     void EndPackage ();
77
78     /// Starts the definition of a new ComplexBlackBox in package pack
79     /// scriptfilename is the file from which the def is read
80     void Define (const std::string &name,
81                  const std::string& pack,
82                  const std::string &scriptfilename);
83
84     /// Sets the file name to use for the current definition
85     /// (Used to set it after the Define command)
86     void SetCurrentFileName (const std::string &name );
87
88     /// End the definition of a ComplexBlackBox
89     void EndDefine ();
90
91     /// Sets the kind of the currently defined ComplexBlackBox
92     void Kind(const std::string& kind);
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     /// Constructor
179     Transcriptor(const std::string& filename);
180
181     /// The input values of the Root ComplexBlackBox
182     std::map<std::string,std::string> mInputs;
183     
184     /// no exec mode flag
185     bool mNoExecMode;
186
187     /// Dialog mode
188     DialogModeType mDialogMode;
189     
190     /// File Pointer, to hold generated C++ code.
191     // std::ofstream *m_Fp;
192     std::ofstream m_Fp;
193   };
194 }
195 #endif