]> Creatis software - bbtk.git/blob - kernel/src/bbtkAtomicBlackBoxMacros.h
605c10d0d7255ffc4b09f443c2967017db8f848e
[bbtk.git] / kernel / src / bbtkAtomicBlackBoxMacros.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
5   Language:  C++
6   Date:      $Date: 2008/04/08 06:59:29 $
7   Version:   $Revision: 1.3 $
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 //============================================================================
276 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
277 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE)                                \
278   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
279                      (typeid(CLASS ## Descriptor),                      \
280                       #NAME,DESCR,NATURE,                               \
281                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
282                       (&CLASS::bbGetInput##NAME),                       \
283                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
284                       (&CLASS::bbSetInput##NAME) ) )
285 //============================================================================
286
287 //============================================================================
288 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
289 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE)                       \
290   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
291                       (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE,  \
292                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
293                        (&CLASS::bbGetOutput##NAME),                     \
294                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
295                        (&CLASS::bbSetOutput##NAME) ) )
296 //============================================================================
297
298
299 //============================================================================
300 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
301 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE)                 \
302   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
303                      (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE,   \
304                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
305                       (&CLASS::bbGetInput##NAME),                       \
306                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
307                       (&CLASS::bbSetInput##NAME),                       \
308                       false) )
309 //============================================================================
310
311 //============================================================================
312 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
313 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE)                \
314   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
315                       (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE,  \
316                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
317                        (&CLASS::bbGetOutput##NAME),                     \
318                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
319                        (&CLASS::bbSetOutput##NAME),\
320                        false) )
321 //============================================================================
322
323
324
325
326
327
328
329
330
331
332 //============================================================================
333 //============================================================================
334 // Template user black boxes macros
335 //============================================================================
336 //============================================================================
337
338 //============================================================================
339 /// Begins a template AtomicBlackBox of template param T description block
340 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)   \
341   template <class T>                                    \
342   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
343   {                                                                     \
344   public:                                                               \
345     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
346     {                                                                   \
347       return CLASS<T>::bbNew(name);                                     \
348     }                                                                   \
349     CLASS ## Descriptor()                                               \
350       {                                                                 \
351         bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS   \
352                             <<"Descriptor()"<<std::endl)
353 //============================================================================
354
355 //============================================================================
356 /// Ends a template AtomicBlackBox of template param T description block
357 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)     \
358   bbtkDecTab("Kernel",9);                                                       \
359   }                                                                     \
360   };                                                                    \
361   template <class T>                                    \
362   void CLASS<T>::bbCreateDescriptorIfNeeded()           \
363   {                                                                     \
364     if ( !bbDescriptorPointer() )                                       \
365       bbDescriptorPointer() = new CLASS ## Descriptor<T>;       \
366   }
367 //============================================================================
368
369 //============================================================================
370 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
371 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE)                      \
372   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
373                      (typeid(CLASS ## Descriptor),#NAME,DESCR,"",       \
374                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
375                       (&CLASS<T>::bbGetInput##NAME),                    \
376                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
377                       (&CLASS<T>::bbSetInput##NAME) ) )
378 //============================================================================
379
380 //============================================================================
381 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
382 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE)                     \
383   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
384                       (typeid(CLASS ## Descriptor),#NAME,DESCR,"",      \
385                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
386                        (&CLASS<T>::bbGetOutput##NAME),                  \
387                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
388                        (&CLASS<T>::bbSetOutput##NAME) ) )
389 //============================================================================
390
391 //============================================================================
392 /// Template AtomicBlackBox std implementation of ctor and dtor
393 #define BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT)       \
394   template <class T>                                                    \
395   CLASS<T>::CLASS(const std::string& name, bool alloc)                  \
396     : PARENT(name,false)                                                \
397   {                                                                     \
398     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS<T>,alloc);                   \
399     CLASS<T>::bbUserConstructor();                              \
400     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
401   }                             \
402   template <class T>                                                    \
403   CLASS<T>::CLASS(CLASS<T>& from,                                               \
404                const std::string& name, bool allocate_connectors)       \
405     : PARENT(from,name,false)                                           \
406   {                                                                     \
407     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS<T>,from,allocate_connectors); \
408     CLASS<T>::bbUserCopyConstructor();                                  \
409     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
410   }             \
411   template <class T>                                                    \
412   CLASS<T>::~CLASS()                                                    \
413   {                                                                     \
414     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS<T>);                          \
415     CLASS<T>::bbUserDestructor();                                       \
416     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
417   }                                                                     
418 //============================================================================
419
420 //============================================================================
421 // Two template params user black boxes macros
422
423 /// Begins a template AtomicBlackBox description block of template param T1 and T2 
424 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)          \
425   template <class T1, class T2>                                         \
426   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
427   {                                                                     \
428   public:                                                               \
429     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
430     {                                                                   \
431       return CLASS<T1,T2>::bbNew(name);                                 \
432     }                                                                   \
433     CLASS ## Descriptor()                                               \
434       {                                                                 \
435       bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS     \
436                           <<"Descriptor()"<<std::endl)
437 //============================================================================
438
439 //============================================================================
440 /// Ends a template AtomicBlackBox description block of template param T1 and T2
441 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)            \
442   bbtkDecTab("Kernel",9);                                                       \
443   }                                                                     \
444   };                                                                    \
445   template <class T1, class T2>                                         \
446   void CLASS<T1,T2>::bbCreateDescriptorIfNeeded()                       \
447   {                                                                     \
448     if ( !bbDescriptorPointer() )                                       \
449       bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>;           \
450   }
451 //============================================================================
452
453 //============================================================================
454 // Two template params user black boxes macros
455
456 /// Begins a template AtomicBlackBox description block of template param T1 and T2 
457 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)           \
458   template <TYPE1 T1, TYPE2 T2>                                         \
459   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
460   {                                                                     \
461   public:                                                               \
462     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
463     {                                                                   \
464       return new CLASS<T1,T2>(name);                                    \
465     }                                                                   \
466     CLASS ## Descriptor()                                               \
467       {                                                                 \
468       bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS     \
469                           <<"Descriptor()"<<std::endl)
470 //============================================================================
471
472 //============================================================================
473 /// Ends a template AtomicBlackBox description block of template param T1 and T2
474 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)     \
475   bbtkDecTab("Kernel",9);                                                       \
476   }                                                                     \
477   };                                                                    \
478   template <TYPE1 T1, TYPE2 T2>                                         \
479   void CLASS<T1,T2>::bbCreateDescriptorIfNeeded()                       \
480   {                                                                     \
481     if ( !bbDescriptorPointer() )                                       \
482       bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>;           \
483   }
484 //============================================================================
485
486
487
488 //============================================================================
489 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
490 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE)                     \
491   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
492                      (typeid(CLASS ## Descriptor),#NAME,DESCR,"",       \
493                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE >      \
494                       (&CLASS<T1,T2>::bbGetInput##NAME),                \
495                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE >      \
496                       (&CLASS<T1,T2>::bbSetInput##NAME) ) )
497 //============================================================================
498
499 //============================================================================
500 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
501 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE)                    \
502   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
503                       (typeid(CLASS ## Descriptor),#NAME,DESCR,"",      \
504                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
505                        (&CLASS<T1,T2>::bbGetOutput##NAME),              \
506                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
507                        (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
508 //============================================================================
509
510 //============================================================================
511 /// Template AtomicBlackBox std implementation of ctor and dtor
512 #define BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT)      \
513   template <class T1, class T2>                                         \
514   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)              \
515     : PARENT(name,false)                                                \
516   {                                                                     \
517     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
518     CLASS<T1,T2>::bbUserConstructor();                                  \
519     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
520   }                                                                     \
521   template <class T1, class T2>                                                 \
522   CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                                               \
523                const std::string& name, bool allocate_connectors)       \
524     : PARENT(from,name,false)                                           \
525   {                                                                     \
526     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
527     CLASS<T1,T2>::bbUserCopyConstructor();                              \
528     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
529   }                                                                     \
530   template <class T1, class T2>                                         \
531   CLASS<T1,T2>::~CLASS()                                                \
532   {                                                                     \
533     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
534     CLASS<T1,T2>::bbUserDestructor();                                   \
535     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
536   }                                                                     
537 //============================================================================
538
539
540 //============================================================================
541 /// Template AtomicBlackBox std implementation of ctor and dtor
542 #define BBTK_USER_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
543   template <TYPE1 T1, TYPE2 T2>                                         \
544   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)              \
545     : PARENT(name,false)                                                \
546   {                                                                     \
547     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
548     this->bbUserConstructor();                                          \
549     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
550   }                                                                     \
551   template <TYPE1 T1, TYPE2 T2>                                         \
552   CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                               \
553                       const std::string& name, bool allocate_connectors) \
554     : PARENT(from,name,false)                                           \
555   {                                                                     \
556     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
557     this->bbUserCopyConstructor();                                      \
558     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
559   }                                                                     \
560   template <TYPE1 T1, TYPE2 T2>                                         \
561   CLASS<T1,T2>::~CLASS()                                                \
562   {                                                                     \
563     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
564     this->bbUserDestructor();                                           \
565     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
566   }                                                                     
567 //============================================================================
568
569
570
571
572
573 //===========================================================================
574 //============================================================================
575 // ITK Specific macros
576 //===========================================================================
577 //===========================================================================
578
579
580 //===========================================================================
581 /// Declares an itk-inherited AtomicBlackBox input 
582 #define BBTK_DECLARE_ITK_INPUT(PARENT,NAME,TYPE)                        \
583   public:                                                               \
584   TYPE bbGetInput##NAME ()                                              \
585   { return PARENT::GetInput(); }                                        \
586   void bbSetInput##NAME (TYPE d)                                        \
587   { PARENT::SetInput(d);                                                \
588     /*bbSetModifiedStatus();*/ }                                                       
589 //===========================================================================
590
591 //===========================================================================
592 #define BBTK_DECLARE_ITK_OUTPUT(PARENT,NAME,TYPE)                       \
593   public:                                                               \
594   TYPE bbGetOutput##NAME ()                                             \
595   { return PARENT::GetOutput(); }                                       \
596   void bbSetOutput##NAME (TYPE d)                                       \
597   { /*PARENT::GetOutput() = d;*/ }                                      
598 //===========================================================================
599
600 //===========================================================================
601 /// Declares an AtomicBlackBox input corresponding to an inherited itk parameter
602 /// which was declared by itkSetMacro/itkGetMacro
603 /// The NAME **MUST** be the same than the itk parameter name
604 #define BBTK_DECLARE_ITK_PARAM(PARENT,NAME,TYPE)                        \
605   public:                                                               \
606   TYPE bbGetInput##NAME ()                                              \
607   { return PARENT::Get##NAME(); }                                       \
608   void bbSetInput##NAME (TYPE d)                                        \
609   { PARENT::Set##NAME(d);                                               \
610     /*bbSetModifiedStatus();*/ }
611 //===========================================================================
612
613
614
615
616 //===========================================================================
617 //============================================================================
618 // VTK Specific macros
619 //===========================================================================
620 //===========================================================================
621
622
623 //===========================================================================
624
625 // EED sept 04                                                  \
626 //  { return GetInput(); /*PARENT::GetInput();*/ }              \
627 //  { PARENT::SetInput( /*(vtkDataObject*)*/ d);                                \
628
629
630
631 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input 
632 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(PARENT,NAME,TYPE)                        \
633   public:                                                               \
634   TYPE bbGetInput##NAME ()                                              \
635   { return GetImageDataInput(0); /*PARENT::GetInput();*/ }              \
636   void bbSetInput##NAME (TYPE d)                                        \
637   { PARENT::SetInput( (vtkDataObject*) d);                              \
638     /*bbSetModifiedStatus();*/ }                                                       
639 //===========================================================================
640 /// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input 
641 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(PARENT,NAME,TYPE)    \
642   public:                                                               \
643   TYPE bbGetInput##NAME ()                                              \
644   { return GetPolyDataInput(0); /*PARENT::GetInput();*/ }               \
645   void bbSetInput##NAME (TYPE d)                                        \
646   { PARENT::SetInput( (vtkDataObject*) d);                              \
647     /*bbSetModifiedStatus();*/ }                                                       
648 //===========================================================================
649
650 //===========================================================================
651 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output 
652 #define BBTK_DECLARE_VTK_OUTPUT(PARENT,NAME,TYPE)                       \
653   public:                                                               \
654   TYPE bbGetOutput##NAME ()                                             \
655   { return PARENT::GetOutput(); }                                       \
656   void bbSetOutput##NAME (TYPE d)                                       \
657   { /*PARENT::GetOutput() = d;*/ }                                      
658 //===========================================================================
659
660 //===========================================================================
661 /// Declares a vtkAlgorithm-inherited AtomicBlackBox input 
662 #define BBTK_DECLARE_VTK_INPUT(PARENT,NAME,TYPE)                        \
663   public:                                                               \
664   TYPE bbGetInput##NAME ()                                              \
665   { return dynamic_cast<TYPE>(PARENT::GetInput()); }                    \
666   void bbSetInput##NAME (TYPE d)                                        \
667   { PARENT::SetInput( (vtkDataObject*) d); /*PARENT::GetOutput() = d;*/ }
668
669 //===========================================================================
670
671 //===========================================================================
672 /// Declares an AtomicBlackBox input corresponding to an inherited vtk parameter
673 /// which was declared by vtkSetMacro/vtkGetMacro
674 /// The NAME **MUST** be the same than the vtk parameter name
675 #define BBTK_DECLARE_VTK_PARAM(PARENT,NAME,TYPE)                        \
676   public:                                                               \
677   TYPE bbGetInput##NAME ()                                              \
678   { return PARENT::Get##NAME(); }                                       \
679   void bbSetInput##NAME (TYPE d)                                        \
680   { PARENT::Set##NAME(d);                                               \
681     /*bbSetModifiedStatus();*/ }
682 //===========================================================================
683
684
685
686 //===========================================================================
687 /// EOF
688 //===========================================================================
689 #endif