]> Creatis software - bbtk.git/blob - kernel/src/bbtkAtomicBlackBoxMacros.h
46a6b954004c0cd49034270a0d7b7f112a6daae2
[bbtk.git] / kernel / src / bbtkAtomicBlackBoxMacros.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
5   Language:  C++
6   Date:      $Date: 2008/03/03 14:15:52 $
7   Version:   $Revision: 1.2 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19
20 /**
21  *  \file 
22  *  \brief Defines macros for the creation of new user black boxes
23  */
24 #ifndef __bbtkAtomicBlackBoxMacros_h__
25 #define __bbtkAtomicBlackBoxMacros_h__
26
27 //============================================================================
28 /// Declares the standard interface of a AtomicBlackBox 
29 /// (ctor, New, descriptor related methods)
30 #define BBTK_USER_BLACK_BOX_INTERFACE(CLASS,PARENT)                     \
31   private:                                                              \
32   inline static void bbCreateDescriptorIfNeeded();                      \
33   protected:                                                            \
34   CLASS(const std::string& name, bool allocate_connectors = true);      \
35   CLASS(CLASS& from, const std::string& name,                           \
36         bool allocate_connectors = true);                               \
37   ~CLASS();                                                             \
38   public: \
39   inline static CLASS* bbNew(const std::string& name)                   \
40   {                                                                     \
41     bbtkDebugMessageInc("Kernel",9,#CLASS<<"::bbNew(\""<<name<<"\")"<<std::endl); \
42     bbCreateDescriptorIfNeeded();                                       \
43     CLASS* c = new CLASS(name);                                         \
44     bbtkDebugDecTab("Kernel",9);                                                \
45     return c;                                                           \
46   }                                                                     \
47   inline bbtk::BlackBox* bbClone(const std::string& name)               \
48   {                                                                     \
49     bbtkDebugMessageInc("Kernel",9,#CLASS<<"::bbClone(\""<<name<<"\")"<<std::endl); \
50     bbCreateDescriptorIfNeeded();                                       \
51     CLASS* c = new CLASS(*this,name);                                   \
52     bbtkDebugDecTab("Kernel",9);                                                \
53     return c;                                                           \
54   }                                                                     \
55   bbtk::BlackBoxDescriptor* bbGetDescriptor() const                     \
56   {                                                                     \
57     return (bbtk::BlackBoxDescriptor*)bbDescriptor();                   \
58   }                                                                     \
59   static bbtk::BlackBoxDescriptor* bbDescriptor()                       \
60   {                                                                     \
61     bbCreateDescriptorIfNeeded();                                       \
62     return bbDescriptorPointer();                                       \
63   }                                                                     \
64   private:                                                              \
65   CLASS() : PARENT("") {}                                               \
66   static bbtk::BlackBoxDescriptor*& bbDescriptorPointer()               \
67   {                                                                     \
68     static bbtk::BlackBoxDescriptor* d = 0;                             \
69     return d;                                                           \
70   }                                                                     
71 //============================================================================
72
73
74 //============================================================================
75 /// Defines the bbUserProcess method
76 #define BBTK_PROCESS(CALLBACK)                                          \
77   public:                                                               \
78   inline void bbUserProcess()                                           \
79   {                                                                     \
80     bbtkDebugMessageInc("Process",1,"=> "<<bbGetTypeName()<<"::bbUserProcess() [" \
81                         <<bbGetFullName()<<"]"<<std::endl);             \
82     CALLBACK();                                                         \
83     bbtkDebugMessageDec("Process",1,"<= "<<bbGetTypeName()<<"::bbUserProcess() [" \
84                         <<bbGetFullName()<<"]"<<std::endl);             \
85   }
86 //============================================================================
87
88
89 //============================================================================
90 /// Declares a new AtomicBlackBox input (to be put in the class interface)
91 #define BBTK_DECLARE_INPUT(NAME,TYPE)                                   \
92   protected:                                                            \
93   TYPE bbmInput##NAME;                                                  \
94   public:                                                               \
95   TYPE bbGetInput##NAME ()                                              \
96   { return bbmInput##NAME; }                                            \
97   void bbSetInput##NAME (TYPE d)                                        \
98   { bbmInput##NAME = d;                                                 \
99     /*bbSetModifiedStatus();*/ }                                
100 //============================================================================
101
102 //============================================================================
103 /// Declares a new AtomicBlackBox output (to be put in the class interface)
104 #define BBTK_DECLARE_OUTPUT(NAME,TYPE)                                  \
105   protected:                                                            \
106   TYPE bbmOutput##NAME;                                                 \
107   public:                                                               \
108   TYPE bbGetOutput##NAME ()                                             \
109   { return bbmOutput##NAME; }                                           \
110   void  bbSetOutput##NAME (TYPE d)                                      \
111   { bbmOutput##NAME = d; }                                      
112 //============================================================================
113
114 //============================================================================
115 /// Declares an inherited AtomicBlackBox input (to be put in the class interface)
116 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD)     \
117   public:                                                               \
118   TYPE bbGetInput##NAME ()                                              \
119   { return GETMETHOD(); }                                               \
120   void bbSetInput##NAME (TYPE d)                                        \
121   { SETMETHOD(d);                                                       \
122     /*bbSetModifiedStatus();*/ }                        
123 //============================================================================
124
125
126 //============================================================================
127 /// Declares an inherited AtomicBlackBox output (to be put in the class interface)
128 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD)    \
129   public:                                                               \
130   TYPE bbGetOutput##NAME () const                                       \
131   { return GETMETHOD(); }                                               \
132   void bbSetOutput##NAME (TYPE d)                                       \
133   { SETMETHOD(d); }                                                     
134 //============================================================================
135
136
137
138 //============================================================================
139 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC)                   \
140   bbtkDebugMessageInc("Kernel",7,#CLASS<<"::"<<#CLASS                   \
141                       <<"(\""<<bbGetName()<<"\")"<<std::endl);          \
142   if (ALLOC) bbAllocateConnectors();                                    
143 //============================================================================
144
145 //============================================================================
146 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC)         \
147   bbtkDebugMessageInc("Kernel",7,#CLASS<<"::"<<#CLASS                   \
148                       <<"("<<FROM.bbGetFullName()<<",\""                \
149                       <<bbGetName()<<"\")"<<std::endl);                 \
150   if (ALLOC)                                                            \
151     {                                                                   \
152       bbAllocateConnectors();                                           \
153       bbCopyIOValues(FROM);                                             \
154    }
155 //============================================================================
156
157
158 //============================================================================
159 #define BBTK_END_BLACK_BOX_CONSTRUCTOR          \
160   bbtkDebugDecTab("Kernel",7)
161 //============================================================================
162
163 //============================================================================
164 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS)                          \
165   bbtkDebugMessageInc("Kernel",7,#CLASS <<"::~"<< #CLASS                        \
166                       <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
167 //============================================================================
168
169
170
171
172 //============================================================================
173 #define BBTK_END_BLACK_BOX_DESTRUCTOR           \
174   bbtkDebugDecTab("Kernel",7)
175 //============================================================================
176
177
178 //============================================================================
179 /// AtomicBlackBox std implementation of ctor and dtor
180 #define BBTK_USER_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT)                \
181   CLASS::CLASS(const std::string& name, bool allocate_connectors)       \
182     : PARENT(name,false)                                                \
183   {                                                                     \
184     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors);        \
185     CLASS::bbUserConstructor();                                         \
186     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
187   }                                                                     \
188   CLASS::CLASS(CLASS& from,                                             \
189                const std::string& name, bool allocate_connectors)       \
190     : PARENT(from,name,false)                                           \
191   {                                                                     \
192     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
193     CLASS::bbUserCopyConstructor();                                     \
194     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
195   }                                                                     \
196   CLASS::~CLASS()                                                       \
197   {                                                                     \
198     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
199     CLASS::bbUserDestructor();                                          \
200     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
201   }                                                                     
202 //============================================================================
203
204
205 //============================================================================
206 /// Begins the AtomicBlackBox description block
207 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT)                     \
208   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
209   {                                                                     \
210   public:                                                               \
211     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
212     {                                                                   \
213       return CLASS::bbNew(name);                                        \
214     }                                                                   \
215     CLASS ## Descriptor()                                               \
216       {                                                                 \
217         bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS   \
218                             <<"Descriptor()"<<std::endl)
219 //============================================================================
220
221 //============================================================================
222 /// Ends the AtomicBlackBox description block
223 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS)                              \
224   bbtkDecTab("Kernel",9);                                                       \
225   }                                                                     \
226   };                                                                    \
227   void CLASS::bbCreateDescriptorIfNeeded()                              \
228   {                                                                     \
229     if ( !bbDescriptorPointer() )                                       \
230       bbDescriptorPointer() = new CLASS ## Descriptor;                  \
231   }
232 //============================================================================
233
234
235 //============================================================================
236 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
237 #define BBTK_NAME(NAME) SetTypeName(NAME)
238 //============================================================================
239
240 //============================================================================
241 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
242 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
243 //============================================================================
244
245 //============================================================================
246 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
247 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
248 //============================================================================
249
250 //============================================================================
251 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
252 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
253 //============================================================================
254
255 //============================================================================
256 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
257 //#define BBTK_KIND(KIND) SetKind(KIND)
258 //============================================================================
259
260 //============================================================================
261 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
262 #define BBTK_ADAPTOR()                        \
263   SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
264   AddToCategory("adaptor")
265 //============================================================================
266
267 //============================================================================
268 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
269 #define BBTK_DEFAULT_ADAPTOR()                          \
270   SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR);   \
271   AddToCategory("adaptor")
272 //============================================================================
273
274 //============================================================================
275 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
276 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE)                               \
277   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
278                      (typeid(CLASS ## Descriptor),                      \
279                       #NAME,DESCR,                                      \
280                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
281                       (&CLASS::bbGetInput##NAME),                       \
282                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
283                       (&CLASS::bbSetInput##NAME) ) )
284 //============================================================================
285
286 //============================================================================
287 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
288 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE)                              \
289   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
290                       (typeid(CLASS ## Descriptor),#NAME,DESCR,                         \
291                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
292                        (&CLASS::bbGetOutput##NAME),                     \
293                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
294                        (&CLASS::bbSetOutput##NAME) ) )
295 //============================================================================
296
297 //============================================================================
298 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
299 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE)                        \
300   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
301                      (typeid(CLASS ## Descriptor),#NAME,DESCR,                                  \
302                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
303                       (&CLASS::bbGetInput##NAME),                       \
304                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
305                       (&CLASS::bbSetInput##NAME),                       \
306                       false) )
307 //============================================================================
308
309 //============================================================================
310 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
311 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE)                       \
312   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
313                       (typeid(CLASS ## Descriptor),#NAME,DESCR,                         \
314                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
315                        (&CLASS::bbGetOutput##NAME),                     \
316                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
317                        (&CLASS::bbSetOutput##NAME),\
318                        false) )
319 //============================================================================
320
321
322
323
324
325
326
327
328
329
330 //============================================================================
331 //============================================================================
332 // Template user black boxes macros
333 //============================================================================
334 //============================================================================
335
336 //============================================================================
337 /// Begins a template AtomicBlackBox of template param T description block
338 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)   \
339   template <class T>                                    \
340   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
341   {                                                                     \
342   public:                                                               \
343     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
344     {                                                                   \
345       return CLASS<T>::bbNew(name);                                     \
346     }                                                                   \
347     CLASS ## Descriptor()                                               \
348       {                                                                 \
349         bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS   \
350                             <<"Descriptor()"<<std::endl)
351 //============================================================================
352
353 //============================================================================
354 /// Ends a template AtomicBlackBox of template param T description block
355 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)     \
356   bbtkDecTab("Kernel",9);                                                       \
357   }                                                                     \
358   };                                                                    \
359   template <class T>                                    \
360   void CLASS<T>::bbCreateDescriptorIfNeeded()           \
361   {                                                                     \
362     if ( !bbDescriptorPointer() )                                       \
363       bbDescriptorPointer() = new CLASS ## Descriptor<T>;       \
364   }
365 //============================================================================
366
367 //============================================================================
368 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
369 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE)                      \
370   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
371                      (typeid(CLASS ## Descriptor),#NAME,DESCR,                                  \
372                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
373                       (&CLASS<T>::bbGetInput##NAME),                    \
374                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
375                       (&CLASS<T>::bbSetInput##NAME) ) )
376 //============================================================================
377
378 //============================================================================
379 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
380 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE)                     \
381   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
382                       (typeid(CLASS ## Descriptor),#NAME,DESCR,                         \
383                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
384                        (&CLASS<T>::bbGetOutput##NAME),                  \
385                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
386                        (&CLASS<T>::bbSetOutput##NAME) ) )
387 //============================================================================
388
389 //============================================================================
390 /// Template AtomicBlackBox std implementation of ctor and dtor
391 #define BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT)       \
392   template <class T>                                                    \
393   CLASS<T>::CLASS(const std::string& name, bool alloc)                  \
394     : PARENT(name,false)                                                \
395   {                                                                     \
396     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS<T>,alloc);                   \
397     CLASS<T>::bbUserConstructor();                              \
398     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
399   }                             \
400   template <class T>                                                    \
401   CLASS<T>::CLASS(CLASS<T>& from,                                               \
402                const std::string& name, bool allocate_connectors)       \
403     : PARENT(from,name,false)                                           \
404   {                                                                     \
405     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS<T>,from,allocate_connectors); \
406     CLASS<T>::bbUserCopyConstructor();                                  \
407     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
408   }             \
409   template <class T>                                                    \
410   CLASS<T>::~CLASS()                                                    \
411   {                                                                     \
412     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS<T>);                          \
413     CLASS<T>::bbUserDestructor();                                       \
414     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
415   }                                                                     
416 //============================================================================
417
418 //============================================================================
419 // Two template params user black boxes macros
420
421 /// Begins a template AtomicBlackBox description block of template param T1 and T2 
422 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)          \
423   template <class T1, class T2>                                         \
424   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
425   {                                                                     \
426   public:                                                               \
427     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
428     {                                                                   \
429       return CLASS<T1,T2>::bbNew(name);                                 \
430     }                                                                   \
431     CLASS ## Descriptor()                                               \
432       {                                                                 \
433       bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS     \
434                           <<"Descriptor()"<<std::endl)
435 //============================================================================
436
437 //============================================================================
438 /// Ends a template AtomicBlackBox description block of template param T1 and T2
439 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)            \
440   bbtkDecTab("Kernel",9);                                                       \
441   }                                                                     \
442   };                                                                    \
443   template <class T1, class T2>                                         \
444   void CLASS<T1,T2>::bbCreateDescriptorIfNeeded()                       \
445   {                                                                     \
446     if ( !bbDescriptorPointer() )                                       \
447       bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>;           \
448   }
449 //============================================================================
450
451 //============================================================================
452 // Two template params user black boxes macros
453
454 /// Begins a template AtomicBlackBox description block of template param T1 and T2 
455 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)           \
456   template <TYPE1 T1, TYPE2 T2>                                         \
457   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
458   {                                                                     \
459   public:                                                               \
460     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
461     {                                                                   \
462       return new CLASS<T1,T2>(name);                                    \
463     }                                                                   \
464     CLASS ## Descriptor()                                               \
465       {                                                                 \
466       bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS     \
467                           <<"Descriptor()"<<std::endl)
468 //============================================================================
469
470 //============================================================================
471 /// Ends a template AtomicBlackBox description block of template param T1 and T2
472 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)     \
473   bbtkDecTab("Kernel",9);                                                       \
474   }                                                                     \
475   };                                                                    \
476   template <TYPE1 T1, TYPE2 T2>                                         \
477   void CLASS<T1,T2>::bbCreateDescriptorIfNeeded()                       \
478   {                                                                     \
479     if ( !bbDescriptorPointer() )                                       \
480       bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>;           \
481   }
482 //============================================================================
483
484
485
486 //============================================================================
487 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
488 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE)                     \
489   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
490                      (typeid(CLASS ## Descriptor),#NAME,DESCR,                                  \
491                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE >      \
492                       (&CLASS<T1,T2>::bbGetInput##NAME),                \
493                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE >      \
494                       (&CLASS<T1,T2>::bbSetInput##NAME) ) )
495 //============================================================================
496
497 //============================================================================
498 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
499 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE)                    \
500   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
501                       (typeid(CLASS ## Descriptor),#NAME,DESCR,                         \
502                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
503                        (&CLASS<T1,T2>::bbGetOutput##NAME),              \
504                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
505                        (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
506 //============================================================================
507
508 //============================================================================
509 /// Template AtomicBlackBox std implementation of ctor and dtor
510 #define BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT)      \
511   template <class T1, class T2>                                         \
512   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)              \
513     : PARENT(name,false)                                                \
514   {                                                                     \
515     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
516     CLASS<T1,T2>::bbUserConstructor();                                  \
517     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
518   }                                                                     \
519   template <class T1, class T2>                                                 \
520   CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                                               \
521                const std::string& name, bool allocate_connectors)       \
522     : PARENT(from,name,false)                                           \
523   {                                                                     \
524     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
525     CLASS<T1,T2>::bbUserCopyConstructor();                              \
526     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
527   }                                                                     \
528   template <class T1, class T2>                                         \
529   CLASS<T1,T2>::~CLASS()                                                \
530   {                                                                     \
531     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
532     CLASS<T1,T2>::bbUserDestructor();                                   \
533     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
534   }                                                                     
535 //============================================================================
536
537
538 //============================================================================
539 /// Template AtomicBlackBox std implementation of ctor and dtor
540 #define BBTK_USER_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
541   template <TYPE1 T1, TYPE2 T2>                                         \
542   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)              \
543     : PARENT(name,false)                                                \
544   {                                                                     \
545     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
546     this->bbUserConstructor();                                          \
547     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
548   }                                                                     \
549   template <TYPE1 T1, TYPE2 T2>                                         \
550   CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                               \
551                       const std::string& name, bool allocate_connectors) \
552     : PARENT(from,name,false)                                           \
553   {                                                                     \
554     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
555     this->bbUserCopyConstructor();                                      \
556     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
557   }                                                                     \
558   template <TYPE1 T1, TYPE2 T2>                                         \
559   CLASS<T1,T2>::~CLASS()                                                \
560   {                                                                     \
561     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
562     this->bbUserDestructor();                                           \
563     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
564   }                                                                     
565 //============================================================================
566
567
568
569
570
571 //===========================================================================
572 //============================================================================
573 // ITK Specific macros
574 //===========================================================================
575 //===========================================================================
576
577
578 //===========================================================================
579 /// Declares an itk-inherited AtomicBlackBox input 
580 #define BBTK_DECLARE_ITK_INPUT(PARENT,NAME,TYPE)                        \
581   public:                                                               \
582   TYPE bbGetInput##NAME ()                                              \
583   { return PARENT::GetInput(); }                                        \
584   void bbSetInput##NAME (TYPE d)                                        \
585   { PARENT::SetInput(d);                                                \
586     /*bbSetModifiedStatus();*/ }                                                       
587 //===========================================================================
588
589 //===========================================================================
590 #define BBTK_DECLARE_ITK_OUTPUT(PARENT,NAME,TYPE)                       \
591   public:                                                               \
592   TYPE bbGetOutput##NAME ()                                             \
593   { return PARENT::GetOutput(); }                                       \
594   void bbSetOutput##NAME (TYPE d)                                       \
595   { /*PARENT::GetOutput() = d;*/ }                                      
596 //===========================================================================
597
598 //===========================================================================
599 /// Declares an AtomicBlackBox input corresponding to an inherited itk parameter
600 /// which was declared by itkSetMacro/itkGetMacro
601 /// The NAME **MUST** be the same than the itk parameter name
602 #define BBTK_DECLARE_ITK_PARAM(PARENT,NAME,TYPE)                        \
603   public:                                                               \
604   TYPE bbGetInput##NAME ()                                              \
605   { return PARENT::Get##NAME(); }                                       \
606   void bbSetInput##NAME (TYPE d)                                        \
607   { PARENT::Set##NAME(d);                                               \
608     /*bbSetModifiedStatus();*/ }
609 //===========================================================================
610
611
612
613
614 //===========================================================================
615 //============================================================================
616 // VTK Specific macros
617 //===========================================================================
618 //===========================================================================
619
620
621 //===========================================================================
622
623 // EED sept 04                                                  \
624 //  { return GetInput(); /*PARENT::GetInput();*/ }              \
625 //  { PARENT::SetInput( /*(vtkDataObject*)*/ d);                                \
626
627
628
629 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input 
630 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(PARENT,NAME,TYPE)                        \
631   public:                                                               \
632   TYPE bbGetInput##NAME ()                                              \
633   { return GetImageDataInput(0); /*PARENT::GetInput();*/ }              \
634   void bbSetInput##NAME (TYPE d)                                        \
635   { PARENT::SetInput( (vtkDataObject*) d);                              \
636     /*bbSetModifiedStatus();*/ }                                                       
637 //===========================================================================
638 /// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input 
639 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(PARENT,NAME,TYPE)    \
640   public:                                                               \
641   TYPE bbGetInput##NAME ()                                              \
642   { return GetPolyDataInput(0); /*PARENT::GetInput();*/ }               \
643   void bbSetInput##NAME (TYPE d)                                        \
644   { PARENT::SetInput( (vtkDataObject*) d);                              \
645     /*bbSetModifiedStatus();*/ }                                                       
646 //===========================================================================
647
648 //===========================================================================
649 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output 
650 #define BBTK_DECLARE_VTK_OUTPUT(PARENT,NAME,TYPE)                       \
651   public:                                                               \
652   TYPE bbGetOutput##NAME ()                                             \
653   { return PARENT::GetOutput(); }                                       \
654   void bbSetOutput##NAME (TYPE d)                                       \
655   { /*PARENT::GetOutput() = d;*/ }                                      
656 //===========================================================================
657
658 //===========================================================================
659 /// Declares a vtkAlgorithm-inherited AtomicBlackBox input 
660 #define BBTK_DECLARE_VTK_INPUT(PARENT,NAME,TYPE)                        \
661   public:                                                               \
662   TYPE bbGetInput##NAME ()                                              \
663   { return dynamic_cast<TYPE>(PARENT::GetInput()); }                    \
664   void bbSetInput##NAME (TYPE d)                                        \
665   { PARENT::SetInput( (vtkDataObject*) d); /*PARENT::GetOutput() = d;*/ }
666
667 //===========================================================================
668
669 //===========================================================================
670 /// Declares an AtomicBlackBox input corresponding to an inherited vtk parameter
671 /// which was declared by vtkSetMacro/vtkGetMacro
672 /// The NAME **MUST** be the same than the vtk parameter name
673 #define BBTK_DECLARE_VTK_PARAM(PARENT,NAME,TYPE)                        \
674   public:                                                               \
675   TYPE bbGetInput##NAME ()                                              \
676   { return PARENT::Get##NAME(); }                                       \
677   void bbSetInput##NAME (TYPE d)                                        \
678   { PARENT::Set##NAME(d);                                               \
679     /*bbSetModifiedStatus();*/ }
680 //===========================================================================
681
682
683
684 //===========================================================================
685 /// EOF
686 //===========================================================================
687 #endif