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