1 /*=========================================================================
4 Module: $RCSfile: bbtkUserBlackBox.h,v $
6 Date: $Date: 2008/01/22 15:41:34 $
7 Version: $Revision: 1.2 $
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::UserBlackBox : Ancestor of all user defined (concrete) black boxes
26 * \class bbtk::UserBlackBox
27 * \brief Ancestor of all user defined (concrete) black boxes.
30 #ifndef __bbtkUserBlackBox_h__
31 #define __bbtkUserBlackBox_h__
33 #include "bbtkBlackBox.h"
34 #include "bbtkUserBlackBoxDescriptor.h"
40 //==================================================================
41 class BBTK_EXPORT UserBlackBox : public bbtk::BlackBox
43 //==================================================================
45 //==================================================================
46 /// Gets the output Data of a given label
47 Data bbGetOutput( const std::string &label );
48 /// Gets the input Data of a given label
49 Data bbGetInput( const std::string &label );
50 /// Sets the data of the output called <name>
51 void bbSetOutput( const std::string &name, Data data);
52 /// Sets the data of the input called <name>
53 void bbSetInput( const std::string &name, Data data,
54 bool setModified = true);
55 /// Sets the data of the input called <name>
56 void bbBruteForceSetInputPointer( const std::string &name,
58 bool setModified = true);
59 //==================================================================
61 //==================================================================
63 virtual ~UserBlackBox();
64 //==================================================================
66 //==================================================================
68 //==================================================================
69 /// Constructor with the UserBlackBox's instance name
70 UserBlackBox(const std::string &name, bool alloc = true);
71 /// Constructor from an existing box (copy) with a new instance name
72 UserBlackBox(UserBlackBox& from, const std::string &name,
74 //==================================================================
77 //==================================================================
78 /// Recursive pipeline processing in backward direction
79 /// (recursion is in backward direction however execution always goes forward).
81 /// \returns The final status of the box (UPTODATE or MODIFIED)
83 /// First checks that re-processing is needed (either Status==MODIFIED or InputProcessMode==Always)
85 /// - updates its inputs by calling bbUpdateInputs (which recursively calls bbBackwardUpdate on amont boxes)
86 /// - calls bbProcess which here simply calls the user callback bbUserProcess which does the actual processing.
87 /// bbProcess is overloaded in WxBlackBox to handle widget creation and show
88 IOStatus bbBackwardUpdate(Connection* caller);
89 //==================================================================
91 //==================================================================
93 //==================================================================
94 /// Calls the user defined processing method.
95 /// Overloaded in WxBlackBox to handle widget creation and show
96 virtual void bbProcess() { this->bbUserProcess(); }
97 //==================================================================
99 //==================================================================
100 /// User callback which computes the outputs as a function of the inputs.
101 /// It is assumed to be deterministic and thus is only called is the inputs have changed
102 /// (i.e. if the black box is marked as modified)
103 virtual void bbUserProcess()
105 bbtkWarning("UserBlackBox::bbUserProcess() not overloaded for box '"
107 <<"' : the box does nothing. Is it a bug or a feature ?"
110 //==================================================================
112 //==================================================================
113 /// User callback called in the box contructor
114 virtual void bbUserConstructor() {}
115 /// User callback called in the box copy constructor
116 virtual void bbUserCopyConstructor() {}
117 /// User callback called in the box destructor
118 virtual void bbUserDestructor() {}
119 //==================================================================
121 //==================================================================
123 //==================================================================
124 /// Default constructor is private :
125 /// derived classes must use the constructor with the UserBlackBox's name
126 UserBlackBox() : BlackBox("") {}
127 //==================================================================
131 // Class UserBlackBox
132 //===========================================================================
140 #include "bbtkUserBlackBoxMacros.h"