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