1 /*=========================================================================
3 Module: $RCSfile: bbtkAtomicBlackBox.cxx,v $
5 Date: $Date: 2008/12/08 12:53:35 $
6 Version: $Revision: 1.11 $
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 void 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 : returning"<<std::endl);
104 bbSetExecuting(true);
105 bool wasExecuting = bbGlobalGetSomeBoxExecuting();
106 bbGlobalSetSomeBoxExecuting(true);
108 // Updates its inputs
109 IOStatus s = bbUpdateInputs();
111 if ( (s != UPTODATE) ||
112 bbBoxProcessModeIsAlways() )
117 // Displays the window (WxBlackbox)
118 bbShowWindow(caller);
120 // Update the I/O statuses
121 bbComputePostProcessStatus();
125 bbtkDebugMessage("process",5," -> Up-to-date : nothing to do"
129 bbtkDebugMessage("process",3,
130 "<= AtomicBlackBox::bbBackwardUpdate() ["
131 <<bbGetFullName()<<"]"<<std::endl);
133 bbSetExecuting(false);
134 bbGlobalSetSomeBoxExecuting(wasExecuting);
136 return; // bbGetStatus();
139 //=========================================================================
142 //=========================================================================
143 Data AtomicBlackBox::bbGetOutput( const std::string &name )
145 bbtkDebugMessageInc("Data",7,
146 "AtomicBlackBox::bbGetOutput(\""<<name<<"\") ["
147 <<bbGetFullName()<<"]"
150 Data p = ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
151 ->GetOutputDescriptor(name))->GetGetFunctor()->Get(this);
153 bbtkDebugDecTab("Data",7);
156 //=========================================================================
159 //=========================================================================
160 /// Gets the input Data of a given name
161 Data AtomicBlackBox::bbGetInput( const std::string &name )
163 bbtkDebugMessageInc("Data",7,
164 "AtomicBlackBox::bbGetInput(\""<<name<<"\") ["
165 <<bbGetFullName()<<"]"
168 Data p = ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
169 ->GetInputDescriptor(name))->GetGetFunctor()->Get(this);
171 bbtkDebugDecTab("Data",7);
174 //=========================================================================
177 //=========================================================================
178 /// Sets the data of the output called <name>
179 void AtomicBlackBox::bbSetOutput( const std::string &name, Data data)
181 bbtkDebugMessageInc("Data",7,
182 "AtomicBlackBox::bbSetOutput(\""<<name<<"\",data) ["
183 <<bbGetFullName()<<"]"
186 ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
187 ->GetOutputDescriptor(name))->GetSetFunctor()->Set(this,data);
189 bbtkDebugDecTab("Data",7);
191 //=========================================================================
194 //=========================================================================
195 /// Sets the data of the input called <name>
196 void AtomicBlackBox::bbSetInput(const std::string &name,
200 bbtkDebugMessageInc("data",7,
201 "AtomicBlackBox::bbSetInput(\""<<name<<"\",data) ["
202 <<bbGetFullName()<<"]"
204 ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()->GetInputDescriptor(name))->GetSetFunctor()->Set(this,data);
208 bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
212 bbtkDebugDecTab("data",7);
214 //=========================================================================
216 //=========================================================================
217 /// Sets the data of the input called <name>
218 void AtomicBlackBox::bbBruteForceSetInputPointer(const std::string &name,
223 bbtkDebugMessageInc("data",7,
224 "AtomicBlackBox::bbBruteForceSetInputPointer(\""
226 <<bbGetFullName()<<"]"
228 ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
229 ->GetInputDescriptor(name))->GetSetFunctor()
230 ->BruteForceSetPointer(this,data);
234 bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
238 bbtkDebugDecTab("data",7);
240 //=========================================================================
244 //==========================================================================
245 std::string AtomicBlackBox::GetObjectInfo() const
250 //==========================================================================
252 //==========================================================================
253 size_t AtomicBlackBox::GetObjectSize() const
255 return sizeof(*this);
257 //==========================================================================
259 //==========================================================================
260 size_t AtomicBlackBox::GetObjectRecursiveSize() const
262 size_t s = GetObjectSize();
265 //==========================================================================