1 /*=========================================================================
3 Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
5 Date: $Date: 2009/04/30 14:31:30 $
6 Version: $Revision: 1.15 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
35 * \brief Defines macros for the creation of new user black boxes
37 #ifndef __bbtkAtomicBlackBoxMacros_h__
38 #define __bbtkAtomicBlackBoxMacros_h__
40 //============================================================================
41 /// Declares the standard interface of a AtomicBlackBox
42 /// (ctor, New, descriptor related methods)
43 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT) \
44 BBTK_OBJECT_MINIMAL_INTERFACE; \
47 CLASS(const std::string& name, bool allocate_connectors = true); \
48 CLASS(Self& from, const std::string& name, \
49 bool allocate_connectors = true); \
52 std::string GetObjectName() const \
53 { return std::string(#CLASS)+std::string(" '") \
54 +bbGetNameWithParent()+std::string("'"); } \
55 virtual void bbLockDescriptor(); \
56 virtual void bbConstructor() { \
57 PARENT::bbConstructor(); \
58 CLASS::bbUserConstructor(); \
60 virtual void bbDestructor() { \
61 PARENT::bbDestructor(); \
62 CLASS::bbUserDestructor(); \
65 CLASS() : PARENT("") {} \
66 CLASS(const CLASS&) : PARENT("") {}
68 //============================================================================
70 //============================================================================
71 /// Declares the standard interface of a AtomicBlackBox
72 /// (ctor, New, descriptor related methods)
73 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT) \
74 BBTK_OBJECT_MINIMAL_INTERFACE; \
77 CLASS(const std::string& name, bool allocate_connectors = true); \
78 CLASS(Self& from, const std::string& name, \
79 bool allocate_connectors = true); \
82 std::string GetObjectName() const \
83 { return std::string(#CLASS)+std::string(" '") \
84 +bbGetNameWithParent()+std::string("'"); } \
85 inline static Pointer New(const std::string& name) \
87 bbtkDebugMessage("object",1,"##> "<<#CLASS \
88 <<"::New(\""<<name<<"\")"<<std::endl); \
89 Pointer p = MakeBlackBoxPointer(new Self(name)); \
90 bbtkDebugMessage("object",1,"<## "<<#CLASS \
91 <<"::New(\""<<name<<"\")"<<std::endl); \
94 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
96 bbtkDebugMessage("object",1,"##> "<<#CLASS \
97 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
98 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
99 bbtkDebugMessage("object",1,"<## "<<#CLASS \
100 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
103 virtual void bbLockDescriptor(); \
104 virtual void bbConstructor() { \
105 PARENT::bbConstructor(); \
106 CLASS::bbUserConstructor(); \
108 virtual void bbDestructor() { \
109 PARENT::bbDestructor(); \
110 CLASS::bbUserDestructor(); \
113 CLASS() : PARENT("") {} \
114 CLASS(const CLASS&) : PARENT("") {}
116 //============================================================================
118 //============================================================================
119 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
120 public : typedef CLASS Self; \
121 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
122 //============================================================================
124 //============================================================================
125 #define BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENT) \
126 public : typedef CLASS Self; \
127 BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT);
128 //============================================================================
130 //============================================================================
131 /// Defines the bbUserProcess method
132 #define BBTK_PROCESS(CALLBACK) \
134 inline void bbUserProcess() \
136 bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName() \
139 bbtkDebugMessage("process",1,"<** Processing ["<<bbGetFullName() \
142 //============================================================================
145 //============================================================================
146 /// Declares a new AtomicBlackBox input (to be put in the class interface)
147 #define BBTK_DECLARE_INPUT(NAME,TYPE) \
149 TYPE bbmInput##NAME; \
151 TYPE bbGetInput##NAME () \
152 { return bbmInput##NAME; } \
153 void bbSetInput##NAME (TYPE d) \
154 { bbmInput##NAME = d; \
155 /*bbSetModifiedStatus();*/ }
156 //============================================================================
158 //============================================================================
159 /// Declares a new AtomicBlackBox output (to be put in the class interface)
160 #define BBTK_DECLARE_OUTPUT(NAME,TYPE) \
162 TYPE bbmOutput##NAME; \
164 TYPE bbGetOutput##NAME () \
165 { return bbmOutput##NAME; } \
166 void bbSetOutput##NAME (TYPE d) \
167 { bbmOutput##NAME = d; }
168 //============================================================================
170 //============================================================================
171 /// Declares an inherited AtomicBlackBox input (to be put in the class interface)
172 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
174 TYPE bbGetInput##NAME () \
175 { return GETMETHOD(); } \
176 void bbSetInput##NAME (TYPE d) \
178 /*bbSetModifiedStatus();*/ }
179 //============================================================================
182 //============================================================================
183 /// Declares an inherited AtomicBlackBox output (to be put in the class interface)
184 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
186 TYPE bbGetOutput##NAME () const \
187 { return GETMETHOD(); } \
188 void bbSetOutput##NAME (TYPE d) \
190 //============================================================================
194 //============================================================================
195 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC) \
196 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
197 <<"(\""<<bbGetName()<<"\")"<<std::endl); \
200 bbLockDescriptor(); \
201 bbAllocateConnectors(); \
203 //============================================================================
205 //============================================================================
206 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS) \
207 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
208 <<"(\""<<bbGetName()<<"\")"<<std::endl);
209 //============================================================================
211 //============================================================================
212 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
213 bbtkDebugMessageInc("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
214 <<"("<<FROM.bbGetFullName()<<",\"" \
215 <<bbGetName()<<"\")"<<std::endl); \
218 bbLockDescriptor(); \
219 bbAllocateConnectors(); \
220 bbCopyIOValues(FROM); \
222 //============================================================================
224 //============================================================================
225 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM) \
226 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
227 <<"("<<FROM.bbGetFullName()<<",\"" \
228 <<bbGetName()<<"\")"<<std::endl);
229 //============================================================================
231 //============================================================================
232 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
233 bbtkDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
234 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
235 //============================================================================
237 //============================================================================
238 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS) \
239 bbtkDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS \
240 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
242 //============================================================================
245 //============================================================================
246 /// AtomicBlackBox std implementation of ctor and dtor
247 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
248 CLASS::CLASS(const std::string& name, bool allocate_connectors) \
249 : PARENT(name,false) \
251 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \
252 /*CLASS::bbUserConstructor(); */ \
253 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
255 CLASS::CLASS(CLASS& from, \
256 const std::string& name, bool allocate_connectors) \
257 : PARENT(from,name,false) \
259 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
260 /*CLASS::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>());*/ \
261 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
265 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
266 /*CLASS::bbUserDestructor();*/ \
267 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
269 void CLASS::bbLockDescriptor() \
271 bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \
273 //============================================================================
276 //============================================================================
277 /// Begins the AtomicBlackBox description block
278 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS) \
280 public: typedef CLASS ## Descriptor Self; \
281 BBTK_OBJECT_MINIMAL_INTERFACE; \
283 std::string GetObjectName() const \
285 return std::string(BBTK_STRINGIFY(CLASS)) \
286 +std::string("Descriptor '")+GetFullTypeName() \
289 size_t GetObjectSize() const { return sizeof(*this); } \
290 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
292 return CLASS::New(name); \
294 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
298 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
300 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
301 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
302 if (!i.lock()) { j = Self::New(); i = j; } \
305 static CLASS ## Descriptor::Pointer New() \
307 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
308 <<"Descriptor::New" <<std::endl); \
309 CLASS ## Descriptor::Pointer p = \
310 MakePointer(new CLASS ## Descriptor()); \
311 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
312 <<"Descriptor::New" <<std::endl); \
316 CLASS ## Descriptor() \
318 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
319 <<#CLASS<<"Descriptor()"<<std::endl);
320 //============================================================================
322 //============================================================================
323 /// Begins the AtomicBlackBox description block
324 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT) \
325 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
326 BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS);
328 //============================================================================
329 /// Ends the AtomicBlackBox description block
330 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
331 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
332 <<#CLASS<<"Descriptor()"<<std::endl); \
336 //============================================================================
339 //============================================================================
340 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
341 #define BBTK_NAME(NAME) SetTypeName(NAME)
342 //============================================================================
344 //============================================================================
345 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
346 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
347 //============================================================================
349 //============================================================================
350 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
351 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
352 //============================================================================
354 //============================================================================
355 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
356 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
357 //============================================================================
359 //============================================================================
360 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
361 //#define BBTK_KIND(KIND) SetKind(KIND)
362 //============================================================================
364 //============================================================================
365 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
366 #define BBTK_ADAPTOR() \
367 SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
368 AddToCategory("adaptor")
369 //============================================================================
371 //============================================================================
372 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
373 #define BBTK_DEFAULT_ADAPTOR() \
374 SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR); \
375 AddToCategory("adaptor")
376 //============================================================================
379 //============================================================================
380 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
381 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
382 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
383 (typeid(CLASS ## Descriptor), \
384 #NAME,DESCR,NATURE, \
385 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
386 (&CLASS::bbGetInput##NAME), \
387 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
388 (&CLASS::bbSetInput##NAME) ) )
389 //============================================================================
391 //============================================================================
392 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
393 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
394 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
395 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
396 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
397 (&CLASS::bbGetOutput##NAME), \
398 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
399 (&CLASS::bbSetOutput##NAME) ) )
400 //============================================================================
403 //============================================================================
404 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
405 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
406 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
407 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
408 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
409 (&CLASS::bbGetInput##NAME), \
410 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
411 (&CLASS::bbSetInput##NAME), \
413 //============================================================================
415 //============================================================================
416 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
417 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
418 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
419 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
420 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
421 (&CLASS::bbGetOutput##NAME), \
422 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
423 (&CLASS::bbSetOutput##NAME),\
425 //============================================================================
436 //============================================================================
437 //============================================================================
438 // Template user black boxes macros
439 //============================================================================
440 //============================================================================
442 //============================================================================
443 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
444 public : typedef CLASS<T> Self; \
445 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
446 //============================================================================
448 //============================================================================
449 /// Begins a template AtomicBlackBox of template param T description block
450 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
452 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
454 public: typedef CLASS ## Descriptor<T> Self; \
455 BBTK_OBJECT_MINIMAL_INTERFACE; \
457 std::string GetObjectName() const \
459 return std::string(BBTK_STRINGIFY(CLASS)) \
460 +std::string("Descriptor<")+bbtk::TypeName<T>() \
461 +std::string("> '")+GetFullTypeName() \
464 static Pointer New() \
466 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
467 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
469 Pointer p = MakePointer(new Self()); \
470 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
471 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
475 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
479 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
481 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
482 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
483 if (!i.lock()) { j = Self::New(); i = j; } \
486 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
488 return CLASS<T>::New(name); \
490 CLASS ## Descriptor() \
492 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
493 <<bbtk::TypeName<T>()<<">::" \
494 <<#CLASS<<"Descriptor()"<<std::endl);
496 //============================================================================
498 //============================================================================
499 /// Ends a template AtomicBlackBox of template param T description block
500 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
501 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
502 <<bbtk::TypeName<T>()<<">::" \
503 <<#CLASS<<"Descriptor()"<<std::endl); \
507 //============================================================================
509 //============================================================================
510 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
511 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE) \
512 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
513 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
514 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
515 (&CLASS<T>::bbGetInput##NAME), \
516 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
517 (&CLASS<T>::bbSetInput##NAME) ) )
518 //============================================================================
520 //============================================================================
521 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
522 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE) \
523 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
524 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
525 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
526 (&CLASS<T>::bbGetOutput##NAME), \
527 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
528 (&CLASS<T>::bbSetOutput##NAME) ) )
529 //============================================================================
531 //============================================================================
532 /// Template AtomicBlackBox std implementation of ctor and dtor
533 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
535 CLASS<T>::CLASS(const std::string& name, bool alloc) \
536 : PARENT(name,false) \
538 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
539 /*CLASS<T>::bbUserConstructor();*/ \
540 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
543 CLASS<T>::CLASS(CLASS<T>& from, \
544 const std::string& name, bool allocate_connectors) \
545 : PARENT(from,name,false) \
547 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
548 /*CLASS<T>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>());*/ \
549 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
554 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
555 /*CLASS<T>::bbUserDestructor();*/ \
556 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
559 void CLASS<T>::bbLockDescriptor() \
561 bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
563 //============================================================================
567 //============================================================================
568 // Two template params user black boxes macros
569 //============================================================================
571 //============================================================================
572 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
573 public : typedef CLASS<T1,T2> Self; \
574 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
575 //===========================================================================
577 //============================================================================
578 /// Begins a template AtomicBlackBox description block of template param T1 and T2
579 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
580 template <class T1, class T2> \
581 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
583 public: typedef CLASS ## Descriptor<T1,T2> Self; \
584 BBTK_OBJECT_MINIMAL_INTERFACE; \
586 std::string GetObjectName() const \
588 return std::string(BBTK_STRINGIFY(CLASS)) \
589 +std::string("Descriptor<")+bbtk::TypeName<T1>() \
590 +std::string(",")+bbtk::TypeName<T2>() \
591 +std::string("> '")+GetFullTypeName() \
594 static Pointer New() \
596 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
597 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
598 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
599 Pointer p = MakePointer(new Self()); \
600 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
601 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
602 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
605 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
609 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
611 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
612 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
613 if (!i.lock()) { j = Self::New(); i = j; } \
616 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
618 return CLASS<T1,T2>::New(name); \
620 CLASS ## Descriptor() \
622 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
623 <<bbtk::TypeName<T1>()<<"," \
624 <<bbtk::TypeName<T2>()<<">::" \
625 <<#CLASS<<"Descriptor()"<<std::endl);
626 //============================================================================
628 //============================================================================
629 /// Ends a template AtomicBlackBox description block of template param T1 and T2
630 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
631 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
632 <<bbtk::TypeName<T1>()<<"," \
633 <<bbtk::TypeName<T2>()<<">::" \
634 <<#CLASS<<"Descriptor()"<<std::endl); \
638 //============================================================================
643 //============================================================================
644 // Two template params user black boxes macros
646 /// Begins a template AtomicBlackBox description block of template param T1 and T2
647 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
648 template <TYPE1 T1, TYPE2 T2> \
649 class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
652 virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
656 static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
658 static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
659 bbtk:AtomicBlackBoxDescriptor::Pointer j; \
660 if (!i.lock()) { j = Self::New(); i = j; } \
663 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
665 return new CLASS<T1,T2>(name); \
667 CLASS ## Descriptor() \
669 bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
670 <<"Descriptor()"<<std::endl)
671 //============================================================================
673 //============================================================================
674 /// Ends a template AtomicBlackBox description block of template param T1 and T2
675 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
676 bbtkDecTab("Kernel",9); \
680 //============================================================================
684 //============================================================================
685 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
686 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE) \
687 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
688 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
689 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
690 (&CLASS<T1,T2>::bbGetInput##NAME), \
691 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
692 (&CLASS<T1,T2>::bbSetInput##NAME) ) )
693 //============================================================================
695 //============================================================================
696 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
697 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE) \
698 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
699 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
700 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
701 (&CLASS<T1,T2>::bbGetOutput##NAME), \
702 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
703 (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
704 //============================================================================
706 //============================================================================
707 /// Template AtomicBlackBox std implementation of ctor and dtor
708 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
709 template <class T1, class T2> \
710 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
711 : PARENT(name,false) \
713 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
714 /*CLASS<T1,T2>::bbUserConstructor();*/ \
715 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
717 template <class T1, class T2> \
718 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
719 const std::string& name, bool allocate_connectors) \
720 : PARENT(from,name,false) \
722 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
723 /*CLASS<T1,T2>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>());*/ \
724 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
726 template <class T1, class T2> \
727 CLASS<T1,T2>::~CLASS() \
729 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
730 /*CLASS<T1,T2>::bbUserDestructor();*/ \
731 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
733 template <class T1, class T2> \
734 void CLASS<T1,T2>::bbLockDescriptor() \
736 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
738 //============================================================================
744 //===========================================================================
746 //===========================================================================