1 /*=========================================================================
4 Module: $RCSfile: bbtkComplexBlackBox.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 =========================================================================*/
22 * \brief class bbtk::ComplexBlackBox : user defined complex black boxes
26 * \class bbtk::ComplexBlackBox
27 * \brief Abstract user defined black boxes
30 #ifndef __bbtkComplexBlackBox_h__
31 #define __bbtkComplexBlackBox_h__
33 #include "bbtkBlackBox.h"
34 #include "bbtkComplexBlackBoxDescriptor.h"
35 //#include "bbtkComplexBlackBoxInputDescriptor.h"
36 //#include "bbtkComplexBlackBoxOutputDescriptor.h"
44 //==================================================================
45 class BBTK_EXPORT ComplexBlackBox : public bbtk::BlackBox
47 friend class ComplexBlackBoxDescriptor;
49 //==================================================================
50 // PUBLIC PART : ACCESSIBLE TO THE END-USER
51 /// Returns the pointer on the box' descriptor
52 BlackBoxDescriptor* bbGetDescriptor() const { return mDescriptor; }
53 /// Returns a pointer on a clone of the box with name <name>
54 BlackBox* bbClone(const std::string& name);
56 void bbExecute(bool force = false);
58 Data bbGetOutput( const std::string &label );
59 Data bbGetInput ( const std::string &label );
60 void bbSetOutput( const std::string &name, Data data);
61 void bbSetInput ( const std::string &name, Data data,
62 bool setModified = true);
63 void bbBruteForceSetInputPointer( const std::string &name,
65 bool setModified = true);
69 BlackBox* bbGetBlackBox( const std::string& name );
71 const std::map<std::string, BlackBox*>& bbGetBlackBoxMap()
76 void bbPrintBlackBoxes();
78 /// Generates a png image representing the pipeline graph of the
79 /// complex box and writes html code to insert it
80 /// into the output file stream.
82 /// level : depth of nested complex boxes graph development
83 /// (0:only this box level
84 /// output_dir is the directory in which to write the files
85 void bbInsertHTMLGraph( std::ofstream& s,
89 const std::string& output_dir,
92 /// Writes Graphviz-dot description in file.
93 /// Generates own description and recursively calls itself
94 /// on internal boxes with level-1
95 virtual void bbWriteDotFileBlackBox(FILE *ff,
96 BlackBox *parentblackbox,
97 int detail, int level,
101 virtual void bbWriteDotInputOutputName(FILE *ff,
103 int detail, int level);
105 virtual BlackBox *bbFindBlackBox(const std::string &blackboxname);
110 //==================================================================
111 // PROTECTED PART : ACCESSIBLE TO ComplexBlackBoxDescriptor
112 /// Constructor that takes the ComplexBlackBox name
113 ComplexBlackBox(const std::string &name, ComplexBlackBoxDescriptor* desc);
114 /// Constructor from an existing box (copy) with a new name
115 ComplexBlackBox(ComplexBlackBox& from, const std::string &name);
119 IOStatus bbBackwardUpdate(Connection* caller);
120 // void bbForwardUpdate(Connection* caller);
121 void bbSetModifiedStatus(BlackBoxInputConnector* c);
127 void bbAddBlackBox( BlackBox* );
128 void bbAddToExecutionList( const std::string& name );
129 void bbUnsafeAddBlackBox( BlackBox* );
130 void bbRemoveBlackBox( const std::string& name );
131 void bbAddConnection( Connection* );
133 // void RemoveConnection( );
135 BlackBox* bbUnsafeGetBlackBox( const std::string& name );
138 void bbAllocateConnectors();
139 void bbDesallocateConnectors();
142 //==================================================================
143 // PRIVATE PART : MEMBERS AND USEFULL INTERNAL METHODS
145 /// Default constructor : derived classes must use the constructor with the ComplexBlackBox's name
146 ComplexBlackBox() : BlackBox("") {}
148 /// The descriptor pointer
149 ComplexBlackBoxDescriptor* mDescriptor;
151 /// The type of map of black boxes
152 typedef std::map<std::string, BlackBox*> BlackBoxMapType;
153 /// The map of black boxes
154 BlackBoxMapType mBlackBoxMap;
157 /// The type of list of connections
158 typedef std::list<Connection*> ConnectionListType;
159 /// The list of connections
160 ConnectionListType mConnectionList;
162 /// The execution list
163 std::vector<std::string> mExecutionList;
166 // Class ComplexBlackBox
167 //===========================================================================
175 //#include "bbtkComplexBlackBoxMacros.h"