]> Creatis software - bbtk.git/blob - kernel/src/bbtkUserBlackBoxMacros.h
Recreated the complete cvs tree because the project architecture deeply changed
[bbtk.git] / kernel / src / bbtkUserBlackBoxMacros.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkUserBlackBoxMacros.h,v $
5   Language:  C++
6   Date:      $Date: 2008/01/22 15:02:00 $
7   Version:   $Revision: 1.1.1.1 $
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 __bbtkUserBlackBoxMacros_h__
25 #define __bbtkUserBlackBoxMacros_h__
26
27 //============================================================================
28 /// Declares the standard interface of a UserBlackBox 
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("Core",9,#CLASS<<"::bbNew(\""<<name<<"\")"<<std::endl); \
42     bbCreateDescriptorIfNeeded();                                       \
43     CLASS* c = new CLASS(name);                                         \
44     bbtkDebugDecTab("Core",9);                                          \
45     return c;                                                           \
46   }                                                                     \
47   inline bbtk::BlackBox* bbClone(const std::string& name)               \
48   {                                                                     \
49     bbtkDebugMessageInc("Core",9,#CLASS<<"::bbClone(\""<<name<<"\")"<<std::endl); \
50     bbCreateDescriptorIfNeeded();                                       \
51     CLASS* c = new CLASS(*this,name);                                   \
52     bbtkDebugDecTab("Core",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 bbProcess method
76 #define BBTK_PROCESS(CALLBACK)                                          \
77   public:                                                               \
78   inline void bbProcess()                                               \
79   {                                                                     \
80     bbtkDebugMessageInc("Process",1,"=> "<<bbGetTypeName()<<"::bbProcess() [" \
81                         <<bbGetFullName()<<"]"<<std::endl);             \
82     CALLBACK();                                                         \
83     bbtkDebugMessageDec("Process",1,"<= "<<bbGetTypeName()<<"::bbProcess() [" \
84                         <<bbGetFullName()<<"]"<<std::endl);             \
85   }
86 //============================================================================
87
88
89 //============================================================================
90 /// Declares a new UserBlackBox 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 UserBlackBox 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 UserBlackBox 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 UserBlackBox 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("Core",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("Core",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("Core",7)
161 //============================================================================
162
163 //============================================================================
164 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS)                          \
165   bbtkDebugMessageInc("Core",7,#CLASS <<"::~"<< #CLASS                  \
166                       <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
167 //============================================================================
168
169
170
171
172 //============================================================================
173 #define BBTK_END_BLACK_BOX_DESTRUCTOR           \
174   bbtkDebugDecTab("Core",7)
175 //============================================================================
176
177
178 //============================================================================
179 /// UserBlackBox 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 UserBlackBox 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("Core",9,#CLASS<<"Descriptor::"<<#CLASS     \
218                             <<"Descriptor()"<<std::endl)
219 //============================================================================
220
221 //============================================================================
222 /// Ends the UserBlackBox description block
223 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS)                              \
224   bbtkDecTab("Core",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 UserBlackBox (to be put inside the UBB description block)
237 #define BBTK_NAME(NAME) SetTypeName(NAME)
238 //============================================================================
239
240 //============================================================================
241 /// Declares the author of a UserBlackBox (to be put inside the UBB description block)
242 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
243 //============================================================================
244
245 //============================================================================
246 /// Declares the description of a UserBlackBox (to be put inside the UBB description block)
247 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
248 //============================================================================
249
250 //============================================================================
251 /// Declares the category of a UserBlackBox (to be put inside the UBB description block)
252 //#define BBTK_CATEGORY(CATEGORY) SetCategory(CATEGORY)
253 //============================================================================
254
255 //============================================================================
256 /// Declares that the UserBlackBox is an adaptor (to be put inside the UBB description block)
257 #define BBTK_ADAPTOR() SetCategory(bbtk::BlackBoxDescriptor::ADAPTOR)
258 //============================================================================
259
260 //============================================================================
261 /// Declares that the UserBlackBox is the default adaptor of the package (to be put inside the UBB description block)
262 #define BBTK_DEFAULT_ADAPTOR() SetCategory(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR)
263 //============================================================================
264
265 //============================================================================
266 /// Describes a UserBlackBox input (to be put inside the UBB description block)
267 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE)                               \
268   AddInputDescriptor(new bbtk::UserBlackBoxInputDescriptor              \
269                      (#NAME,DESCR,                                      \
270                       new bbtk::UserBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
271                       (&CLASS::bbGetInput##NAME),                       \
272                       new bbtk::UserBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
273                       (&CLASS::bbSetInput##NAME) ) )
274 //============================================================================
275
276 //============================================================================
277 /// Describes a UserBlackBox output (to be put inside the UBB description block)
278 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE)                              \
279   AddOutputDescriptor(new bbtk::UserBlackBoxOutputDescriptor            \
280                       (#NAME,DESCR,                                     \
281                        new bbtk::UserBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
282                        (&CLASS::bbGetOutput##NAME),                     \
283                        new bbtk::UserBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
284                        (&CLASS::bbSetOutput##NAME) ) )
285 //============================================================================
286
287 //============================================================================
288 /// Describes a UserBlackBox input (to be put inside the UBB description block)
289 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE)                        \
290   AddInputDescriptor(new bbtk::UserBlackBoxInputDescriptor              \
291                      (#NAME,DESCR,                                      \
292                       new bbtk::UserBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
293                       (&CLASS::bbGetInput##NAME),                       \
294                       new bbtk::UserBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
295                       (&CLASS::bbSetInput##NAME),                       \
296                       false) )
297 //============================================================================
298
299 //============================================================================
300 /// Describes a UserBlackBox output (to be put inside the UBB description block)
301 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE)                       \
302   AddOutputDescriptor(new bbtk::UserBlackBoxOutputDescriptor            \
303                       (#NAME,DESCR,                                     \
304                        new bbtk::UserBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
305                        (&CLASS::bbGetOutput##NAME),                     \
306                        new bbtk::UserBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
307                        (&CLASS::bbSetOutput##NAME),\
308                        false) )
309 //============================================================================
310
311
312
313
314
315
316
317
318
319
320 //============================================================================
321 //============================================================================
322 // Template user black boxes macros
323 //============================================================================
324 //============================================================================
325
326 //============================================================================
327 /// Begins a template UserBlackBox of template param T description block
328 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)   \
329   template <class T>                                    \
330   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
331   {                                                                     \
332   public:                                                               \
333     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
334     {                                                                   \
335       return CLASS<T>::bbNew(name);                                     \
336     }                                                                   \
337     CLASS ## Descriptor()                                               \
338       {                                                                 \
339         bbtkDebugMessageInc("Core",9,#CLASS<<"Descriptor::"<<#CLASS     \
340                             <<"Descriptor()"<<std::endl)
341 //============================================================================
342
343 //============================================================================
344 /// Ends a template UserBlackBox of template param T description block
345 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)     \
346   bbtkDecTab("Core",9);                                                 \
347   }                                                                     \
348   };                                                                    \
349   template <class T>                                    \
350   void CLASS<T>::bbCreateDescriptorIfNeeded()           \
351   {                                                                     \
352     if ( !bbDescriptorPointer() )                                       \
353       bbDescriptorPointer() = new CLASS ## Descriptor<T>;       \
354   }
355 //============================================================================
356
357 //============================================================================
358 /// Describes a template UserBlackBox input (to be put inside the template UBB description block)
359 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE)                      \
360   AddInputDescriptor(new bbtk::UserBlackBoxInputDescriptor              \
361                      (#NAME,DESCR,                                      \
362                       new bbtk::UserBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
363                       (&CLASS<T>::bbGetInput##NAME),                    \
364                       new bbtk::UserBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
365                       (&CLASS<T>::bbSetInput##NAME) ) )
366 //============================================================================
367
368 //============================================================================
369 /// Describes a template UserBlackBox output (to be put inside the template UBB description block)
370 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE)                     \
371   AddOutputDescriptor(new bbtk::UserBlackBoxOutputDescriptor            \
372                       (#NAME,DESCR,                                     \
373                        new bbtk::UserBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
374                        (&CLASS<T>::bbGetOutput##NAME),                  \
375                        new bbtk::UserBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
376                        (&CLASS<T>::bbSetOutput##NAME) ) )
377 //============================================================================
378
379 //============================================================================
380 /// Template UserBlackBox std implementation of ctor and dtor
381 #define BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT)       \
382   template <class T>                                                    \
383   CLASS<T>::CLASS(const std::string& name, bool alloc)                  \
384     : PARENT(name,false)                                                \
385   {                                                                     \
386     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS<T>,alloc);                   \
387     CLASS<T>::bbUserConstructor();                              \
388     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
389   }                             \
390   template <class T>                                                    \
391   CLASS<T>::CLASS(CLASS<T>& from,                                               \
392                const std::string& name, bool allocate_connectors)       \
393     : PARENT(from,name,false)                                           \
394   {                                                                     \
395     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS<T>,from,allocate_connectors); \
396     CLASS<T>::bbUserCopyConstructor();                                  \
397     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
398   }             \
399   template <class T>                                                    \
400   CLASS<T>::~CLASS()                                                    \
401   {                                                                     \
402     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS<T>);                          \
403     CLASS<T>::bbUserDestructor();                                       \
404     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
405   }                                                                     
406 //============================================================================
407
408 //============================================================================
409 // Two template params user black boxes macros
410
411 /// Begins a template UserBlackBox description block of template param T1 and T2 
412 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)          \
413   template <class T1, class T2>                                         \
414   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
415   {                                                                     \
416   public:                                                               \
417     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
418     {                                                                   \
419       return CLASS<T1,T2>::bbNew(name);                                 \
420     }                                                                   \
421     CLASS ## Descriptor()                                               \
422       {                                                                 \
423       bbtkDebugMessageInc("Core",9,#CLASS<<"Descriptor::"<<#CLASS       \
424                           <<"Descriptor()"<<std::endl)
425 //============================================================================
426
427 //============================================================================
428 /// Ends a template UserBlackBox description block of template param T1 and T2
429 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)            \
430   bbtkDecTab("Core",9);                                                 \
431   }                                                                     \
432   };                                                                    \
433   template <class T1, class T2>                                         \
434   void CLASS<T1,T2>::bbCreateDescriptorIfNeeded()                       \
435   {                                                                     \
436     if ( !bbDescriptorPointer() )                                       \
437       bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>;           \
438   }
439 //============================================================================
440
441 //============================================================================
442 // Two template params user black boxes macros
443
444 /// Begins a template UserBlackBox description block of template param T1 and T2 
445 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)           \
446   template <TYPE1 T1, TYPE2 T2>                                         \
447   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
448   {                                                                     \
449   public:                                                               \
450     bbtk::BlackBox::Pointer CreateInstance(const std::string& name)     \
451     {                                                                   \
452       return new CLASS<T1,T2>(name);                                    \
453     }                                                                   \
454     CLASS ## Descriptor()                                               \
455       {                                                                 \
456       bbtkDebugMessageInc("Core",9,#CLASS<<"Descriptor::"<<#CLASS       \
457                           <<"Descriptor()"<<std::endl)
458 //============================================================================
459
460 //============================================================================
461 /// Ends a template UserBlackBox description block of template param T1 and T2
462 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)     \
463   bbtkDecTab("Core",9);                                                 \
464   }                                                                     \
465   };                                                                    \
466   template <TYPE1 T1, TYPE2 T2>                                         \
467   void CLASS<T1,T2>::bbCreateDescriptorIfNeeded()                       \
468   {                                                                     \
469     if ( !bbDescriptorPointer() )                                       \
470       bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>;           \
471   }
472 //============================================================================
473
474
475
476 //============================================================================
477 /// Describes a 2 template params UserBlackBox input (to be put inside the UBB description block)
478 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE)                     \
479   AddInputDescriptor(new bbtk::UserBlackBoxInputDescriptor              \
480                      (#NAME,DESCR,                                      \
481                       new bbtk::UserBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE >        \
482                       (&CLASS<T1,T2>::bbGetInput##NAME),                \
483                       new bbtk::UserBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE >        \
484                       (&CLASS<T1,T2>::bbSetInput##NAME) ) )
485 //============================================================================
486
487 //============================================================================
488 /// Describes a 2 template params UserBlackBox output (to be put inside the UBB description block)
489 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE)                    \
490   AddOutputDescriptor(new bbtk::UserBlackBoxOutputDescriptor            \
491                       (#NAME,DESCR,                                     \
492                        new bbtk::UserBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
493                        (&CLASS<T1,T2>::bbGetOutput##NAME),              \
494                        new bbtk::UserBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
495                        (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
496 //============================================================================
497
498 //============================================================================
499 /// Template UserBlackBox std implementation of ctor and dtor
500 #define BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT)      \
501   template <class T1, class T2>                                         \
502   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)              \
503     : PARENT(name,false)                                                \
504   {                                                                     \
505     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
506     CLASS<T1,T2>::bbUserConstructor();                                  \
507     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
508   }                                                                     \
509   template <class T1, class T2>                                                 \
510   CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                                               \
511                const std::string& name, bool allocate_connectors)       \
512     : PARENT(from,name,false)                                           \
513   {                                                                     \
514     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
515     CLASS<T1,T2>::bbUserCopyConstructor();                              \
516     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
517   }                                                                     \
518   template <class T1, class T2>                                         \
519   CLASS<T1,T2>::~CLASS()                                                \
520   {                                                                     \
521     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
522     CLASS<T1,T2>::bbUserDestructor();                                   \
523     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
524   }                                                                     
525 //============================================================================
526
527
528 //============================================================================
529 /// Template UserBlackBox std implementation of ctor and dtor
530 #define BBTK_USER_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
531   template <TYPE1 T1, TYPE2 T2>                                         \
532   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)              \
533     : PARENT(name,false)                                                \
534   {                                                                     \
535     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
536     this->bbUserConstructor();                                          \
537     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
538   }                                                                     \
539   template <TYPE1 T1, TYPE2 T2>                                         \
540   CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                               \
541                       const std::string& name, bool allocate_connectors) \
542     : PARENT(from,name,false)                                           \
543   {                                                                     \
544     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
545     this->bbUserCopyConstructor();                                      \
546     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
547   }                                                                     \
548   template <TYPE1 T1, TYPE2 T2>                                         \
549   CLASS<T1,T2>::~CLASS()                                                \
550   {                                                                     \
551     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
552     this->bbUserDestructor();                                           \
553     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
554   }                                                                     
555 //============================================================================
556
557
558
559
560
561 //===========================================================================
562 //============================================================================
563 // ITK Specific macros
564 //===========================================================================
565 //===========================================================================
566
567
568 //===========================================================================
569 /// Declares an itk-inherited UserBlackBox input 
570 #define BBTK_DECLARE_ITK_INPUT(PARENT,NAME,TYPE)                        \
571   public:                                                               \
572   TYPE bbGetInput##NAME ()                                              \
573   { return PARENT::GetInput(); }                                        \
574   void bbSetInput##NAME (TYPE d)                                        \
575   { PARENT::SetInput(d);                                                \
576     /*bbSetModifiedStatus();*/ }                                                       
577 //===========================================================================
578
579 //===========================================================================
580 #define BBTK_DECLARE_ITK_OUTPUT(PARENT,NAME,TYPE)                       \
581   public:                                                               \
582   TYPE bbGetOutput##NAME ()                                             \
583   { return PARENT::GetOutput(); }                                       \
584   void bbSetOutput##NAME (TYPE d)                                       \
585   { /*PARENT::GetOutput() = d;*/ }                                      
586 //===========================================================================
587
588 //===========================================================================
589 /// Declares an UserBlackBox input corresponding to an inherited itk parameter
590 /// which was declared by itkSetMacro/itkGetMacro
591 /// The NAME **MUST** be the same than the itk parameter name
592 #define BBTK_DECLARE_ITK_PARAM(PARENT,NAME,TYPE)                        \
593   public:                                                               \
594   TYPE bbGetInput##NAME ()                                              \
595   { return PARENT::Get##NAME(); }                                       \
596   void bbSetInput##NAME (TYPE d)                                        \
597   { PARENT::Set##NAME(d);                                               \
598     /*bbSetModifiedStatus();*/ }
599 //===========================================================================
600
601
602
603
604 //===========================================================================
605 //============================================================================
606 // VTK Specific macros
607 //===========================================================================
608 //===========================================================================
609
610
611 //===========================================================================
612
613 // EED sept 04                                                  \
614 //  { return GetInput(); /*PARENT::GetInput();*/ }              \
615 //  { PARENT::SetInput( /*(vtkDataObject*)*/ d);                                \
616
617
618
619 /// Declares a vtkImageAlgorithm-inherited UserBlackBox input 
620 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(PARENT,NAME,TYPE)                        \
621   public:                                                               \
622   TYPE bbGetInput##NAME ()                                              \
623   { return GetImageDataInput(0); /*PARENT::GetInput();*/ }              \
624   void bbSetInput##NAME (TYPE d)                                        \
625   { PARENT::SetInput( (vtkDataObject*) d);                              \
626     /*bbSetModifiedStatus();*/ }                                                       
627 //===========================================================================
628 /// Declares a vtkPolyDataAlgorithm-inherited UserBlackBox input 
629 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(PARENT,NAME,TYPE)    \
630   public:                                                               \
631   TYPE bbGetInput##NAME ()                                              \
632   { return GetPolyDataInput(0); /*PARENT::GetInput();*/ }               \
633   void bbSetInput##NAME (TYPE d)                                        \
634   { PARENT::SetInput( (vtkDataObject*) d);                              \
635     /*bbSetModifiedStatus();*/ }                                                       
636 //===========================================================================
637
638 //===========================================================================
639 /// Declares a vtkImageAlgorithm-inherited UserBlackBox output 
640 #define BBTK_DECLARE_VTK_OUTPUT(PARENT,NAME,TYPE)                       \
641   public:                                                               \
642   TYPE bbGetOutput##NAME ()                                             \
643   { return PARENT::GetOutput(); }                                       \
644   void bbSetOutput##NAME (TYPE d)                                       \
645   { /*PARENT::GetOutput() = d;*/ }                                      
646 //===========================================================================
647
648 //===========================================================================
649 /// Declares a vtkAlgorithm-inherited UserBlackBox input 
650 #define BBTK_DECLARE_VTK_INPUT(PARENT,NAME,TYPE)                        \
651   public:                                                               \
652   TYPE bbGetInput##NAME ()                                              \
653   { return dynamic_cast<TYPE>(PARENT::GetInput()); }                    \
654   void bbSetInput##NAME (TYPE d)                                        \
655   { PARENT::SetInput( (vtkDataObject*) d); /*PARENT::GetOutput() = d;*/ }
656
657 //===========================================================================
658
659 //===========================================================================
660 /// Declares an UserBlackBox input corresponding to an inherited vtk parameter
661 /// which was declared by vtkSetMacro/vtkGetMacro
662 /// The NAME **MUST** be the same than the vtk parameter name
663 #define BBTK_DECLARE_VTK_PARAM(PARENT,NAME,TYPE)                        \
664   public:                                                               \
665   TYPE bbGetInput##NAME ()                                              \
666   { return PARENT::Get##NAME(); }                                       \
667   void bbSetInput##NAME (TYPE d)                                        \
668   { PARENT::Set##NAME(d);                                               \
669     /*bbSetModifiedStatus();*/ }
670 //===========================================================================
671
672
673
674 //===========================================================================
675 /// EOF
676 //===========================================================================
677 #endif