1 /*=========================================================================
4 Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
6 Date: $Date: 2008/04/18 12:59:15 $
7 Version: $Revision: 1.5 $
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.
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.
17 =========================================================================*/
22 * \brief Defines macros for the creation of new user black boxes
24 #ifndef __bbtkAtomicBlackBoxMacros_h__
25 #define __bbtkAtomicBlackBoxMacros_h__
27 //============================================================================
28 /// Declares the standard interface of a AtomicBlackBox
29 /// (ctor, New, descriptor related methods)
30 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT) \
31 BBTK_OBJECT_MINIMAL_INTERFACE; \
34 CLASS(const std::string& name, bool allocate_connectors = true); \
35 CLASS(Self& from, const std::string& name, \
36 bool allocate_connectors = true); \
39 std::string GetObjectName() const \
40 { return std::string(#CLASS)+std::string(" '") \
41 +bbGetNameWithParent()+std::string("'"); } \
42 inline static Pointer New(const std::string& name) \
44 bbtkDebugMessage("object",1,"##> "<<#CLASS \
45 <<"::New(\""<<name<<"\")"<<std::endl); \
46 Pointer p = MakeBlackBoxPointer(new Self(name)); \
47 bbtkDebugMessage("object",1,"<## "<<#CLASS \
48 <<"::New(\""<<name<<"\")"<<std::endl); \
51 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
53 bbtkDebugMessage("object",1,"##> "<<#CLASS \
54 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
55 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
56 bbtkDebugMessage("object",1,"<## "<<#CLASS \
57 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
60 virtual void bbLockDescriptor(); \
62 CLASS() : PARENT("") {} \
63 CLASS(const CLASS&) : PARENT("") {}
65 //============================================================================
67 //============================================================================
68 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
69 public : typedef CLASS Self; \
70 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
71 //============================================================================
73 //============================================================================
74 /// Defines the bbUserProcess method
75 #define BBTK_PROCESS(CALLBACK) \
77 inline void bbUserProcess() \
79 bbtkDebugMessageInc("Process",1,"=> "<<bbGetTypeName()<<"::bbUserProcess() [" \
80 <<bbGetFullName()<<"]"<<std::endl); \
82 bbtkDebugMessageDec("Process",1,"<= "<<bbGetTypeName()<<"::bbUserProcess() [" \
83 <<bbGetFullName()<<"]"<<std::endl); \
85 //============================================================================
88 //============================================================================
89 /// Declares a new AtomicBlackBox input (to be put in the class interface)
90 #define BBTK_DECLARE_INPUT(NAME,TYPE) \
92 TYPE bbmInput##NAME; \
94 TYPE bbGetInput##NAME () \
95 { return bbmInput##NAME; } \
96 void bbSetInput##NAME (TYPE d) \
97 { bbmInput##NAME = d; \
98 /*bbSetModifiedStatus();*/ }
99 //============================================================================
101 //============================================================================
102 /// Declares a new AtomicBlackBox output (to be put in the class interface)
103 #define BBTK_DECLARE_OUTPUT(NAME,TYPE) \
105 TYPE bbmOutput##NAME; \
107 TYPE bbGetOutput##NAME () \
108 { return bbmOutput##NAME; } \
109 void bbSetOutput##NAME (TYPE d) \
110 { bbmOutput##NAME = d; }
111 //============================================================================
113 //============================================================================
114 /// Declares an inherited AtomicBlackBox input (to be put in the class interface)
115 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
117 TYPE bbGetInput##NAME () \
118 { return GETMETHOD(); } \
119 void bbSetInput##NAME (TYPE d) \
121 /*bbSetModifiedStatus();*/ }
122 //============================================================================
125 //============================================================================
126 /// Declares an inherited AtomicBlackBox output (to be put in the class interface)
127 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
129 TYPE bbGetOutput##NAME () const \
130 { return GETMETHOD(); } \
131 void bbSetOutput##NAME (TYPE d) \
133 //============================================================================
137 //============================================================================
138 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC) \
139 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
140 <<"(\""<<bbGetName()<<"\")"<<std::endl); \
143 bbLockDescriptor(); \
144 bbAllocateConnectors(); \
146 //============================================================================
148 //============================================================================
149 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS) \
150 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
151 <<"(\""<<bbGetName()<<"\")"<<std::endl);
152 //============================================================================
154 //============================================================================
155 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
156 bbtkDebugMessageInc("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
157 <<"("<<FROM.bbGetFullName()<<",\"" \
158 <<bbGetName()<<"\")"<<std::endl); \
161 bbLockDescriptor(); \
162 bbAllocateConnectors(); \
163 bbCopyIOValues(FROM); \
165 //============================================================================
167 //============================================================================
168 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM) \
169 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
170 <<"("<<FROM.bbGetFullName()<<",\"" \
171 <<bbGetName()<<"\")"<<std::endl);
172 //============================================================================
174 //============================================================================
175 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
176 bbtkDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
177 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
178 //============================================================================
180 //============================================================================
181 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS) \
182 bbtkDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS \
183 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
185 //============================================================================
188 //============================================================================
189 /// AtomicBlackBox std implementation of ctor and dtor
190 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
191 CLASS::CLASS(const std::string& name, bool allocate_connectors) \
192 : PARENT(name,false) \
194 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \
195 CLASS::bbUserConstructor(); \
196 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
198 CLASS::CLASS(CLASS& from, \
199 const std::string& name, bool allocate_connectors) \
200 : PARENT(from,name,false) \
202 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
203 CLASS::bbUserCopyConstructor(); \
204 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
208 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
209 CLASS::bbUserDestructor(); \
210 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
212 void CLASS::bbLockDescriptor() \
214 bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \
216 //============================================================================
219 //============================================================================
220 /// Begins the AtomicBlackBox description block
221 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT) \
222 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
224 public: typedef CLASS ## Descriptor Self; \
225 BBTK_OBJECT_MINIMAL_INTERFACE; \
227 std::string GetObjectName() const \
229 return std::string(BBTK_STRINGIFY(CLASS)) \
230 +std::string("Descriptor '")+GetFullTypeName() \
233 size_t GetObjectSize() const { return sizeof(*this); } \
234 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
236 return CLASS::New(name); \
238 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
242 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
244 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
245 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
246 if (!i.lock()) { j = Self::New(); i = j; } \
249 static CLASS ## Descriptor::Pointer New() \
251 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
252 <<"Descriptor::New" <<std::endl); \
253 CLASS ## Descriptor::Pointer p = \
254 MakePointer(new CLASS ## Descriptor()); \
255 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
256 <<"Descriptor::New" <<std::endl); \
260 CLASS ## Descriptor() \
262 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
263 <<#CLASS<<"Descriptor()"<<std::endl);
264 //============================================================================
266 //============================================================================
267 /// Ends the AtomicBlackBox description block
268 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
269 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
270 <<#CLASS<<"Descriptor()"<<std::endl); \
274 //============================================================================
277 //============================================================================
278 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
279 #define BBTK_NAME(NAME) SetTypeName(NAME)
280 //============================================================================
282 //============================================================================
283 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
284 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
285 //============================================================================
287 //============================================================================
288 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
289 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
290 //============================================================================
292 //============================================================================
293 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
294 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
295 //============================================================================
297 //============================================================================
298 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
299 //#define BBTK_KIND(KIND) SetKind(KIND)
300 //============================================================================
302 //============================================================================
303 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
304 #define BBTK_ADAPTOR() \
305 SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
306 AddToCategory("adaptor")
307 //============================================================================
309 //============================================================================
310 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
311 #define BBTK_DEFAULT_ADAPTOR() \
312 SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR); \
313 AddToCategory("adaptor")
314 //============================================================================
317 //============================================================================
318 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
319 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
320 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
321 (typeid(CLASS ## Descriptor), \
322 #NAME,DESCR,NATURE, \
323 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
324 (&CLASS::bbGetInput##NAME), \
325 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
326 (&CLASS::bbSetInput##NAME) ) )
327 //============================================================================
329 //============================================================================
330 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
331 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
332 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
333 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
334 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
335 (&CLASS::bbGetOutput##NAME), \
336 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
337 (&CLASS::bbSetOutput##NAME) ) )
338 //============================================================================
341 //============================================================================
342 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
343 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
344 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
345 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
346 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
347 (&CLASS::bbGetInput##NAME), \
348 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
349 (&CLASS::bbSetInput##NAME), \
351 //============================================================================
353 //============================================================================
354 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
355 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
356 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
357 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
358 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
359 (&CLASS::bbGetOutput##NAME), \
360 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
361 (&CLASS::bbSetOutput##NAME),\
363 //============================================================================
374 //============================================================================
375 //============================================================================
376 // Template user black boxes macros
377 //============================================================================
378 //============================================================================
380 //============================================================================
381 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
382 public : typedef CLASS<T> Self; \
383 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
384 //============================================================================
386 //============================================================================
387 /// Begins a template AtomicBlackBox of template param T description block
388 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
390 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
392 public: typedef CLASS ## Descriptor<T> Self; \
393 BBTK_OBJECT_MINIMAL_INTERFACE; \
395 std::string GetObjectName() const \
397 return std::string(BBTK_STRINGIFY(CLASS)) \
398 +std::string("Descriptor<")+bbtk::TypeName<T>() \
399 +std::string("> '")+GetFullTypeName() \
402 static Pointer New() \
404 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
405 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
407 Pointer p = MakePointer(new Self()); \
408 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
409 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
413 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
417 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
419 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
420 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
421 if (!i.lock()) { j = Self::New(); i = j; } \
424 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
426 return CLASS<T>::New(name); \
428 CLASS ## Descriptor() \
430 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
431 <<bbtk::TypeName<T>()<<">::" \
432 <<#CLASS<<"Descriptor()"<<std::endl);
434 //============================================================================
436 //============================================================================
437 /// Ends a template AtomicBlackBox of template param T description block
438 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
439 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
440 <<bbtk::TypeName<T>()<<">::" \
441 <<#CLASS<<"Descriptor()"<<std::endl); \
445 //============================================================================
447 //============================================================================
448 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
449 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE) \
450 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
451 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
452 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
453 (&CLASS<T>::bbGetInput##NAME), \
454 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
455 (&CLASS<T>::bbSetInput##NAME) ) )
456 //============================================================================
458 //============================================================================
459 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
460 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE) \
461 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
462 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
463 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
464 (&CLASS<T>::bbGetOutput##NAME), \
465 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
466 (&CLASS<T>::bbSetOutput##NAME) ) )
467 //============================================================================
469 //============================================================================
470 /// Template AtomicBlackBox std implementation of ctor and dtor
471 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
473 CLASS<T>::CLASS(const std::string& name, bool alloc) \
474 : PARENT(name,false) \
476 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
477 CLASS<T>::bbUserConstructor(); \
478 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
481 CLASS<T>::CLASS(CLASS<T>& from, \
482 const std::string& name, bool allocate_connectors) \
483 : PARENT(from,name,false) \
485 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
486 CLASS<T>::bbUserCopyConstructor(); \
487 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
492 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
493 CLASS<T>::bbUserDestructor(); \
494 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
497 void CLASS<T>::bbLockDescriptor() \
499 bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
501 //============================================================================
505 //============================================================================
506 // Two template params user black boxes macros
507 //============================================================================
509 //============================================================================
510 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
511 public : typedef CLASS<T1,T2> Self; \
512 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
513 //===========================================================================
515 //============================================================================
516 /// Begins a template AtomicBlackBox description block of template param T1 and T2
517 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
518 template <class T1, class T2> \
519 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
521 public: typedef CLASS ## Descriptor<T1,T2> Self; \
522 BBTK_OBJECT_MINIMAL_INTERFACE; \
524 std::string GetObjectName() const \
526 return std::string(BBTK_STRINGIFY(CLASS)) \
527 +std::string("Descriptor<")+bbtk::TypeName<T1>() \
528 +std::string(",")+bbtk::TypeName<T2>() \
529 +std::string("> '")+GetFullTypeName() \
532 static Pointer New() \
534 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
535 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
536 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
537 Pointer p = MakePointer(new Self()); \
538 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
539 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
540 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
543 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
547 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
549 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
550 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
551 if (!i.lock()) { j = Self::New(); i = j; } \
554 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
556 return CLASS<T1,T2>::New(name); \
558 CLASS ## Descriptor() \
560 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
561 <<bbtk::TypeName<T1>()<<"," \
562 <<bbtk::TypeName<T2>()<<">::" \
563 <<#CLASS<<"Descriptor()"<<std::endl);
564 //============================================================================
566 //============================================================================
567 /// Ends a template AtomicBlackBox description block of template param T1 and T2
568 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
569 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
570 <<bbtk::TypeName<T1>()<<"," \
571 <<bbtk::TypeName<T2>()<<">::" \
572 <<#CLASS<<"Descriptor()"<<std::endl); \
576 //============================================================================
581 //============================================================================
582 // Two template params user black boxes macros
584 /// Begins a template AtomicBlackBox description block of template param T1 and T2
585 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
586 template <TYPE1 T1, TYPE2 T2> \
587 class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
590 virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
594 static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
596 static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
597 bbtk:AtomicBlackBoxDescriptor::Pointer j; \
598 if (!i.lock()) { j = Self::New(); i = j; } \
601 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
603 return new CLASS<T1,T2>(name); \
605 CLASS ## Descriptor() \
607 bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
608 <<"Descriptor()"<<std::endl)
609 //============================================================================
611 //============================================================================
612 /// Ends a template AtomicBlackBox description block of template param T1 and T2
613 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
614 bbtkDecTab("Kernel",9); \
618 //============================================================================
622 //============================================================================
623 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
624 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE) \
625 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
626 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
627 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
628 (&CLASS<T1,T2>::bbGetInput##NAME), \
629 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
630 (&CLASS<T1,T2>::bbSetInput##NAME) ) )
631 //============================================================================
633 //============================================================================
634 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
635 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE) \
636 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
637 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
638 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
639 (&CLASS<T1,T2>::bbGetOutput##NAME), \
640 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
641 (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
642 //============================================================================
644 //============================================================================
645 /// Template AtomicBlackBox std implementation of ctor and dtor
646 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
647 template <class T1, class T2> \
648 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
649 : PARENT(name,false) \
651 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
652 CLASS<T1,T2>::bbUserConstructor(); \
653 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
655 template <class T1, class T2> \
656 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
657 const std::string& name, bool allocate_connectors) \
658 : PARENT(from,name,false) \
660 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
661 CLASS<T1,T2>::bbUserCopyConstructor(); \
662 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
664 template <class T1, class T2> \
665 CLASS<T1,T2>::~CLASS() \
667 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
668 CLASS<T1,T2>::bbUserDestructor(); \
669 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
671 template <class T1, class T2> \
672 void CLASS<T1,T2>::bbLockDescriptor() \
674 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
676 //============================================================================
680 //============================================================================
681 /// Template AtomicBlackBox std implementation of ctor and dtor
682 #define BBTK_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
683 template <TYPE1 T1, TYPE2 T2> \
684 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
685 : PARENT(name,false) \
687 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
688 this->bbUserConstructor(); \
689 BBTK_END_BLACK_BOX_CONSTRUCTOR; \
691 template <TYPE1 T1, TYPE2 T2> \
692 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
693 const std::string& name, bool allocate_connectors) \
694 : PARENT(from,name,false) \
696 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
697 this->bbUserCopyConstructor(); \
698 BBTK_END_BLACK_BOX_CONSTRUCTOR; \
700 template <TYPE1 T1, TYPE2 T2> \
701 CLASS<T1,T2>::~CLASS() \
703 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
704 this->bbUserDestructor(); \
705 BBTK_END_BLACK_BOX_DESTRUCTOR; \
707 template <class T1, class T2> \
708 void CLASS<T1,T2>::bbLockDescriptor() \
710 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
712 //============================================================================
718 //===========================================================================
719 //============================================================================
720 // ITK Specific macros
721 //===========================================================================
722 //===========================================================================
725 //===========================================================================
726 /// Declares an itk-inherited AtomicBlackBox input
727 #define BBTK_DECLARE_ITK_INPUT(PARENT,NAME,TYPE) \
729 TYPE bbGetInput##NAME () \
730 { return PARENT::GetInput(); } \
731 void bbSetInput##NAME (TYPE d) \
732 { PARENT::SetInput(d); \
733 /*bbSetModifiedStatus();*/ }
734 //===========================================================================
736 //===========================================================================
737 #define BBTK_DECLARE_ITK_OUTPUT(PARENT,NAME,TYPE) \
739 TYPE bbGetOutput##NAME () \
740 { return PARENT::GetOutput(); } \
741 void bbSetOutput##NAME (TYPE d) \
742 { /*PARENT::GetOutput() = d;*/ }
743 //===========================================================================
745 //===========================================================================
746 /// Declares an AtomicBlackBox input corresponding to an inherited itk parameter
747 /// which was declared by itkSetMacro/itkGetMacro
748 /// The NAME **MUST** be the same than the itk parameter name
749 #define BBTK_DECLARE_ITK_PARAM(PARENT,NAME,TYPE) \
751 TYPE bbGetInput##NAME () \
752 { return PARENT::Get##NAME(); } \
753 void bbSetInput##NAME (TYPE d) \
754 { PARENT::Set##NAME(d); \
755 /*bbSetModifiedStatus();*/ }
756 //===========================================================================
761 //===========================================================================
762 //============================================================================
763 // VTK Specific macros
764 //===========================================================================
765 //===========================================================================
768 //===========================================================================
771 // { return GetInput(); /*PARENT::GetInput();*/ } \
772 // { PARENT::SetInput( /*(vtkDataObject*)*/ d); \
776 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input
777 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(PARENT,NAME,TYPE) \
779 TYPE bbGetInput##NAME () \
780 { return GetImageDataInput(0); /*PARENT::GetInput();*/ } \
781 void bbSetInput##NAME (TYPE d) \
782 { PARENT::SetInput( (vtkDataObject*) d); \
783 /*bbSetModifiedStatus();*/ }
784 //===========================================================================
785 /// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input
786 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(PARENT,NAME,TYPE) \
788 TYPE bbGetInput##NAME () \
789 { return GetPolyDataInput(0); /*PARENT::GetInput();*/ } \
790 void bbSetInput##NAME (TYPE d) \
791 { PARENT::SetInput( (vtkDataObject*) d); \
792 /*bbSetModifiedStatus();*/ }
793 //===========================================================================
795 //===========================================================================
796 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output
797 #define BBTK_DECLARE_VTK_OUTPUT(PARENT,NAME,TYPE) \
799 TYPE bbGetOutput##NAME () \
800 { return PARENT::GetOutput(); } \
801 void bbSetOutput##NAME (TYPE d) \
802 { /*PARENT::GetOutput() = d;*/ }
803 //===========================================================================
805 //===========================================================================
806 /// Declares a vtkAlgorithm-inherited AtomicBlackBox input
807 #define BBTK_DECLARE_VTK_INPUT(PARENT,NAME,TYPE) \
809 TYPE bbGetInput##NAME () \
810 { return dynamic_cast<TYPE>(PARENT::GetInput()); } \
811 void bbSetInput##NAME (TYPE d) \
812 { PARENT::SetInput( (vtkDataObject*) d); /*PARENT::GetOutput() = d;*/ }
814 //===========================================================================
816 //===========================================================================
817 /// Declares an AtomicBlackBox input corresponding to an inherited vtk parameter
818 /// which was declared by vtkSetMacro/vtkGetMacro
819 /// The NAME **MUST** be the same than the vtk parameter name
820 #define BBTK_DECLARE_VTK_PARAM(PARENT,NAME,TYPE) \
822 TYPE bbGetInput##NAME () \
823 { return PARENT::Get##NAME(); } \
824 void bbSetInput##NAME (TYPE d) \
825 { PARENT::Set##NAME(d); \
826 /*bbSetModifiedStatus();*/ }
827 //===========================================================================
831 //===========================================================================
833 //===========================================================================