]> Creatis software - bbtk.git/blob - kernel/src/bbtkComplexBlackBoxDescriptor.h
Recreated the complete cvs tree because the project architecture deeply changed
[bbtk.git] / kernel / src / bbtkComplexBlackBoxDescriptor.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkComplexBlackBoxDescriptor.h,v $
5   Language:  C++
6   Date:      $Date: 2008/01/22 15:02:00 $
7   Version:   $Revision: 1.1.1.1 $
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 /**
20  *  \file 
21  *  \brief Class bbtk::ComplexBlackBoxDescriptor : describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it.
22  */
23 /**
24  * \class bbtk::ComplexBlackBoxDescriptor
25  * \brief Describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it.
26  */
27
28 #ifndef __bbtkComplexBlackBoxDescriptor_h__
29 #define __bbtkComplexBlackBoxDescriptor_h__
30
31 #include "bbtkBlackBoxDescriptor.h"
32 #include "bbtkComplexBlackBoxInputDescriptor.h"
33 #include "bbtkComplexBlackBoxOutputDescriptor.h"
34 #include "bbtkFactory.h"
35 #include <fstream>
36
37 namespace bbtk
38 {
39
40   class ComplexBlackBox;
41   
42   //==========================================================================
43   class BBTK_EXPORT ComplexBlackBoxDescriptor : public bbtk::BlackBoxDescriptor
44   {
45   public:
46
47     /// Default ctor with name 
48     ComplexBlackBoxDescriptor(const std::string& name); //, Factory* f); 
49     /// Default dtor
50     ~ComplexBlackBoxDescriptor();
51     /// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor 
52     virtual BlackBox* CreateInstance(const std::string& name);
53
54     /// Adds a black box to the complex box
55     void Add ( const std::string& type,
56                const std::string& name
57                ); 
58     /// Connects two black boxes of the complex box
59     void Connect ( const std::string& from,
60                    const std::string& output,
61                    const std::string& to,
62                    const std::string& input
63                    ); 
64     /// Defines an input of the complex box
65     void DefineInput ( const std::string& name,
66                        const std::string& box,
67                        const std::string& input,
68                        const std::string& help);
69     /// Defines an output of the complex box
70     void DefineOutput ( const std::string& name,
71                        const std::string& box,
72                        const std::string& output,
73                        const std::string& help);
74  
75     /// Sets the name of the script file from which it is defined
76     void SetScriptFileName(const std::string& n) { mScriptFileName = n; }
77     /// Gets the name of the script file from which it is defined
78     std::string GetScriptFileName() const { return mScriptFileName; }
79    
80     /// 
81     void AddToExecutionList( const std::string& box );
82
83     ComplexBlackBox* GetPrototype() { return mPrototype; }
84     void PrintBlackBoxes(); 
85    
86     /// Prints help on the black box
87     void GetHelp(bool full=true) const;
88  
89     /// Writes html formatted help into the output file stream. 
90     /// detail and level are used for graphical representation of 
91     /// complex black boxes (see ComplexBlackBox::InsertHTMLGraph)
92     /// output_dir is the directory in which to write auxilliary files 
93     /// (.dot/.png/.cmap)
94     void InsertHtmlHelp ( std::ofstream& s, 
95                           int detail, int level,
96                           const std::string& output_dir = "",
97                           bool relative_link = false);
98
99     /// Generates a png image representing the pipeline graph of the 
100     /// complex box and writes html code to insert it 
101     /// into the output file stream. 
102     /// detail : 
103     /// level : depth of nested complex boxes graph development 
104     /// (0:only this box level 
105     /// output_dir is the directory in which to write the files 
106     /// (.dot/.png/.cmap)
107     void InsertHTMLGraph( std::ofstream& s, 
108                           int detail, int level, 
109                           const std::string& output_dir = "",
110                           bool relative_link = false );
111     
112
113
114   private:
115     /// Default ctor is private (must have name and factory)
116     ComplexBlackBoxDescriptor() {}
117     /// The complex box in which boxes and connections are stored
118     ComplexBlackBox* mPrototype;
119     /// The name of the script file from which it was created
120     std::string mScriptFileName;
121     
122   };
123   // class ComplexBlackBoxDescriptor
124   //==========================================================================
125
126
127  
128 }
129 // namespace bbtk
130 #endif