]> Creatis software - bbtk.git/blob - kernel/src/bbtkAtomicBlackBox.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkAtomicBlackBox.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkAtomicBlackBox.cxx,v $
4   Language:  C++
5   Date:      $Date: 2008/12/11 09:50:34 $
6   Version:   $Revision: 1.12 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31
32 /**
33  *  \file 
34  *  \brief class bbtk::AtomicBlackBox : abstract user defined black boxes
35  */
36 #include "bbtkAtomicBlackBox.h"
37
38 namespace bbtk
39 {
40   
41   //=========================================================================
42   AtomicBlackBox::AtomicBlackBox(const std::string &name, bool alloc)
43     : BlackBox(name)
44   {
45     bbtkDebugMessage("object",3,
46                      "==> AtomicBlackBox::AtomicBlackBox(\""
47                      <<name<<"\")"<<std::endl);
48     bbtkDebugMessage("object",3,
49                      "<== AtomicBlackBox::AtomicBlackBox(\""
50                      <<name<<"\")"<<std::endl);
51   }
52   //========================================================================= 
53   
54   //=========================================================================
55   /// Constructor from an existing box (copy) with a new name 
56   AtomicBlackBox::AtomicBlackBox(AtomicBlackBox& from, 
57                 const std::string &name, 
58                 bool alloc)
59     : BlackBox(from,name)
60   {
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);
69     
70   }
71   //=========================================================================
72   
73   
74   //=========================================================================
75   ///  Destructor
76   AtomicBlackBox::~AtomicBlackBox()
77   {
78     bbtkDebugMessage("object",3,"==> AtomicBlackBox::~AtomicBlackBox()"
79                      <<std::endl);
80     bbtkDebugMessage("object",3,"<== AtomicBlackBox::~AtomicBlackBox()"
81                      <<std::endl);
82   } 
83   //=========================================================================
84   
85
86
87   
88   //=========================================================================
89   Data AtomicBlackBox::bbGetOutput( const std::string &name )
90   {
91     bbtkDebugMessageInc("Data",7,
92             "AtomicBlackBox::bbGetOutput(\""<<name<<"\") ["
93             <<bbGetFullName()<<"]"
94             <<std::endl);
95     
96     Data p = ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
97                 ->GetOutputDescriptor(name))->GetGetFunctor()->Get(this);
98     
99     bbtkDebugDecTab("Data",7);
100     return p;
101   }
102   //=========================================================================
103   
104   
105   //=========================================================================
106   ///  Gets the input Data of a given name
107   Data AtomicBlackBox::bbGetInput( const std::string &name ) 
108   {
109     bbtkDebugMessageInc("Data",7,
110             "AtomicBlackBox::bbGetInput(\""<<name<<"\") ["
111             <<bbGetFullName()<<"]"
112             <<std::endl);  
113     
114     Data p = ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
115                 ->GetInputDescriptor(name))->GetGetFunctor()->Get(this);
116     
117     bbtkDebugDecTab("Data",7);
118     return p;
119   }
120   //=========================================================================
121   
122   
123   //=========================================================================
124   ///  Sets the data of the output called <name>
125   void AtomicBlackBox::bbSetOutput( const std::string &name, Data data)
126   {
127     bbtkDebugMessageInc("Data",7,
128             "AtomicBlackBox::bbSetOutput(\""<<name<<"\",data) ["
129             <<bbGetFullName()<<"]"
130             <<std::endl); 
131     
132     ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
133         ->GetOutputDescriptor(name))->GetSetFunctor()->Set(this,data);
134     
135     bbtkDebugDecTab("Data",7);
136   }  
137   //=========================================================================
138   
139   
140   //=========================================================================
141   ///  Sets the data of the input called <name>
142   void AtomicBlackBox::bbSetInput(const std::string &name,
143                                   Data data, 
144                                   bool setModified )
145   {
146     bbtkDebugMessageInc("data",7,
147             "AtomicBlackBox::bbSetInput(\""<<name<<"\",data) ["
148             <<bbGetFullName()<<"]"
149             <<std::endl);  
150     ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()->GetInputDescriptor(name))->GetSetFunctor()->Set(this,data);
151     
152     if (setModified) 
153       {
154         bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
155                                 MODIFIED);
156       }
157     
158     bbtkDebugDecTab("data",7);
159   }
160   //=========================================================================
161   
162   //=========================================================================
163   ///  Sets the data of the input called <name>
164   void AtomicBlackBox::bbBruteForceSetInputPointer(const std::string &name, 
165                                                    void* data, 
166                                                    bool setModified
167                                                    )
168   {
169     bbtkDebugMessageInc("data",7,
170             "AtomicBlackBox::bbBruteForceSetInputPointer(\""
171             <<name<<"\",data) ["
172             <<bbGetFullName()<<"]"
173             <<std::endl);  
174     ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
175         ->GetInputDescriptor(name))->GetSetFunctor()
176             ->BruteForceSetPointer(this,data);
177     
178     if (setModified) 
179       {
180         bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
181                                 MODIFIED);
182       }
183     
184     bbtkDebugDecTab("data",7);
185   }
186   //=========================================================================
187  
188
189
190   //==========================================================================
191   std::string AtomicBlackBox::GetObjectInfo() const 
192   {
193     std::stringstream i;
194     return i.str();
195   }
196   //==========================================================================
197
198   //==========================================================================
199   size_t AtomicBlackBox::GetObjectSize() const 
200   {
201     return sizeof(*this);
202   }
203   //==========================================================================
204   
205   //==========================================================================
206   size_t AtomicBlackBox::GetObjectRecursiveSize() const 
207   {
208     size_t s = GetObjectSize();
209     return s;
210   }
211   //==========================================================================
212
213  
214 }
215 // EO namespace bbtk