]> Creatis software - bbtk.git/blob - kernel/src/bbtkTranscriptor.h
*** empty log message ***
[bbtk.git] / kernel / src / bbtkTranscriptor.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkTranscriptor.h,v $
4   Language:  C++
5   Date:      $Date: 2008/12/12 12:11:21 $
6   Version:   $Revision: 1.13 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32  *  \file 
33  *  \brief class Transcriptor: level 0 of script C++ translation (header)
34  */
35 /**
36  *  \class bbtk::Transcriptor 
37  *  \brief class Transcriptor: level 0 of script C++ translation 
38  */
39  
40 #ifndef __bbtkTranscriptor_h__
41 #define __bbtkTranscriptor_h__
42
43 #include "bbtkVirtualExec.h"
44
45 #include "bbtkSystem.h"
46 #include <iostream>
47
48 namespace bbtk
49 {
50
51   class /*BBTK_EXPORT*/ Transcriptor : public VirtualExec
52   {
53     BBTK_OBJECT_INTERFACE(Transcriptor);
54     typedef VirtualExec Superclass;
55   public:
56     static Pointer New(const std::string& filename);
57
58    
59     /// Sets the inputs of the workspace : 
60     void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
61
62     /// Puts the executer in "no exec" mode, 
63     /// which creates but does not execute pipelines 
64
65     //void SetNoExecMode(bool b) { mNoExecMode = b; }
66     void SetNoExecMode(bool b)
67     {
68        if (b)
69           m_Fp << "  e->SetNoExecMode(true);" << std::endl;
70        else
71           m_Fp << "  e->SetNoExecMode(false);" << std::endl;       
72     }
73
74     void SetNoErrorMode(bool b)
75     {
76        if (b)
77           m_Fp << "  e->SetNoErrorMode(true);" << std::endl;
78        else
79           m_Fp << "  e->SetNoErrorMode(false);" << std::endl;       
80     }
81
82     bool GetNoExecMode() const { return false; }
83     bool GetNoErrorMode() const { return false; }
84
85     /// Sets the mode of dialog of the executer for Root inputs 
86     void SetDialogMode(DialogModeType t) { mDialogMode = t; }
87
88     /// Loads a package
89     void LoadPackage(const std::string &name );
90
91     /// Unloads a package
92     void UnLoadPackage(const std::string &name );
93
94     /// Starts a package block  
95     void BeginPackage (const std::string &name );
96
97     /// Ends a package block
98     void EndPackage ();
99
100     /// Starts the definition of a new ComplexBlackBox in package pack
101     /// scriptfilename is the file from which the def is read
102     void Define (const std::string &name,
103                  const std::string& pack,
104                  const std::string &scriptfilename);
105
106     /// Sets the file name to use for the current definition
107     /// (Used to set it after the Define command)
108     void SetCurrentFileName (const std::string &name );
109
110     /// End the definition of a ComplexBlackBox
111     void EndDefine ();
112
113     /// Sets the kind of the currently defined ComplexBlackBox
114     void Kind(const std::string& kind);
115
116     /// Creates a new black box in current complex box
117     void Create ( const std::string& boxType, const std::string& boxName);
118
119     /// Destroys a black box
120     void Destroy (const std::string &boxName);
121
122     /// Clears the currently defined ComplexBlackBox
123     void Clear();
124
125     /// Connects the output boxOutput to the input boxInput
126     void Connect (const std::string &boxfrom,
127                   const std::string &output,
128                   const std::string &boxto,
129                   const std::string &input);
130
131     /// Updates the box 
132     void Execute(const std::string &box);
133
134     /// Defines an input of the current complex box
135     void DefineInput (const std::string &name,
136                       const std::string &box,
137                       const std::string &input,
138                       const std::string &help);
139
140     /// Defines an output of the current complex box
141     void DefineOutput (const std::string &name,
142                        const std::string &box,
143                        const std::string &output,
144                        const std::string &help);     
145   
146     /// sets the input of the box with the value
147     void Set (const std::string &box, 
148               const std::string &input, 
149               const std::string &value);
150
151     /// gets the output of the box
152     std::string Get (const std::string &box, 
153                      const std::string &output);
154
155     /// changes the workspace name
156     void SetWorkspaceName( const std::string& n );
157
158     ///Adds the authorName to the Box author list
159     void Author(const std::string &authorName);
160
161     ///Adds the Categories to the Box category list
162     void Category(const std::string &category);
163
164     /// The description string which explains what does the ComplexBox
165     void Description(const std::string & d);
166
167     /// prints the list off the boxes of the current box
168     void PrintBoxes();
169
170    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
171     std::string ShowGraph(const std::string &nameblackbox, 
172                           const std::string &detailStr, 
173                           const std::string &levelStr,
174                           const std::string &output_file,
175                           const std::string &custom_header,
176                           const std::string &custom_title,
177                           bool system_display = true);
178
179    /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
180     std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
181
182    /// Description of the actual pipeline
183       void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
184
185       void Reset();
186  
187   /// Sets the level of message for kind
188     void SetMessageLevel(const std::string &kind,
189                          int level);
190
191    /// Prints help on the messages
192     void HelpMessages();
193     
194     /// Prints the string ... MORE : TO EXPLAIN 
195     void Print(const std::string & message);
196
197   //  static const std::string& GetObjectDescription()
198   //  { static std::string s("Executer"); return s; }
199
200   protected:
201
202   private:
203     /// Constructor
204     Transcriptor(const std::string& filename);
205
206     /// The input values of the Root ComplexBlackBox
207     std::map<std::string,std::string> mInputs;
208     
209     /// Dialog mode
210     DialogModeType mDialogMode;
211     
212     /// File Pointer, to hold generated C++ code.
213     // std::ofstream *m_Fp;
214     std::ofstream m_Fp;
215   };
216 }
217 #endif