1 /*=========================================================================
3 Module: $RCSfile: bbtkAtomicBlackBox.h,v $
5 Date: $Date: 2008/11/25 11:17:13 $
6 Version: $Revision: 1.6 $
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 * ------------------------------------------------------------------------ */
32 /* ---------------------------------------------------------------------
34 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
35 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
37 * This software is governed by the CeCILL-B license under French law and
38 * abiding by the rules of distribution of free software. You can use,
39 * modify and/ or redistribute the software under the terms of the CeCILL-B
40 * license as circulated by CEA, CNRS and INRIA at the following URL
41 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
42 * or in the file LICENSE.txt.
44 * As a counterpart to the access to the source code and rights to copy,
45 * modify and redistribute granted by the license, users are provided only
46 * with a limited warranty and the software's author, the holder of the
47 * economic rights, and the successive licensors have only limited
50 * The fact that you are presently reading this means that you have had
51 * knowledge of the CeCILL-B license and that you accept its terms.
52 * ------------------------------------------------------------------------ */
58 * \brief class bbtk::AtomicBlackBox : ancestor of all user defined (concrete) black boxes which are atomic (vs. complex boxes which are made up of other (atomic or complex) boxes).
62 * \class bbtk::AtomicBlackBox
63 * \brief Ancestor of all user defined (concrete) black boxes which are atomic (vs. complex boxes which are made up of other (atomic or complex) boxes).
66 #ifndef __bbtkAtomicBlackBox_h__
67 #define __bbtkAtomicBlackBox_h__
69 #include "bbtkBlackBox.h"
70 #include "bbtkAtomicBlackBoxDescriptor.h"
76 //==================================================================
77 class BBTK_EXPORT AtomicBlackBox : public bbtk::BlackBox
79 //==================================================================
81 //==================================================================
82 bbtk::BlackBoxDescriptor::Pointer bbGetDescriptor() const
84 return bbmDescriptorPointer;
86 //==================================================================
87 /// Gets the output Data of a given label
88 Data bbGetOutput( const std::string &label );
89 /// Gets the input Data of a given label
90 Data bbGetInput( const std::string &label );
91 /// Sets the data of the output called <name>
92 void bbSetOutput( const std::string &name, Data data);
93 /// Sets the data of the input called <name>
94 void bbSetInput( const std::string &name, Data data,
95 bool setModified = true);
96 /// Sets the data of the input called <name>
97 void bbBruteForceSetInputPointer( const std::string &name,
99 bool setModified = true);
100 //==================================================================
102 //==================================================================
103 std::string GetObjectInfo() const;
104 size_t GetObjectSize() const;
105 size_t GetObjectRecursiveSize() const;
106 //==================================================================
108 //==================================================================
110 //==================================================================
111 /// Constructor with the AtomicBlackBox's instance name
112 AtomicBlackBox(const std::string &name, bool alloc = true);
113 /// Constructor from an existing box (copy) with a new instance name
114 AtomicBlackBox(AtomicBlackBox& from, const std::string &name,
116 //==================================================================
117 //==================================================================
119 virtual ~AtomicBlackBox();
120 //==================================================================
122 //==================================================================
124 virtual void bbLockDescriptor() = 0;
126 // virtual void bbReleaseDescriptor();
127 //==================================================================
130 //==================================================================
131 /// Recursive pipeline processing in backward direction
132 /// (recursion is in backward direction however execution always goes forward).
134 /// \returns The final status of the box (UPTODATE or MODIFIED)
136 /// First checks that re-processing is needed (either Status==MODIFIED or InputProcessMode==Always)
138 /// - updates its inputs by calling bbUpdateInputs (which recursively calls bbBackwardUpdate on upstream boxes)
139 /// - calls bbProcess which here simply calls the user callback bbUserProcess which does the actual processing.
140 /// bbProcess is overloaded in WxBlackBox to handle widget creation and show
141 virtual IOStatus bbBackwardUpdate(Connection::Pointer caller);
142 //==================================================================
144 //==================================================================
146 //==================================================================
147 /// Calls the user defined processing method.
148 /// Overloaded in WxBlackBox to handle widget creation and show
149 virtual void bbProcess() { this->bbUserProcess(); }
150 //==================================================================
152 //==================================================================
153 /// User callback which computes the outputs as a function of the inputs.
154 /// It is assumed to be deterministic and thus is only called is the inputs have changed
155 /// (i.e. if the black box is marked as modified)
156 virtual void bbUserProcess()
158 bbtkWarning("AtomicBlackBox::bbUserProcess() not overloaded for box '"
160 <<"' : the box does nothing. Is it a bug or a feature ?"
163 //==================================================================
165 //==================================================================
166 /// User callback called in the box contructor
167 virtual void bbUserConstructor() {}
168 /// User callback called in the box copy constructor
169 virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer) {}
170 /// User callback called in the box destructor
171 virtual void bbUserDestructor() {}
172 //==================================================================
174 //==================================================================
176 //==================================================================
177 /// Default constructor is private :
178 /// derived classes must use the constructor with the AtomicBlackBox's name
179 AtomicBlackBox() : BlackBox("") {}
180 //==================================================================
183 //==================================================================
184 // The pointer on the descriptor
185 bbtk::BlackBoxDescriptor::Pointer bbmDescriptorPointer;
186 //==================================================================
189 // Class AtomicBlackBox
190 //===========================================================================
198 #include "bbtkAtomicBlackBoxMacros.h"