1 /*=========================================================================
4 Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
6 Date: $Date: 2008/07/29 07:31:13 $
7 Version: $Revision: 1.10 $
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_WITHOUT_NEW(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 virtual void bbLockDescriptor(); \
44 CLASS() : PARENT("") {} \
45 CLASS(const CLASS&) : PARENT("") {}
47 //============================================================================
49 //============================================================================
50 /// Declares the standard interface of a AtomicBlackBox
51 /// (ctor, New, descriptor related methods)
52 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT) \
53 BBTK_OBJECT_MINIMAL_INTERFACE; \
56 CLASS(const std::string& name, bool allocate_connectors = true); \
57 CLASS(Self& from, const std::string& name, \
58 bool allocate_connectors = true); \
61 std::string GetObjectName() const \
62 { return std::string(#CLASS)+std::string(" '") \
63 +bbGetNameWithParent()+std::string("'"); } \
64 inline static Pointer New(const std::string& name) \
66 bbtkDebugMessage("object",1,"##> "<<#CLASS \
67 <<"::New(\""<<name<<"\")"<<std::endl); \
68 Pointer p = MakeBlackBoxPointer(new Self(name)); \
69 bbtkDebugMessage("object",1,"<## "<<#CLASS \
70 <<"::New(\""<<name<<"\")"<<std::endl); \
73 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
75 bbtkDebugMessage("object",1,"##> "<<#CLASS \
76 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
77 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
78 bbtkDebugMessage("object",1,"<## "<<#CLASS \
79 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
82 virtual void bbLockDescriptor(); \
84 CLASS() : PARENT("") {} \
85 CLASS(const CLASS&) : PARENT("") {}
87 //============================================================================
89 //============================================================================
90 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
91 public : typedef CLASS Self; \
92 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
93 //============================================================================
95 //============================================================================
96 #define BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENT) \
97 public : typedef CLASS Self; \
98 BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT);
99 //============================================================================
101 //============================================================================
102 /// Defines the bbUserProcess method
103 #define BBTK_PROCESS(CALLBACK) \
105 inline void bbUserProcess() \
107 bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName() \
110 bbtkDebugMessage("process",2,"<** Processing ["<<bbGetFullName() \
113 //============================================================================
116 //============================================================================
117 /// Declares a new AtomicBlackBox input (to be put in the class interface)
118 #define BBTK_DECLARE_INPUT(NAME,TYPE) \
120 TYPE bbmInput##NAME; \
122 TYPE bbGetInput##NAME () \
123 { return bbmInput##NAME; } \
124 void bbSetInput##NAME (TYPE d) \
125 { bbmInput##NAME = d; \
126 /*bbSetModifiedStatus();*/ }
127 //============================================================================
129 //============================================================================
130 /// Declares a new AtomicBlackBox output (to be put in the class interface)
131 #define BBTK_DECLARE_OUTPUT(NAME,TYPE) \
133 TYPE bbmOutput##NAME; \
135 TYPE bbGetOutput##NAME () \
136 { return bbmOutput##NAME; } \
137 void bbSetOutput##NAME (TYPE d) \
138 { bbmOutput##NAME = d; }
139 //============================================================================
141 //============================================================================
142 /// Declares an inherited AtomicBlackBox input (to be put in the class interface)
143 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
145 TYPE bbGetInput##NAME () \
146 { return GETMETHOD(); } \
147 void bbSetInput##NAME (TYPE d) \
149 /*bbSetModifiedStatus();*/ }
150 //============================================================================
153 //============================================================================
154 /// Declares an inherited AtomicBlackBox output (to be put in the class interface)
155 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
157 TYPE bbGetOutput##NAME () const \
158 { return GETMETHOD(); } \
159 void bbSetOutput##NAME (TYPE d) \
161 //============================================================================
165 //============================================================================
166 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC) \
167 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
168 <<"(\""<<bbGetName()<<"\")"<<std::endl); \
171 bbLockDescriptor(); \
172 bbAllocateConnectors(); \
174 //============================================================================
176 //============================================================================
177 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS) \
178 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
179 <<"(\""<<bbGetName()<<"\")"<<std::endl);
180 //============================================================================
182 //============================================================================
183 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
184 bbtkDebugMessageInc("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
185 <<"("<<FROM.bbGetFullName()<<",\"" \
186 <<bbGetName()<<"\")"<<std::endl); \
189 bbLockDescriptor(); \
190 bbAllocateConnectors(); \
191 bbCopyIOValues(FROM); \
193 //============================================================================
195 //============================================================================
196 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM) \
197 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
198 <<"("<<FROM.bbGetFullName()<<",\"" \
199 <<bbGetName()<<"\")"<<std::endl);
200 //============================================================================
202 //============================================================================
203 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
204 bbtkDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
205 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
206 //============================================================================
208 //============================================================================
209 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS) \
210 bbtkDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS \
211 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
213 //============================================================================
216 //============================================================================
217 /// AtomicBlackBox std implementation of ctor and dtor
218 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
219 CLASS::CLASS(const std::string& name, bool allocate_connectors) \
220 : PARENT(name,false) \
222 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \
223 CLASS::bbUserConstructor(); \
224 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
226 CLASS::CLASS(CLASS& from, \
227 const std::string& name, bool allocate_connectors) \
228 : PARENT(from,name,false) \
230 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
231 CLASS::bbUserCopyConstructor(); \
232 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
236 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
237 CLASS::bbUserDestructor(); \
238 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
240 void CLASS::bbLockDescriptor() \
242 bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \
244 //============================================================================
247 //============================================================================
248 /// Begins the AtomicBlackBox description block
249 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT) \
250 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
252 public: typedef CLASS ## Descriptor Self; \
253 BBTK_OBJECT_MINIMAL_INTERFACE; \
255 std::string GetObjectName() const \
257 return std::string(BBTK_STRINGIFY(CLASS)) \
258 +std::string("Descriptor '")+GetFullTypeName() \
261 size_t GetObjectSize() const { return sizeof(*this); } \
262 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
264 return CLASS::New(name); \
266 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
270 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
272 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
273 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
274 if (!i.lock()) { j = Self::New(); i = j; } \
277 static CLASS ## Descriptor::Pointer New() \
279 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
280 <<"Descriptor::New" <<std::endl); \
281 CLASS ## Descriptor::Pointer p = \
282 MakePointer(new CLASS ## Descriptor()); \
283 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
284 <<"Descriptor::New" <<std::endl); \
288 CLASS ## Descriptor() \
290 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
291 <<#CLASS<<"Descriptor()"<<std::endl);
292 //============================================================================
294 //============================================================================
295 /// Ends the AtomicBlackBox description block
296 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
297 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
298 <<#CLASS<<"Descriptor()"<<std::endl); \
302 //============================================================================
305 //============================================================================
306 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
307 #define BBTK_NAME(NAME) SetTypeName(NAME)
308 //============================================================================
310 //============================================================================
311 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
312 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
313 //============================================================================
315 //============================================================================
316 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
317 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
318 //============================================================================
320 //============================================================================
321 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
322 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
323 //============================================================================
325 //============================================================================
326 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
327 //#define BBTK_KIND(KIND) SetKind(KIND)
328 //============================================================================
330 //============================================================================
331 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
332 #define BBTK_ADAPTOR() \
333 SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
334 AddToCategory("adaptor")
335 //============================================================================
337 //============================================================================
338 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
339 #define BBTK_DEFAULT_ADAPTOR() \
340 SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR); \
341 AddToCategory("adaptor")
342 //============================================================================
345 //============================================================================
346 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
347 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
348 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
349 (typeid(CLASS ## Descriptor), \
350 #NAME,DESCR,NATURE, \
351 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
352 (&CLASS::bbGetInput##NAME), \
353 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
354 (&CLASS::bbSetInput##NAME) ) )
355 //============================================================================
357 //============================================================================
358 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
359 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
360 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
361 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
362 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
363 (&CLASS::bbGetOutput##NAME), \
364 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
365 (&CLASS::bbSetOutput##NAME) ) )
366 //============================================================================
369 //============================================================================
370 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
371 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
372 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
373 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
374 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
375 (&CLASS::bbGetInput##NAME), \
376 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
377 (&CLASS::bbSetInput##NAME), \
379 //============================================================================
381 //============================================================================
382 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
383 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
384 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
385 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
386 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
387 (&CLASS::bbGetOutput##NAME), \
388 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
389 (&CLASS::bbSetOutput##NAME),\
391 //============================================================================
402 //============================================================================
403 //============================================================================
404 // Template user black boxes macros
405 //============================================================================
406 //============================================================================
408 //============================================================================
409 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
410 public : typedef CLASS<T> Self; \
411 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
412 //============================================================================
414 //============================================================================
415 /// Begins a template AtomicBlackBox of template param T description block
416 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
418 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
420 public: typedef CLASS ## Descriptor<T> Self; \
421 BBTK_OBJECT_MINIMAL_INTERFACE; \
423 std::string GetObjectName() const \
425 return std::string(BBTK_STRINGIFY(CLASS)) \
426 +std::string("Descriptor<")+bbtk::TypeName<T>() \
427 +std::string("> '")+GetFullTypeName() \
430 static Pointer New() \
432 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
433 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
435 Pointer p = MakePointer(new Self()); \
436 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
437 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
441 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
445 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
447 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
448 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
449 if (!i.lock()) { j = Self::New(); i = j; } \
452 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
454 return CLASS<T>::New(name); \
456 CLASS ## Descriptor() \
458 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
459 <<bbtk::TypeName<T>()<<">::" \
460 <<#CLASS<<"Descriptor()"<<std::endl);
462 //============================================================================
464 //============================================================================
465 /// Ends a template AtomicBlackBox of template param T description block
466 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
467 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
468 <<bbtk::TypeName<T>()<<">::" \
469 <<#CLASS<<"Descriptor()"<<std::endl); \
473 //============================================================================
475 //============================================================================
476 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
477 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE) \
478 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
479 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
480 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
481 (&CLASS<T>::bbGetInput##NAME), \
482 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
483 (&CLASS<T>::bbSetInput##NAME) ) )
484 //============================================================================
486 //============================================================================
487 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
488 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE) \
489 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
490 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
491 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
492 (&CLASS<T>::bbGetOutput##NAME), \
493 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
494 (&CLASS<T>::bbSetOutput##NAME) ) )
495 //============================================================================
497 //============================================================================
498 /// Template AtomicBlackBox std implementation of ctor and dtor
499 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
501 CLASS<T>::CLASS(const std::string& name, bool alloc) \
502 : PARENT(name,false) \
504 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
505 CLASS<T>::bbUserConstructor(); \
506 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
509 CLASS<T>::CLASS(CLASS<T>& from, \
510 const std::string& name, bool allocate_connectors) \
511 : PARENT(from,name,false) \
513 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
514 CLASS<T>::bbUserCopyConstructor(); \
515 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
520 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
521 CLASS<T>::bbUserDestructor(); \
522 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
525 void CLASS<T>::bbLockDescriptor() \
527 bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
529 //============================================================================
533 //============================================================================
534 // Two template params user black boxes macros
535 //============================================================================
537 //============================================================================
538 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
539 public : typedef CLASS<T1,T2> Self; \
540 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
541 //===========================================================================
543 //============================================================================
544 /// Begins a template AtomicBlackBox description block of template param T1 and T2
545 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
546 template <class T1, class T2> \
547 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
549 public: typedef CLASS ## Descriptor<T1,T2> Self; \
550 BBTK_OBJECT_MINIMAL_INTERFACE; \
552 std::string GetObjectName() const \
554 return std::string(BBTK_STRINGIFY(CLASS)) \
555 +std::string("Descriptor<")+bbtk::TypeName<T1>() \
556 +std::string(",")+bbtk::TypeName<T2>() \
557 +std::string("> '")+GetFullTypeName() \
560 static Pointer New() \
562 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
563 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
564 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
565 Pointer p = MakePointer(new Self()); \
566 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
567 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
568 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
571 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
575 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
577 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
578 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
579 if (!i.lock()) { j = Self::New(); i = j; } \
582 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
584 return CLASS<T1,T2>::New(name); \
586 CLASS ## Descriptor() \
588 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
589 <<bbtk::TypeName<T1>()<<"," \
590 <<bbtk::TypeName<T2>()<<">::" \
591 <<#CLASS<<"Descriptor()"<<std::endl);
592 //============================================================================
594 //============================================================================
595 /// Ends a template AtomicBlackBox description block of template param T1 and T2
596 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
597 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
598 <<bbtk::TypeName<T1>()<<"," \
599 <<bbtk::TypeName<T2>()<<">::" \
600 <<#CLASS<<"Descriptor()"<<std::endl); \
604 //============================================================================
609 //============================================================================
610 // Two template params user black boxes macros
612 /// Begins a template AtomicBlackBox description block of template param T1 and T2
613 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
614 template <TYPE1 T1, TYPE2 T2> \
615 class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
618 virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
622 static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
624 static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
625 bbtk:AtomicBlackBoxDescriptor::Pointer j; \
626 if (!i.lock()) { j = Self::New(); i = j; } \
629 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
631 return new CLASS<T1,T2>(name); \
633 CLASS ## Descriptor() \
635 bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
636 <<"Descriptor()"<<std::endl)
637 //============================================================================
639 //============================================================================
640 /// Ends a template AtomicBlackBox description block of template param T1 and T2
641 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
642 bbtkDecTab("Kernel",9); \
646 //============================================================================
650 //============================================================================
651 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
652 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE) \
653 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
654 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
655 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
656 (&CLASS<T1,T2>::bbGetInput##NAME), \
657 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
658 (&CLASS<T1,T2>::bbSetInput##NAME) ) )
659 //============================================================================
661 //============================================================================
662 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
663 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE) \
664 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
665 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
666 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
667 (&CLASS<T1,T2>::bbGetOutput##NAME), \
668 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
669 (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
670 //============================================================================
672 //============================================================================
673 /// Template AtomicBlackBox std implementation of ctor and dtor
674 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
675 template <class T1, class T2> \
676 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
677 : PARENT(name,false) \
679 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
680 CLASS<T1,T2>::bbUserConstructor(); \
681 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
683 template <class T1, class T2> \
684 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
685 const std::string& name, bool allocate_connectors) \
686 : PARENT(from,name,false) \
688 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
689 CLASS<T1,T2>::bbUserCopyConstructor(); \
690 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
692 template <class T1, class T2> \
693 CLASS<T1,T2>::~CLASS() \
695 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
696 CLASS<T1,T2>::bbUserDestructor(); \
697 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
699 template <class T1, class T2> \
700 void CLASS<T1,T2>::bbLockDescriptor() \
702 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
704 //============================================================================
708 //============================================================================
709 /// Template AtomicBlackBox std implementation of ctor and dtor
710 #define BBTK_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
711 template <TYPE1 T1, TYPE2 T2> \
712 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
713 : PARENT(name,false) \
715 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
716 this->bbUserConstructor(); \
717 BBTK_END_BLACK_BOX_CONSTRUCTOR; \
719 template <TYPE1 T1, TYPE2 T2> \
720 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
721 const std::string& name, bool allocate_connectors) \
722 : PARENT(from,name,false) \
724 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
725 this->bbUserCopyConstructor(); \
726 BBTK_END_BLACK_BOX_CONSTRUCTOR; \
728 template <TYPE1 T1, TYPE2 T2> \
729 CLASS<T1,T2>::~CLASS() \
731 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
732 this->bbUserDestructor(); \
733 BBTK_END_BLACK_BOX_DESTRUCTOR; \
735 template <class T1, class T2> \
736 void CLASS<T1,T2>::bbLockDescriptor() \
738 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
740 //============================================================================
750 //===========================================================================
752 //===========================================================================