1 /*=========================================================================
4 Module: $RCSfile: bbtkAtomicBlackBox.cxx,v $
6 Date: $Date: 2008/06/27 08:12:46 $
7 Version: $Revision: 1.7 $
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::AtomicBlackBox : abstract user defined black boxes
24 #include "bbtkAtomicBlackBox.h"
29 //=========================================================================
30 AtomicBlackBox::AtomicBlackBox(const std::string &name, bool alloc)
33 bbtkDebugMessage("object",3,
34 "==> AtomicBlackBox::AtomicBlackBox(\""
35 <<name<<"\")"<<std::endl);
36 bbtkDebugMessage("object",3,
37 "<== AtomicBlackBox::AtomicBlackBox(\""
38 <<name<<"\")"<<std::endl);
40 //=========================================================================
42 //=========================================================================
43 /// Constructor from an existing box (copy) with a new name
44 AtomicBlackBox::AtomicBlackBox(AtomicBlackBox& from,
45 const std::string &name,
49 bbtkDebugMessage("object",3,
50 "==>AtomicBlackBox::AtomicBlackBox("
51 <<from.bbGetFullName()<<",\""
52 <<name<<"\")"<<std::endl);
53 bbtkDebugMessage("object",3,
54 "<==AtomicBlackBox::AtomicBlackBox("
55 <<from.bbGetFullName()<<",\""
56 <<name<<"\")"<<std::endl);
59 //=========================================================================
62 //=========================================================================
64 AtomicBlackBox::~AtomicBlackBox()
66 bbtkDebugMessage("object",3,"==> AtomicBlackBox::~AtomicBlackBox()"
68 bbtkDebugMessage("object",3,"<== AtomicBlackBox::~AtomicBlackBox()"
71 //=========================================================================
75 //=========================================================================
76 /// Main processing method of the box.
77 IOStatus AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
79 bbtkDebugMessageInc("process",3,
80 "=> AtomicBlackBox::bbBackwardUpdate("
81 <<(caller?caller->GetFullName():"0")<<") ["
82 <<bbGetFullName()<<"]"<<std::endl);
84 bbtkDebugMessage("process",5,"Initial Status = "<<bbGetStatus()
86 bbtkDebugMessage("process",5,"BoxProcessMode = "
87 <<bbGetInputBoxProcessMode()<<std::endl);
90 if ( ( bbGetStatus() == MODIFIED ) ||
91 ( bbBoxProcessModeIsAlways() ) )
94 bbSetStatus(UPDATING);
96 bool wasExecuting = bbGlobalGetSomeBoxExecuting();
97 bbGlobalSetSomeBoxExecuting(true);
100 IOStatus s = bbUpdateInputs();
102 bbtkDebugMessage("process",6,"Inputs post-update status = "<<s<<std::endl);
103 // If all inputs are in UPTODATE post-update status
104 // and mProcessMode is not "Always"
105 // then the box is now UPTODATE
107 if ( ( s == UPTODATE ) &&
108 ( ! bbBoxProcessModeIsAlways() ) )
110 new_status = UPTODATE;
114 // else it remains MODIFIED
115 new_status = MODIFIED;
117 bbSetStatus(new_status);
122 // Displays the window (WxBlackbox)
123 bbShowWindow(caller);
125 bbGlobalSetSomeBoxExecuting(wasExecuting);
130 bbtkDebugMessage("process",5,"Up-to-date : nothing to do"<<std::endl);
133 bbtkDebugMessage("process",5,"Final Status = "
134 <<bbGetStatus()<<std::endl);
135 bbtkDebugMessage("process",3,
136 "<= AtomicBlackBox::bbBackwardUpdate() ["
137 <<bbGetFullName()<<"]"<<std::endl);
140 return bbGetStatus();
143 //=========================================================================
146 //=========================================================================
147 Data AtomicBlackBox::bbGetOutput( const std::string &name )
149 bbtkDebugMessageInc("Data",7,
150 "AtomicBlackBox::bbGetOutput(\""<<name<<"\") ["
151 <<bbGetFullName()<<"]"
154 Data p = ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
155 ->GetOutputDescriptor(name))->GetGetFunctor()->Get(this);
157 bbtkDebugDecTab("Data",7);
160 //=========================================================================
163 //=========================================================================
164 /// Gets the input Data of a given name
165 Data AtomicBlackBox::bbGetInput( const std::string &name )
167 bbtkDebugMessageInc("Data",7,
168 "AtomicBlackBox::bbGetInput(\""<<name<<"\") ["
169 <<bbGetFullName()<<"]"
172 Data p = ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
173 ->GetInputDescriptor(name))->GetGetFunctor()->Get(this);
175 bbtkDebugDecTab("Data",7);
178 //=========================================================================
181 //=========================================================================
182 /// Sets the data of the output called <name>
183 void AtomicBlackBox::bbSetOutput( const std::string &name, Data data)
185 bbtkDebugMessageInc("Data",7,
186 "AtomicBlackBox::bbSetOutput(\""<<name<<"\",data) ["
187 <<bbGetFullName()<<"]"
190 ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
191 ->GetOutputDescriptor(name))->GetSetFunctor()->Set(this,data);
193 bbtkDebugDecTab("Data",7);
195 //=========================================================================
198 //=========================================================================
199 /// Sets the data of the input called <name>
200 void AtomicBlackBox::bbSetInput(
201 const std::string &name,
205 bbtkDebugMessageInc("Data",7,
206 "AtomicBlackBox::bbSetInput(\""<<name<<"\",data) ["
207 <<bbGetFullName()<<"]"
209 ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()->GetInputDescriptor(name))->GetSetFunctor()->Set(this,data);
213 bbSetModifiedStatus();
216 bbtkDebugDecTab("Data",7);
218 //=========================================================================
220 //=========================================================================
221 /// Sets the data of the input called <name>
222 void AtomicBlackBox::bbBruteForceSetInputPointer
224 const std::string &name,
229 bbtkDebugMessageInc("Data",7,
230 "AtomicBlackBox::bbBruteForceSetInputPointer(\""
232 <<bbGetFullName()<<"]"
234 ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
235 ->GetInputDescriptor(name))->GetSetFunctor()
236 ->BruteForceSetPointer(this,data);
240 bbSetModifiedStatus();
243 bbtkDebugDecTab("Data",7);
245 //=========================================================================
249 //==========================================================================
250 std::string AtomicBlackBox::GetObjectInfo() const
255 //==========================================================================
257 //==========================================================================
258 size_t AtomicBlackBox::GetObjectSize() const
260 return sizeof(*this);
262 //==========================================================================
264 //==========================================================================
265 size_t AtomicBlackBox::GetObjectRecursiveSize() const
267 size_t s = GetObjectSize();
270 //==========================================================================