1 /*=========================================================================
3 Module: $RCSfile: bbtkBlackBoxDescriptor.h,v $
5 Date: $Date: 2008/10/17 08:18:12 $
6 Version: $Revision: 1.11 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
34 * \brief Class bbtk::BlackBoxDescriptor : (abstract) describes of a BlackBox (name, description, author) and is able to create an instance of it.
37 * \class bbtk::BlackBoxDescriptor
38 * \brief (Abstract) Contains information on a BlackBox type (name, description, author, inputs, outputs) and is able to create an instance of it.
41 #ifndef __bbtkBlackBoxDescriptor_h__
42 #define __bbtkBlackBoxDescriptor_h__
44 #include "bbtkObject.h"
45 #include "bbtkBlackBoxInputDescriptor.h"
46 #include "bbtkBlackBoxOutputDescriptor.h"
55 BBTK_FORWARD_DECLARE_POINTER(BlackBox);
56 BBTK_FORWARD_DECLARE_POINTER(Package);
58 //==========================================================================
59 class BBTK_EXPORT BlackBoxDescriptor : public Object
61 BBTK_ABSTRACT_OBJECT_INTERFACE(BlackBoxDescriptor);
63 /// The type of descriptor of inputs
64 typedef BlackBoxInputDescriptor InputDescriptor;
65 /// The type of descriptor of outputs
66 typedef BlackBoxOutputDescriptor OutputDescriptor;
67 /// The type of dictionnary of inputs = map of input descriptors pointers
68 typedef std::map<std::string, InputDescriptor*> InputDescriptorMapType;
69 /// The type of dictionnary of outputs= map of output descriptors pointers
70 typedef std::map<std::string, OutputDescriptor*> OutputDescriptorMapType;
71 /// The kinds of black box
82 /// Releases a descriptor
83 // static void Release(BlackBoxDescriptor::WeakPointer);
85 /// Creates an instance with name boxname of the BlackBox
86 /// of which this is the descriptor
87 virtual BlackBoxPointer NewBlackBox(const std::string& boxname) = 0;
89 /// Returns the name of the **TYPE** of the black box
90 const std::string& GetTypeName() const { return mTypeName; }
92 /// Returns the full name of the **TYPE** of the black box (+package name)
93 std::string GetFullTypeName() const;
95 /// Returns the description of the BlackBox
96 const std::string& GetDescription() const { return mDescription; }
98 /// Returns the author(s) of the BlackBox
99 const std::string& GetAuthor() const { return mAuthor; }
101 /// Returns the category(s) of the BlackBox
102 const std::string& GetCategory() const { return mCategory; }
104 /// Returns the Package to which the box belongs (const pointer)
105 PackagePointer GetPackage() const { return mPackage; }
107 /// Returns the kind of box
108 Kind GetKind() const { return mKind; }
110 /// Prints help on the black box
111 virtual void GetHelp(bool full=true) const;
113 /// Returns a const ref on the map of input descriptors
114 const InputDescriptorMapType& GetInputDescriptorMap() const
117 /// Returns a const ref on the map of output descriptors
118 const OutputDescriptorMapType& GetOutputDescriptorMap() const
121 /// Returns a const pointer on the descriptor of the input of name <name>
122 const InputDescriptor* GetInputDescriptor(const std::string &name) const;
124 /// Returns a const pointer on the descriptor of the output of name <name>
125 const OutputDescriptor* GetOutputDescriptor(const std::string &name) const;
127 /// Sets the name of the **TYPE** of BlackBox
128 void SetTypeName( const std::string& name ) { mTypeName=name; }
130 /// Adds the string to the BlackBox description
131 void AddToDescription( const std::string&, bool clear = false );
133 /// Adds the string to the BlackBox author list
134 void AddToAuthor( const std::string&, bool clear = false );
136 /// Adds the string to the BlackBox category list
137 void AddToCategory( const std::string&, bool clear = false );
139 /// Sets the Package to which the box belongs
140 void SetPackage(PackagePointer package) { mPackage = package; }
142 /// Sets the kind of box
143 void SetKind(Kind kind) { mKind = kind; }
146 virtual void InsertHTMLGraph( std::ofstream& s, int detail, int level,
147 const std::string& output_dir = "" ) { }
149 /// Writes html formatted help into the output file stream.
150 /// detail and level are used for graphical representation of
151 /// complex black boxes (see ComplexBlackBox::InsertHTMLGraph)
152 /// output_dir is the directory in which to write auxilliary files
153 /// (.dot/.png/.cmap)
154 virtual void InsertHtmlHelp ( std::ofstream& s,
155 int detail, int level,
156 const std::string& output_dir = "",
157 bool relative_link = false );
159 virtual void Check(bool recursive=true) const;
162 /// Adds an input descriptor
163 void AddInputDescriptor( BlackBoxInputDescriptor *d )
164 { mInput[d->GetName()] = d; }
165 /// Adds an output descriptor
166 void AddOutputDescriptor( BlackBoxOutputDescriptor *d )
167 { mOutput[d->GetName()] = d; }
170 /// The name of the type of black box
171 std::string mTypeName;
172 /// The description of the black box
173 std::string mDescription;
174 /// The author of the black box
176 /// The category of the black box
177 std::string mCategory;
178 /// The kind of box (standard / adaptor)
180 /// The Package to which the box belongs
181 PackagePointer mPackage;
183 InputDescriptorMapType mInput;
185 OutputDescriptorMapType mOutput;
188 // class BlackBoxDescriptor
189 //==========================================================================