]> Creatis software - bbtk.git/blob - kernel/src/bbtkItkBlackBoxMacros.h
98adfcbea37a4142295b1969b0bf046a7839c791
[bbtk.git] / kernel / src / bbtkItkBlackBoxMacros.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkItkBlackBoxMacros.h,v $
4   Language:  C++
5   Date:      $Date: 2009/05/28 08:12:06 $
6   Version:   $Revision: 1.7 $
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  *  \file 
35  *  \brief Defines macros for the creation of itk object inherited black boxes
36  */
37 #ifndef __bbtkItkBlackBoxMacros_h__
38 #define __bbtkItkBlackBoxMacros_h__
39 //===========================================================================
40 //============================================================================
41 // ITK Specific macros
42 //===========================================================================
43 //===========================================================================
44
45 //===========================================================================
46 #define BBTK_ITK_DELETE()                                               \
47   int bbDelete() {                                                      \
48     int refs = itkParent::GetReferenceCount()-1;                        \
49     itkParent::UnRegister();                                            \
50     return refs;                                                        \
51   }
52 //===========================================================================
53
54 //===========================================================================
55 #define BBTK_ITK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,ITKPARENT)    \
56   BBTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX);                       \
57   typedef ITKPARENT itkParent;                                          \
58   BBTK_ITK_DELETE();
59 //===========================================================================
60
61 //===========================================================================
62 /// Declares an itk-inherited AtomicBlackBox input 
63 #define BBTK_DECLARE_ITK_INPUT(NAME,TYPE)                               \
64   public:                                                               \
65   TYPE bbGetInput##NAME ()                                              \
66   { return itkParent::GetInput(); }                                     \
67   void bbSetInput##NAME (TYPE d)                                        \
68   { itkParent::SetInput(d);                                             \
69     /*bbSetModifiedStatus();*/ }                                                       
70 //===========================================================================
71
72 //===========================================================================
73 #define BBTK_DECLARE_ITK_OUTPUT(NAME,TYPE)                      \
74   public:                                                               \
75   TYPE bbGetOutput##NAME ()                                             \
76   { return itkParent::GetOutput(); }                                    \
77   void bbSetOutput##NAME (TYPE d)                                       \
78   { /*PARENT::GetOutput() = d;*/ }                                      
79 //===========================================================================
80
81 //===========================================================================
82 /// Declares an AtomicBlackBox input corresponding to an inherited itk parameter
83 /// which was declared by itkSetMacro/itkGetMacro
84 /// The NAME **MUST** be the same than the itk parameter name
85 #define BBTK_DECLARE_ITK_PARAM(NAME,TYPE)                       \
86   public:                                                               \
87   TYPE bbGetInput##NAME ()                                              \
88   { return itkParent::Get##NAME(); }                                    \
89   void bbSetInput##NAME (TYPE d)                                        \
90   { itkParent::Set##NAME(d);                                            \
91     /*bbSetModifiedStatus();*/ }
92 //===========================================================================
93
94 //============================================================================
95 /// Defines the default bbUserProcess method for itk inherited black boxes
96 /// (calls itkParent::Update)
97 #define BBTK_ITK_PROCESS()                                              \
98   public:                                                               \
99   inline void bbUserProcess()                                           \
100   {                                                                     \
101     bbtkBlackBoxDebugMessage("process",1,"**> Processing..."            \
102                              <<std::endl);                              \
103     itkParent::Update();                                                \
104     bbtkBlackBoxDebugMessage("process",2,"<** Processing"               \
105                              <<std::endl);                              \
106   }                                                             
107
108 //============================================================================
109
110 //===========================================================================
111 /// EOF
112 //===========================================================================
113 #endif