1 /*=========================================================================
3 Module: $RCSfile: bbtkAtomicBlackBox.cxx,v $
5 Date: $Date: 2008/11/25 11:17:13 $
6 Version: $Revision: 1.10 $
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 * ------------------------------------------------------------------------ */
34 * \brief class bbtk::AtomicBlackBox : abstract user defined black boxes
36 #include "bbtkAtomicBlackBox.h"
41 //=========================================================================
42 AtomicBlackBox::AtomicBlackBox(const std::string &name, bool alloc)
45 bbtkDebugMessage("object",3,
46 "==> AtomicBlackBox::AtomicBlackBox(\""
47 <<name<<"\")"<<std::endl);
48 bbtkDebugMessage("object",3,
49 "<== AtomicBlackBox::AtomicBlackBox(\""
50 <<name<<"\")"<<std::endl);
52 //=========================================================================
54 //=========================================================================
55 /// Constructor from an existing box (copy) with a new name
56 AtomicBlackBox::AtomicBlackBox(AtomicBlackBox& from,
57 const std::string &name,
61 bbtkDebugMessage("object",3,
62 "==>AtomicBlackBox::AtomicBlackBox("
63 <<from.bbGetFullName()<<",\""
64 <<name<<"\")"<<std::endl);
65 bbtkDebugMessage("object",3,
66 "<==AtomicBlackBox::AtomicBlackBox("
67 <<from.bbGetFullName()<<",\""
68 <<name<<"\")"<<std::endl);
71 //=========================================================================
74 //=========================================================================
76 AtomicBlackBox::~AtomicBlackBox()
78 bbtkDebugMessage("object",3,"==> AtomicBlackBox::~AtomicBlackBox()"
80 bbtkDebugMessage("object",3,"<== AtomicBlackBox::~AtomicBlackBox()"
83 //=========================================================================
87 //=========================================================================
88 /// Main processing method of the box.
89 IOStatus AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
91 bbtkDebugMessageInc("process",3,
92 "=> AtomicBlackBox::bbBackwardUpdate("
93 <<(caller?caller->GetFullName():"0")<<") ["
94 <<bbGetFullName()<<"]"<<std::endl);
96 // If already executing : return
99 bbtkDebugMessage("process",3,
100 " -> already executing : bailing out"<<std::endl);
101 return bbGetStatus();
103 bbSetExecuting(true);
104 bool wasExecuting = bbGlobalGetSomeBoxExecuting();
105 bbGlobalSetSomeBoxExecuting(true);
107 bbtkDebugMessage("process",5,"Initial Status = "<<bbGetStatus()
109 bbtkDebugMessage("process",5,"BoxProcessMode = "
110 <<bbGetInputBoxProcessMode()<<std::endl);
113 if ( ( bbGetStatus() == MODIFIED ) ||
114 ( bbBoxProcessModeIsAlways() ) )
117 // bbSetStatus(UPDATING);
119 // Updates its inputs
120 IOStatus s = bbUpdateInputs();
122 bbtkDebugMessage("process",6,"=> AtomicBlackBox::bbBackwardUpdate("
123 <<(caller?caller->GetFullName():"0")<<") ["
124 <<bbGetFullName()<<"] : Inputs post-update status = "<<s<<std::endl);
125 // If all inputs are in UPTODATE post-update status
126 // and mProcessMode is not "Always"
127 // then the box is now UPTODATE
129 if ( ( s == UPTODATE ) &&
130 ( ! bbBoxProcessModeIsAlways() ) )
132 new_status = UPTODATE;
136 // else it remains MODIFIED
137 new_status = MODIFIED;
139 bbSetStatus(new_status);
144 // Displays the window (WxBlackbox)
145 bbShowWindow(caller);
151 bbtkDebugMessage("process",5,"Up-to-date : nothing to do"<<std::endl);
154 bbtkDebugMessage("process",5,"=> AtomicBlackBox::bbBackwardUpdate("
155 <<(caller?caller->GetFullName():"0")<<") ["
156 <<bbGetFullName()<<"] : Final Status = "
157 <<bbGetStatus()<<std::endl);
158 bbtkDebugMessage("process",3,
159 "<= AtomicBlackBox::bbBackwardUpdate() ["
160 <<bbGetFullName()<<"]"<<std::endl);
162 bbSetExecuting(false);
163 bbGlobalSetSomeBoxExecuting(wasExecuting);
165 return bbGetStatus();
168 //=========================================================================
171 //=========================================================================
172 Data AtomicBlackBox::bbGetOutput( const std::string &name )
174 bbtkDebugMessageInc("Data",7,
175 "AtomicBlackBox::bbGetOutput(\""<<name<<"\") ["
176 <<bbGetFullName()<<"]"
179 Data p = ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
180 ->GetOutputDescriptor(name))->GetGetFunctor()->Get(this);
182 bbtkDebugDecTab("Data",7);
185 //=========================================================================
188 //=========================================================================
189 /// Gets the input Data of a given name
190 Data AtomicBlackBox::bbGetInput( const std::string &name )
192 bbtkDebugMessageInc("Data",7,
193 "AtomicBlackBox::bbGetInput(\""<<name<<"\") ["
194 <<bbGetFullName()<<"]"
197 Data p = ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
198 ->GetInputDescriptor(name))->GetGetFunctor()->Get(this);
200 bbtkDebugDecTab("Data",7);
203 //=========================================================================
206 //=========================================================================
207 /// Sets the data of the output called <name>
208 void AtomicBlackBox::bbSetOutput( const std::string &name, Data data)
210 bbtkDebugMessageInc("Data",7,
211 "AtomicBlackBox::bbSetOutput(\""<<name<<"\",data) ["
212 <<bbGetFullName()<<"]"
215 ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
216 ->GetOutputDescriptor(name))->GetSetFunctor()->Set(this,data);
218 bbtkDebugDecTab("Data",7);
220 //=========================================================================
223 //=========================================================================
224 /// Sets the data of the input called <name>
225 void AtomicBlackBox::bbSetInput(
226 const std::string &name,
230 bbtkDebugMessageInc("data",7,
231 "AtomicBlackBox::bbSetInput(\""<<name<<"\",data) ["
232 <<bbGetFullName()<<"]"
234 ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()->GetInputDescriptor(name))->GetSetFunctor()->Set(this,data);
238 bbSetModifiedStatus();
241 bbtkDebugDecTab("data",7);
243 //=========================================================================
245 //=========================================================================
246 /// Sets the data of the input called <name>
247 void AtomicBlackBox::bbBruteForceSetInputPointer
249 const std::string &name,
254 bbtkDebugMessageInc("data",7,
255 "AtomicBlackBox::bbBruteForceSetInputPointer(\""
257 <<bbGetFullName()<<"]"
259 ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
260 ->GetInputDescriptor(name))->GetSetFunctor()
261 ->BruteForceSetPointer(this,data);
265 bbSetModifiedStatus();
268 bbtkDebugDecTab("data",7);
270 //=========================================================================
274 //==========================================================================
275 std::string AtomicBlackBox::GetObjectInfo() const
280 //==========================================================================
282 //==========================================================================
283 size_t AtomicBlackBox::GetObjectSize() const
285 return sizeof(*this);
287 //==========================================================================
289 //==========================================================================
290 size_t AtomicBlackBox::GetObjectRecursiveSize() const
292 size_t s = GetObjectSize();
295 //==========================================================================