1 /*=========================================================================
3 Module: $RCSfile: bbtkAtomicBlackBox.cxx,v $
5 Date: $Date: 2008/10/17 08:18:12 $
6 Version: $Revision: 1.8 $
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 bbtkDebugMessage("process",5,"Initial Status = "<<bbGetStatus()
98 bbtkDebugMessage("process",5,"BoxProcessMode = "
99 <<bbGetInputBoxProcessMode()<<std::endl);
102 if ( ( bbGetStatus() == MODIFIED ) ||
103 ( bbBoxProcessModeIsAlways() ) )
106 bbSetStatus(UPDATING);
108 bool wasExecuting = bbGlobalGetSomeBoxExecuting();
109 bbGlobalSetSomeBoxExecuting(true);
111 // Updates its inputs
112 IOStatus s = bbUpdateInputs();
114 bbtkDebugMessage("process",6,"Inputs post-update status = "<<s<<std::endl);
115 // If all inputs are in UPTODATE post-update status
116 // and mProcessMode is not "Always"
117 // then the box is now UPTODATE
119 if ( ( s == UPTODATE ) &&
120 ( ! bbBoxProcessModeIsAlways() ) )
122 new_status = UPTODATE;
126 // else it remains MODIFIED
127 new_status = MODIFIED;
129 bbSetStatus(new_status);
134 // Displays the window (WxBlackbox)
135 bbShowWindow(caller);
137 bbGlobalSetSomeBoxExecuting(wasExecuting);
142 bbtkDebugMessage("process",5,"Up-to-date : nothing to do"<<std::endl);
145 bbtkDebugMessage("process",5,"Final Status = "
146 <<bbGetStatus()<<std::endl);
147 bbtkDebugMessage("process",3,
148 "<= AtomicBlackBox::bbBackwardUpdate() ["
149 <<bbGetFullName()<<"]"<<std::endl);
152 return bbGetStatus();
155 //=========================================================================
158 //=========================================================================
159 Data AtomicBlackBox::bbGetOutput( const std::string &name )
161 bbtkDebugMessageInc("Data",7,
162 "AtomicBlackBox::bbGetOutput(\""<<name<<"\") ["
163 <<bbGetFullName()<<"]"
166 Data p = ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
167 ->GetOutputDescriptor(name))->GetGetFunctor()->Get(this);
169 bbtkDebugDecTab("Data",7);
172 //=========================================================================
175 //=========================================================================
176 /// Gets the input Data of a given name
177 Data AtomicBlackBox::bbGetInput( const std::string &name )
179 bbtkDebugMessageInc("Data",7,
180 "AtomicBlackBox::bbGetInput(\""<<name<<"\") ["
181 <<bbGetFullName()<<"]"
184 Data p = ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
185 ->GetInputDescriptor(name))->GetGetFunctor()->Get(this);
187 bbtkDebugDecTab("Data",7);
190 //=========================================================================
193 //=========================================================================
194 /// Sets the data of the output called <name>
195 void AtomicBlackBox::bbSetOutput( const std::string &name, Data data)
197 bbtkDebugMessageInc("Data",7,
198 "AtomicBlackBox::bbSetOutput(\""<<name<<"\",data) ["
199 <<bbGetFullName()<<"]"
202 ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
203 ->GetOutputDescriptor(name))->GetSetFunctor()->Set(this,data);
205 bbtkDebugDecTab("Data",7);
207 //=========================================================================
210 //=========================================================================
211 /// Sets the data of the input called <name>
212 void AtomicBlackBox::bbSetInput(
213 const std::string &name,
217 bbtkDebugMessageInc("Data",7,
218 "AtomicBlackBox::bbSetInput(\""<<name<<"\",data) ["
219 <<bbGetFullName()<<"]"
221 ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()->GetInputDescriptor(name))->GetSetFunctor()->Set(this,data);
225 bbSetModifiedStatus();
228 bbtkDebugDecTab("Data",7);
230 //=========================================================================
232 //=========================================================================
233 /// Sets the data of the input called <name>
234 void AtomicBlackBox::bbBruteForceSetInputPointer
236 const std::string &name,
241 bbtkDebugMessageInc("Data",7,
242 "AtomicBlackBox::bbBruteForceSetInputPointer(\""
244 <<bbGetFullName()<<"]"
246 ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
247 ->GetInputDescriptor(name))->GetSetFunctor()
248 ->BruteForceSetPointer(this,data);
252 bbSetModifiedStatus();
255 bbtkDebugDecTab("Data",7);
257 //=========================================================================
261 //==========================================================================
262 std::string AtomicBlackBox::GetObjectInfo() const
267 //==========================================================================
269 //==========================================================================
270 size_t AtomicBlackBox::GetObjectSize() const
272 return sizeof(*this);
274 //==========================================================================
276 //==========================================================================
277 size_t AtomicBlackBox::GetObjectRecursiveSize() const
279 size_t s = GetObjectSize();
282 //==========================================================================