1 /*=========================================================================
4 Module: $RCSfile: bbtkComplexBlackBoxDescriptor.h,v $
6 Date: $Date: 2008/04/18 12:59:15 $
7 Version: $Revision: 1.5 $
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::ComplexBlackBoxDescriptor : describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it.
24 * \class bbtk::ComplexBlackBoxDescriptor
25 * \brief Describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it.
28 #ifndef __bbtkComplexBlackBoxDescriptor_h__
29 #define __bbtkComplexBlackBoxDescriptor_h__
31 #include "bbtkBlackBoxDescriptor.h"
32 #include "bbtkComplexBlackBoxInputDescriptor.h"
33 #include "bbtkComplexBlackBoxOutputDescriptor.h"
34 #include "bbtkFactory.h"
40 class ComplexBlackBox;
41 typedef boost::shared_ptr<ComplexBlackBox> ComplexBlackBoxPointer;
43 //==========================================================================
44 class BBTK_EXPORT ComplexBlackBoxDescriptor :
45 public bbtk::BlackBoxDescriptor
47 BBTK_OBJECT_INTERFACE(ComplexBlackBoxDescriptor);
48 typedef BlackBoxDescriptor Superclass;
50 friend class ComplexBlackBox;
52 static Pointer New(const std::string& name);
53 /// Sets the factory used
54 void SetFactory(Factory::Pointer f) { mFactory = f; }
55 /// Gets the factory used
56 Factory::Pointer GetFactory() const { return mFactory.lock(); }
58 /// Releases the descriptor
59 // void Release(bool release_package = true);
61 /// Gets the factory used (const)
62 // const Factory* GetFactory() const { return mFactory; }
64 /// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor
65 virtual BlackBoxPointer NewBlackBox(const std::string& name);
67 /// Adds a black box to the complex box
68 /// Needs a factory set !
69 void Add ( const std::string& type,
70 const std::string& name
73 /// Removes a black box from the complex box
74 void Remove( const std::string& name, bool remove_connections = true);
76 /// Connects two black boxes of the complex box
77 /// Needs a factory set !
78 void Connect ( const std::string& from,
79 const std::string& output,
80 const std::string& to,
81 const std::string& input
83 /// Defines an input of the complex box
84 void DefineInput ( const std::string& name,
85 const std::string& box,
86 const std::string& input,
87 const std::string& help);
88 /// Defines an output of the complex box
89 void DefineOutput ( const std::string& name,
90 const std::string& box,
91 const std::string& output,
92 const std::string& help);
95 /// Sets the name of the script file from which it is defined
96 void SetScriptFileName(const std::string& n) { mScriptFileName = n; }
97 /// Gets the name of the script file from which it is defined
98 std::string GetScriptFileName() const { return mScriptFileName; }
101 void AddToExecutionList( const std::string& box );
103 ComplexBlackBoxPointer GetPrototype() { return mPrototype; }
104 void PrintBlackBoxes();
106 /// Prints help on the black box
107 void GetHelp(bool full=true) const;
109 /// Writes html formatted help into the output file stream.
110 /// detail and level are used for graphical representation of
111 /// complex black boxes (see ComplexBlackBox::InsertHTMLGraph)
112 /// output_dir is the directory in which to write auxilliary files
113 /// (.dot/.png/.cmap)
114 void InsertHtmlHelp ( std::ofstream& s,
115 int detail, int level,
116 const std::string& output_dir = "",
117 bool relative_link = false);
119 /// Generates a png image representing the pipeline graph of the
120 /// complex box and writes html code to insert it
121 /// into the output file stream.
123 /// level : depth of nested complex boxes graph development
124 /// (0:only this box level
125 /// output_dir is the directory in which to write the files
126 /// (.dot/.png/.cmap)
127 void InsertHTMLGraph( std::ofstream& s,
128 int detail, int level,
129 const std::string& output_dir = "",
130 bool relative_link = false );
134 virtual void Check(bool recursive=true) const;
139 /// Default ctor with name is protected
140 ComplexBlackBoxDescriptor(const std::string& name);
144 Factory::WeakPointer mFactory;
145 /// The complex box in which boxes and connections are stored
146 ComplexBlackBoxPointer mPrototype;
147 /// The name of the script file from which it was created
148 std::string mScriptFileName;
151 // class ComplexBlackBoxDescriptor
152 //==========================================================================