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