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