]> Creatis software - bbtk.git/blob - kernel/src/bbtkAtomicBlackBox.cxx
49dbcac191bea0843a08671c5a5cd8b25cf4ef4e
[bbtk.git] / kernel / src / bbtkAtomicBlackBox.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkAtomicBlackBox.cxx,v $
4   Language:  C++
5   Date:      $Date: 2009/05/28 08:12:05 $
6   Version:   $Revision: 1.13 $
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     bbtkBlackBoxDebugMessage("object",3,
46                      "==> AtomicBlackBox(\""
47                      <<name<<"\")"<<std::endl);
48   }
49   //========================================================================= 
50   
51   //=========================================================================
52   /// Constructor from an existing box (copy) with a new name 
53   AtomicBlackBox::AtomicBlackBox(AtomicBlackBox& from, 
54                 const std::string &name, 
55                 bool alloc)
56     : BlackBox(from,name)
57   {
58     bbtkBlackBoxDebugMessage("object",3,
59                              "==> AtomicBlackBox("
60                              <<from.bbGetFullName()<<",\""
61                              <<name<<"\")"<<std::endl);
62   }
63   //=========================================================================
64   
65   
66   //=========================================================================
67   ///  Destructor
68   AtomicBlackBox::~AtomicBlackBox()
69   {
70     bbtkBlackBoxDebugMessage("object",3,"==> ~AtomicBlackBox()"
71                      <<std::endl);
72     bbtkBlackBoxDebugMessage("object",3,"<== ~AtomicBlackBox()"
73                      <<std::endl);
74   } 
75   //=========================================================================
76   
77
78
79   
80   //=========================================================================
81   Data AtomicBlackBox::bbGetOutput( const std::string &name )
82   {
83     bbtkBlackBoxDebugMessage("data",7,
84                              "AtomicBlackBox::bbGetOutput(\""<<name<<"\")"
85                              <<std::endl);
86     
87     Data p = ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
88               ->GetOutputDescriptor(name))->GetGetFunctor()->Get(this);
89     
90     return p;
91   }
92   //=========================================================================
93   
94   
95   //=========================================================================
96   ///  Gets the input Data of a given name
97   Data AtomicBlackBox::bbGetInput( const std::string &name ) 
98   {
99     bbtkBlackBoxDebugMessage("data",7,
100                              "AtomicBlackBox::bbGetInput(\""<<name<<"\")"
101                              <<std::endl);  
102     
103     Data p = ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
104               ->GetInputDescriptor(name))->GetGetFunctor()->Get(this);
105     
106     return p;
107   }
108   //=========================================================================
109   
110   
111   //=========================================================================
112   ///  Sets the data of the output called <name>
113   void AtomicBlackBox::bbSetOutput( const std::string &name, Data data)
114   {
115     bbtkBlackBoxDebugMessage("data",7,
116             "AtomicBlackBox::bbSetOutput(\""<<name<<"\",data)"
117             <<std::endl); 
118     
119     ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
120         ->GetOutputDescriptor(name))->GetSetFunctor()->Set(this,data);
121     
122     bbtkDebugDecTab("Data",7);
123   }  
124   //=========================================================================
125   
126   
127   //=========================================================================
128   ///  Sets the data of the input called <name>
129   void AtomicBlackBox::bbSetInput(const std::string &name,
130                                   Data data, 
131                                   bool setModified )
132   {
133     bbtkBlackBoxDebugMessage("data",7,
134             "AtomicBlackBox::bbSetInput(\""<<name<<"\",data)"
135             <<std::endl);  
136     ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()->GetInputDescriptor(name))->GetSetFunctor()->Set(this,data);
137     
138     if (setModified) 
139       {
140         bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
141                                 MODIFIED);
142       }
143     
144   }
145   //=========================================================================
146   
147   //=========================================================================
148   ///  Sets the data of the input called <name>
149   void AtomicBlackBox::bbBruteForceSetInputPointer(const std::string &name, 
150                                                    void* data, 
151                                                    bool setModified
152                                                    )
153   {
154     bbtkBlackBoxDebugMessage("data",7,
155             "AtomicBlackBox::bbBruteForceSetInputPointer(\""
156             <<name<<"\",data)"
157             <<std::endl);  
158     ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
159         ->GetInputDescriptor(name))->GetSetFunctor()
160             ->BruteForceSetPointer(this,data);
161     
162     if (setModified) 
163       {
164         bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
165                                 MODIFIED);
166       }
167     
168   }
169   //=========================================================================
170  
171
172
173   //==========================================================================
174   std::string AtomicBlackBox::GetObjectInfo() const 
175   {
176     std::stringstream i;
177     return i.str();
178   }
179   //==========================================================================
180
181   //==========================================================================
182   size_t AtomicBlackBox::GetObjectSize() const 
183   {
184     return sizeof(*this);
185   }
186   //==========================================================================
187   
188   //==========================================================================
189   size_t AtomicBlackBox::GetObjectRecursiveSize() const 
190   {
191     size_t s = GetObjectSize();
192     return s;
193   }
194   //==========================================================================
195
196  
197 }
198 // EO namespace bbtk