]> Creatis software - bbtk.git/blob - kernel/src/bbtkAtomicBlackBox.cxx
Feature #1774
[bbtk.git] / kernel / src / bbtkAtomicBlackBox.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 #                        pour la SantÈ)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and
11 #  abiding by the rules of distribution of free software. You can  use,
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B
13 #  license as circulated by CEA, CNRS and INRIA at the following URL
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability.
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
26
27
28
29 /*=========================================================================
30   Program:   bbtk
31   Module:    $RCSfile: bbtkAtomicBlackBox.cxx,v $
32   Language:  C++
33   Date:      $Date: 2012/11/16 08:49:01 $
34   Version:   $Revision: 1.14 $
35 =========================================================================*/
36
37
38
39 /**
40  *  \file 
41  *  \brief class bbtk::AtomicBlackBox : abstract user defined black boxes
42  */
43 #include "bbtkAtomicBlackBox.h"
44
45 namespace bbtk
46 {
47   
48   //=========================================================================
49   AtomicBlackBox::AtomicBlackBox(const std::string &name, bool alloc)
50     : BlackBox(name)
51   {
52     bbtkBlackBoxDebugMessage("object",3,
53                      "==> AtomicBlackBox(\""
54                      <<name<<"\")"<<std::endl);
55   }
56   //========================================================================= 
57   
58   //=========================================================================
59   /// Constructor from an existing box (copy) with a new name 
60   AtomicBlackBox::AtomicBlackBox(AtomicBlackBox& from, 
61                 const std::string &name, 
62                 bool alloc)
63     : BlackBox(from,name)
64   {
65     bbtkBlackBoxDebugMessage("object",3,
66                              "==> AtomicBlackBox("
67                              <<from.bbGetFullName()<<",\""
68                              <<name<<"\")"<<std::endl);
69   }
70   //=========================================================================
71   
72   
73   //=========================================================================
74   ///  Destructor
75   AtomicBlackBox::~AtomicBlackBox()
76   {
77     bbtkBlackBoxDebugMessage("object",3,"==> ~AtomicBlackBox()"
78                      <<std::endl);
79     bbtkBlackBoxDebugMessage("object",3,"<== ~AtomicBlackBox()"
80                      <<std::endl);
81   } 
82   //=========================================================================
83   
84
85
86   
87   //=========================================================================
88   Data AtomicBlackBox::bbGetOutput( const std::string &name )
89   {
90     bbtkBlackBoxDebugMessage("data",7,
91                              "AtomicBlackBox::bbGetOutput(\""<<name<<"\")"
92                              <<std::endl);
93     
94     Data p = ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
95               ->GetOutputDescriptor(name))->GetGetFunctor()->Get(this);
96     
97     return p;
98   }
99   //=========================================================================
100   
101   
102   //=========================================================================
103   ///  Gets the input Data of a given name
104   Data AtomicBlackBox::bbGetInput( const std::string &name ) 
105   {
106     bbtkBlackBoxDebugMessage("data",7,
107                              "AtomicBlackBox::bbGetInput(\""<<name<<"\")"
108                              <<std::endl);  
109     
110     Data p = ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
111               ->GetInputDescriptor(name))->GetGetFunctor()->Get(this);
112     
113     return p;
114   }
115   //=========================================================================
116   
117   
118   //=========================================================================
119   ///  Sets the data of the output called <name>
120   void AtomicBlackBox::bbSetOutput( const std::string &name, Data data)
121   {
122     bbtkBlackBoxDebugMessage("data",7,
123             "AtomicBlackBox::bbSetOutput(\""<<name<<"\",data)"
124             <<std::endl); 
125     
126     ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
127         ->GetOutputDescriptor(name))->GetSetFunctor()->Set(this,data);
128     
129     bbtkDebugDecTab("Data",7);
130   }  
131   //=========================================================================
132   
133   
134   //=========================================================================
135   ///  Sets the data of the input called <name>
136   void AtomicBlackBox::bbSetInput(const std::string &name,
137                                   Data data, 
138                                   bool setModified )
139   {
140     bbtkBlackBoxDebugMessage("data",7,
141             "AtomicBlackBox::bbSetInput(\""<<name<<"\",data)"
142             <<std::endl);  
143     ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()->GetInputDescriptor(name))->GetSetFunctor()->Set(this,data);
144     
145     if (setModified) 
146       {
147         bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
148                                 MODIFIED);
149       }
150     
151   }
152   //=========================================================================
153   
154   //=========================================================================
155   ///  Sets the data of the input called <name>
156   void AtomicBlackBox::bbBruteForceSetInputPointer(const std::string &name, 
157                                                    void* data, 
158                                                    bool setModified
159                                                    )
160   {
161     bbtkBlackBoxDebugMessage("data",7,
162             "AtomicBlackBox::bbBruteForceSetInputPointer(\""
163             <<name<<"\",data)"
164             <<std::endl);  
165     ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
166         ->GetInputDescriptor(name))->GetSetFunctor()
167             ->BruteForceSetPointer(this,data);
168     
169     if (setModified) 
170       {
171         bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
172                                 MODIFIED);
173       }
174     
175   }
176   //=========================================================================
177  
178
179
180   //==========================================================================
181   std::string AtomicBlackBox::GetObjectInfo() const 
182   {
183     std::stringstream i;
184     return i.str();
185   }
186   //==========================================================================
187
188   //==========================================================================
189   size_t AtomicBlackBox::GetObjectSize() const 
190   {
191     return sizeof(*this);
192   }
193   //==========================================================================
194   
195   //==========================================================================
196   size_t AtomicBlackBox::GetObjectRecursiveSize() const 
197   {
198     size_t s = GetObjectSize();
199     return s;
200   }
201   //==========================================================================
202
203  
204 }
205 // EO namespace bbtk