]> Creatis software - bbtk.git/blob - kernel/src/bbtkAtomicBlackBox.h
*** empty log message ***
[bbtk.git] / kernel / src / bbtkAtomicBlackBox.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkAtomicBlackBox.h,v $
4   Language:  C++
5   Date:      $Date: 2008/12/11 09:50:34 $
6   Version:   $Revision: 1.8 $
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
34 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
35 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
36 *
37 *  This software is governed by the CeCILL-B license under French law and 
38 *  abiding by the rules of distribution of free software. You can  use, 
39 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
40 *  license as circulated by CEA, CNRS and INRIA at the following URL 
41 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
42 *  or in the file LICENSE.txt.
43 *
44 *  As a counterpart to the access to the source code and  rights to copy,
45 *  modify and redistribute granted by the license, users are provided only
46 *  with a limited warranty  and the software's author,  the holder of the
47 *  economic rights,  and the successive licensors  have only  limited
48 *  liability. 
49 *
50 *  The fact that you are presently reading this means that you have had
51 *  knowledge of the CeCILL-B license and that you accept its terms.
52 * ------------------------------------------------------------------------ */                                                                         
53
54
55
56 /**
57  *  \file 
58  *  \brief class bbtk::AtomicBlackBox : ancestor of all user defined (concrete) black boxes which are atomic (vs. ComplexBlackBox objects which are made up of other (atomic or complex) boxes).
59  */
60
61 /**
62  *  \class bbtk::AtomicBlackBox
63  *  \brief Ancestor of all user defined (concrete) black boxes which are atomic (vs. complex boxes which are made up of other (atomic or complex) boxes).
64  */
65  
66 #ifndef __bbtkAtomicBlackBox_h__
67 #define __bbtkAtomicBlackBox_h__
68
69 #include "bbtkBlackBox.h"
70 #include "bbtkAtomicBlackBoxDescriptor.h"
71
72 namespace bbtk
73 {
74
75  
76   //==================================================================
77   class BBTK_EXPORT AtomicBlackBox : public bbtk::BlackBox
78   {
79     //==================================================================
80   public: 
81     //==================================================================
82     bbtk::BlackBoxDescriptor::Pointer bbGetDescriptor() const
83     {
84       return bbmDescriptorPointer;
85     }
86     //==================================================================
87
88     //==================================================================
89     /// Gets the output Data of a given label
90     Data bbGetOutput( const std::string &label );
91     ///  Gets the input Data of a given label
92     Data bbGetInput( const std::string &label );
93     ///  Sets the data of the output called <name>
94     void bbSetOutput( const std::string &name, Data data);
95     ///  Sets the data of the input called <name>
96     void bbSetInput( const std::string &name, Data data, 
97                      bool setModified = true);
98     ///  Sets the data of the input called <name>
99     void bbBruteForceSetInputPointer( const std::string &name, 
100                                       void* data, 
101                                       bool setModified = true);
102     //==================================================================
103
104     //==================================================================
105     std::string GetObjectInfo() const;      
106     size_t GetObjectSize() const;
107     size_t GetObjectRecursiveSize() const;
108     //==================================================================
109
110     //==================================================================
111   protected:
112     //==================================================================
113     ///  Constructor with the AtomicBlackBox's instance name
114     AtomicBlackBox(const std::string &name, bool alloc = true);
115     /// Constructor from an existing box (copy) with a new instance name 
116     AtomicBlackBox(AtomicBlackBox& from, const std::string &name, 
117                  bool alloc = true);
118     ///  Destructor
119     virtual ~AtomicBlackBox();
120     /// 
121     virtual void bbLockDescriptor() = 0;
122     //==================================================================
123
124     //==================================================================
125     /// Calls the user defined processing method.
126     /// Overloaded in WxBlackBox to handle widget creation and show
127     virtual void bbProcess() { this->bbUserProcess(); }
128     //==================================================================
129
130     //==================================================================
131     /// User callback which computes the outputs as a function of the inputs. 
132     /// It is assumed to be deterministic and thus is only called 
133     /// if the inputs have changed 
134     virtual void bbUserProcess() 
135     {
136       bbtkWarning("AtomicBlackBox::bbUserProcess() not overloaded for box '"
137                   <<bbGetFullName()
138                   <<"' : the box does nothing. Is it a bug or a feature ?"
139                   <<std::endl);
140     }
141     //==================================================================
142
143     //==================================================================
144     /// User callback called in the box contructor
145     virtual void bbUserConstructor() {}
146     /// User callback called in the box copy constructor
147     virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer) {}
148     /// User callback called in the box destructor
149     virtual void bbUserDestructor() {}
150     //==================================================================    
151
152      //==================================================================
153   private:
154     //================================================================== 
155     /// Default constructor is private : 
156     /// derived classes must use the constructor with the AtomicBlackBox's name
157     AtomicBlackBox() : BlackBox("") {}
158     //================================================================== 
159
160   protected:
161     //================================================================== 
162     // The pointer on the descriptor
163     bbtk::BlackBoxDescriptor::Pointer bbmDescriptorPointer;  
164     //================================================================== 
165
166   };
167   // Class AtomicBlackBox
168   //====================================================================
169
170
171 }
172 // namespace bbtk
173
174
175 #include "bbtkAtomicBlackBoxMacros.h"
176
177 #endif
178