1 /*=========================================================================
4 Module: $RCSfile: bbtkBlackBoxDescriptor.h,v $
6 Date: $Date: 2008/01/22 15:02:00 $
7 Version: $Revision: 1.1 $
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.
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.
17 =========================================================================*/
21 * \brief Class bbtk::BlackBoxDescriptor : (abstract) describes of a BlackBox (name, description, author) and is able to create an instance of it.
24 * \class bbtk::BlackBoxDescriptor
25 * \brief (Abstract) Contains information on a BlackBox type (name, description, author, inputs, outputs) and is able to create an instance of it.
28 #ifndef __bbtkBlackBoxDescriptor_h__
29 #define __bbtkBlackBoxDescriptor_h__
31 #include "bbtkBlackBoxInputDescriptor.h"
32 #include "bbtkBlackBoxOutputDescriptor.h"
42 //==========================================================================
43 class BBTK_EXPORT BlackBoxDescriptor
46 /// The type of descriptor of inputs
47 typedef BlackBoxInputDescriptor InputDescriptor;
48 /// The type of descriptor of outputs
49 typedef BlackBoxOutputDescriptor OutputDescriptor;
50 /// The type of dictionnary of inputs = map of input descriptors pointers
51 typedef std::map<std::string, InputDescriptor*> InputDescriptorMapType;
52 /// The type of dictionnary of outputs= map of output descriptors pointers
53 typedef std::map<std::string, OutputDescriptor*> OutputDescriptorMapType;
54 /// The categories of black box
66 virtual ~BlackBoxDescriptor();
67 /// Creates an instance with name boxname of the BlackBox
68 /// of which this is the descriptor
69 virtual BlackBox* CreateInstance(const std::string& boxname) = 0;
71 /// Returns the name of the **TYPE** of the black box
72 const std::string& GetTypeName() const { return mTypeName; }
73 /// Returns the description of the BlackBox
74 const std::string& GetDescription() const { return mDescription; }
75 /// Returns the author(s) of the BlackBox
76 const std::string& GetAuthor() const { return mAuthor; }
77 /// Returns the Package to which the box belongs
78 Package* GetPackage() { return mPackage; }
79 /// Returns the Package to which the box belongs
80 const Package* GetPackage() const { return mPackage; }
81 /// Returns the category of box
82 Category GetCategory() const { return mCategory; }
85 /// Prints help on the black box
86 virtual void GetHelp(bool full=true) const;
88 /// Returns a const ref on the map of input descriptors
89 const InputDescriptorMapType& GetInputDescriptorMap() const
91 /// Returns a const ref on the map of output descriptors
92 const OutputDescriptorMapType& GetOutputDescriptorMap() const
94 /// Returns a const pointer on the descriptor of the input of name <name>
95 const InputDescriptor* GetInputDescriptor(const std::string & name) const;
96 /// Returns a const pointer on the descriptor of the output of name <name>
97 const OutputDescriptor* GetOutputDescriptor(const std::string & name) const;
99 /// Sets the name of the **TYPE** of BlackBox
100 void SetTypeName( const std::string& name ) { mTypeName=name; }
101 /// Adds the string to the BlackBox's description
102 void AddToDescription( const std::string&, bool clear = false );
103 /// Adds the string to the BlackBox's author list
104 void AddToAuthor( const std::string&, bool clear = false );
105 /// Sets the Package to which the box belongs
106 void SetPackage(Package *package) { mPackage = package; }
107 /// Sets the category of box
108 void SetCategory(Category category) { mCategory = category; }
111 virtual void InsertHTMLGraph( std::ofstream& s, int detail, int level,
112 const std::string& output_dir = "" ) { }
114 /// Writes html formatted help into the output file stream.
115 /// detail and level are used for graphical representation of
116 /// complex black boxes (see ComplexBlackBox::InsertHTMLGraph)
117 /// output_dir is the directory in which to write auxilliary files
118 /// (.dot/.png/.cmap)
119 virtual void InsertHtmlHelp ( std::ofstream& s,
120 int detail, int level,
121 const std::string& output_dir = "",
122 bool relative_link = false );
125 /// Adds an input descriptor
126 void AddInputDescriptor( BlackBoxInputDescriptor* d )
127 { mInput[d->GetName()] = d; }
128 /// Adds an output descriptor
129 void AddOutputDescriptor( BlackBoxOutputDescriptor* d )
130 { mOutput[d->GetName()] = d; }
133 /// The name of the type of black box
134 std::string mTypeName;
135 /// The description of the black box
136 std::string mDescription;
137 /// The author of the black box
139 /// The category of box
141 /// The Package to which the box belongs
144 InputDescriptorMapType mInput;
146 OutputDescriptorMapType mOutput;
149 // class BlackBoxDescriptor
150 //==========================================================================