1 /*=========================================================================
3 Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
5 Date: $Date: 2009/06/10 11:36:51 $
6 Version: $Revision: 1.19 $
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 bbUserSetDefaultValues(); \
57 virtual void bbUserInitializeProcessing(); \
58 virtual void bbUserFinalizeProcessing(); \
59 virtual void bbRecursiveInitializeProcessing() \
61 PARENT::bbRecursiveInitializeProcessing(); \
62 CLASS::bbUserInitializeProcessing(); \
64 virtual void bbRecursiveFinalizeProcessing() \
66 CLASS::bbUserFinalizeProcessing(); \
67 PARENT::bbRecursiveFinalizeProcessing(); \
70 CLASS() : PARENT("") {} \
71 CLASS(const CLASS&) : PARENT("") {}
73 //============================================================================
75 //============================================================================
76 /// Declares the standard interface of a AtomicBlackBox
77 /// (ctor, New, descriptor related methods)
78 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT) \
79 BBTK_OBJECT_MINIMAL_INTERFACE; \
82 CLASS(const std::string& name, bool allocate_connectors = true); \
83 CLASS(Self& from, const std::string& name, \
84 bool allocate_connectors = true); \
87 std::string GetObjectName() const \
88 { return std::string(#CLASS)+std::string(" '") \
89 +bbGetNameWithParent()+std::string("'"); } \
90 inline static Pointer New(const std::string& name) \
92 bbtkDebugMessage("object",1,"##> "<<#CLASS \
93 <<"::New(\""<<name<<"\")"<<std::endl); \
94 Pointer p = MakeBlackBoxPointer(new Self(name)); \
95 bbtkDebugMessage("object",1,"<## "<<#CLASS \
96 <<"::New(\""<<name<<"\")"<<std::endl); \
99 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
101 bbtkBlackBoxDebugMessage("object",1,"##> "<<#CLASS \
102 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
103 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
104 bbtkBlackBoxDebugMessage("object",1,"<## "<<#CLASS \
105 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
108 virtual void bbLockDescriptor(); \
109 virtual void bbUserSetDefaultValues(); \
110 virtual void bbUserInitializeProcessing(); \
111 virtual void bbUserFinalizeProcessing(); \
112 virtual void bbRecursiveInitializeProcessing() \
114 PARENT::bbRecursiveInitializeProcessing(); \
115 CLASS::bbUserInitializeProcessing(); \
117 virtual void bbRecursiveFinalizeProcessing() \
119 CLASS::bbUserFinalizeProcessing(); \
120 PARENT::bbRecursiveFinalizeProcessing(); \
123 CLASS() : PARENT("") {} \
124 CLASS(const CLASS&) : PARENT("") {}
126 //============================================================================
128 //============================================================================
129 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
130 public : typedef CLASS Self; \
131 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
132 //============================================================================
134 //============================================================================
135 #define BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENT) \
136 public : typedef CLASS Self; \
137 BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT);
138 //============================================================================
140 //============================================================================
141 /// Defines the bbUserProcess method
142 #define BBTK_PROCESS(CALLBACK) \
144 inline void bbUserProcess() \
146 bbtkBlackBoxDebugMessage("process",1,"**> Processing..." \
149 bbtkBlackBoxDebugMessage("process",1,"<** Processing" \
152 //============================================================================
155 //============================================================================
156 /// Declares a new AtomicBlackBox input (to be put in the class interface)
157 #define BBTK_DECLARE_INPUT(NAME,TYPE) \
159 TYPE bbmInput##NAME; \
161 TYPE bbGetInput##NAME () \
162 { return bbmInput##NAME; } \
163 void bbSetInput##NAME (TYPE d) \
164 { bbmInput##NAME = d; \
165 /*bbSetModifiedStatus();*/ }
166 //============================================================================
168 //============================================================================
169 /// Declares a new AtomicBlackBox output (to be put in the class interface)
170 #define BBTK_DECLARE_OUTPUT(NAME,TYPE) \
172 TYPE bbmOutput##NAME; \
174 TYPE bbGetOutput##NAME () \
175 { return bbmOutput##NAME; } \
176 void bbSetOutput##NAME (TYPE d) \
177 { bbmOutput##NAME = d; }
178 //============================================================================
180 //============================================================================
181 /// Declares an inherited AtomicBlackBox input (to be put in the class interface)
182 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
184 TYPE bbGetInput##NAME () \
185 { return GETMETHOD(); } \
186 void bbSetInput##NAME (TYPE d) \
188 /*bbSetModifiedStatus();*/ }
189 //============================================================================
192 //============================================================================
193 /// Declares an inherited AtomicBlackBox output (to be put in the class interface)
194 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
196 TYPE bbGetOutput##NAME () const \
197 { return GETMETHOD(); } \
198 void bbSetOutput##NAME (TYPE d) \
200 //============================================================================
204 //============================================================================
205 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC) \
206 bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
207 <<"()"<<std::endl); \
210 bbLockDescriptor(); \
211 bbAllocateConnectors(); \
214 //============================================================================
216 //============================================================================
217 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS) \
218 bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
220 //============================================================================
222 //============================================================================
223 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
224 bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
225 <<"("<<FROM.bbGetFullName() \
229 bbLockDescriptor(); \
230 bbAllocateConnectors(); \
232 //============================================================================
234 //============================================================================
235 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
236 bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
237 <<"("<<FROM.bbGetFullName() \
241 bbCopyIOValues(FROM); \
243 //============================================================================
245 //============================================================================
246 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
247 bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
248 <<"()"<<std::endl); \
249 bbFinalizeProcessing();
252 //============================================================================
254 //============================================================================
255 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS) \
256 bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS \
259 //============================================================================
262 //============================================================================
263 /// AtomicBlackBox std implementation of ctor and dtor
264 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
265 CLASS::CLASS(const std::string& name, bool allocate_connectors) \
266 : PARENT(name,false) \
268 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \
269 CLASS::bbUserSetDefaultValues(); \
270 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
272 CLASS::CLASS(CLASS& from, \
273 const std::string& name, bool allocate_connectors) \
274 : PARENT(from,name,false) \
276 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
277 CLASS::bbUserSetDefaultValues(); \
278 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
282 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
283 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
285 void CLASS::bbLockDescriptor() \
287 bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \
289 //============================================================================
292 //============================================================================
293 /// Begins the AtomicBlackBox description block
294 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS) \
296 public: typedef CLASS ## Descriptor Self; \
297 BBTK_OBJECT_MINIMAL_INTERFACE; \
299 std::string GetObjectName() const \
301 return std::string(BBTK_STRINGIFY(CLASS)) \
302 +std::string("Descriptor '")+GetFullTypeName() \
305 size_t GetObjectSize() const { return sizeof(*this); } \
306 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
308 return CLASS::New(name); \
310 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
314 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
316 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
317 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
318 if (!i.lock()) { j = Self::New(); i = j; } \
321 static CLASS ## Descriptor::Pointer New() \
323 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
324 <<"Descriptor::New" <<std::endl); \
325 CLASS ## Descriptor::Pointer p = \
326 MakePointer(new CLASS ## Descriptor()); \
327 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
328 <<"Descriptor::New" <<std::endl); \
332 CLASS ## Descriptor() \
334 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
335 <<#CLASS<<"Descriptor()"<<std::endl);
336 //============================================================================
338 //============================================================================
339 /// Begins the AtomicBlackBox description block
340 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT) \
341 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
342 BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS);
344 //============================================================================
345 /// Ends the AtomicBlackBox description block
346 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
347 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
348 <<#CLASS<<"Descriptor()"<<std::endl); \
352 //============================================================================
355 //============================================================================
356 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
357 #define BBTK_NAME(NAME) SetTypeName(NAME)
358 //============================================================================
360 //============================================================================
361 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
362 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
363 //============================================================================
365 //============================================================================
366 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
367 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
368 //============================================================================
370 //============================================================================
371 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
372 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
373 //============================================================================
375 //============================================================================
376 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
377 //#define BBTK_KIND(KIND) SetKind(KIND)
378 //============================================================================
380 //============================================================================
381 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
382 #define BBTK_ADAPTOR() \
383 SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
384 AddToCategory("adaptor")
385 //============================================================================
387 //============================================================================
388 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
389 #define BBTK_DEFAULT_ADAPTOR() \
390 SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR); \
391 AddToCategory("adaptor")
392 //============================================================================
395 //============================================================================
396 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
397 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
398 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
399 (typeid(CLASS ## Descriptor), \
400 #NAME,DESCR,NATURE, \
401 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
402 (&CLASS::bbGetInput##NAME), \
403 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
404 (&CLASS::bbSetInput##NAME) ) )
405 //============================================================================
407 //============================================================================
408 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
409 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
410 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
411 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
412 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
413 (&CLASS::bbGetOutput##NAME), \
414 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
415 (&CLASS::bbSetOutput##NAME) ) )
416 //============================================================================
419 //============================================================================
420 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
421 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
422 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
423 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
424 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
425 (&CLASS::bbGetInput##NAME), \
426 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
427 (&CLASS::bbSetInput##NAME), \
429 //============================================================================
431 //============================================================================
432 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
433 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
434 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
435 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
436 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
437 (&CLASS::bbGetOutput##NAME), \
438 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
439 (&CLASS::bbSetOutput##NAME),\
441 //============================================================================
452 //============================================================================
453 //============================================================================
454 // Template user black boxes macros
455 //============================================================================
456 //============================================================================
458 //============================================================================
459 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
460 public : typedef CLASS<T> Self; \
461 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
462 //============================================================================
464 //============================================================================
465 /// Begins a template AtomicBlackBox of template param T description block
466 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
468 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
470 public: typedef CLASS ## Descriptor<T> Self; \
471 BBTK_OBJECT_MINIMAL_INTERFACE; \
473 std::string GetObjectName() const \
475 return std::string(BBTK_STRINGIFY(CLASS)) \
476 +std::string("Descriptor<")+bbtk::TypeName<T>() \
477 +std::string("> '")+GetFullTypeName() \
480 static Pointer New() \
482 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
483 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
485 Pointer p = MakePointer(new Self()); \
486 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
487 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
491 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
495 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
497 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
498 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
499 if (!i.lock()) { j = Self::New(); i = j; } \
502 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
504 return CLASS<T>::New(name); \
506 CLASS ## Descriptor() \
508 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
509 <<bbtk::TypeName<T>()<<">::" \
510 <<#CLASS<<"Descriptor()"<<std::endl);
512 //============================================================================
514 //============================================================================
515 /// Ends a template AtomicBlackBox of template param T description block
516 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
517 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
518 <<bbtk::TypeName<T>()<<">::" \
519 <<#CLASS<<"Descriptor()"<<std::endl); \
523 //============================================================================
525 //============================================================================
526 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
527 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE) \
528 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
529 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
530 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
531 (&CLASS<T>::bbGetInput##NAME), \
532 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
533 (&CLASS<T>::bbSetInput##NAME) ) )
534 //============================================================================
536 //============================================================================
537 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
538 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE) \
539 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
540 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
541 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
542 (&CLASS<T>::bbGetOutput##NAME), \
543 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
544 (&CLASS<T>::bbSetOutput##NAME) ) )
545 //============================================================================
548 //JCP 09JUIN2009 BBTK_EXPORT
550 //============================================================================
551 /// Template AtomicBlackBox std implementation of ctor and dtor
552 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
554 CLASS<T>::CLASS(const std::string& name, bool alloc) \
555 : PARENT(name,false) \
557 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
558 CLASS<T>::bbUserSetDefaultValues(); \
559 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
562 CLASS<T>::CLASS(CLASS<T>& from, \
563 const std::string& name, bool allocate_connectors) \
564 : PARENT(from,name,false) \
566 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
567 CLASS<T>::bbUserSetDefaultValues(); \
568 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
573 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
574 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
577 void CLASS<T>::bbLockDescriptor() \
579 bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
581 //============================================================================
585 //============================================================================
586 // Two template params user black boxes macros
587 //============================================================================
589 //============================================================================
590 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
591 public : typedef CLASS<T1,T2> Self; \
592 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
593 //===========================================================================
595 //============================================================================
596 /// Begins a template AtomicBlackBox description block of template param T1 and T2
597 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
598 template <class T1, class T2> \
599 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
601 public: typedef CLASS ## Descriptor<T1,T2> Self; \
602 BBTK_OBJECT_MINIMAL_INTERFACE; \
604 std::string GetObjectName() const \
606 return std::string(BBTK_STRINGIFY(CLASS)) \
607 +std::string("Descriptor<")+bbtk::TypeName<T1>() \
608 +std::string(",")+bbtk::TypeName<T2>() \
609 +std::string("> '")+GetFullTypeName() \
612 static Pointer New() \
614 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
615 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
616 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
617 Pointer p = MakePointer(new Self()); \
618 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
619 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
620 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
623 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
627 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
629 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
630 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
631 if (!i.lock()) { j = Self::New(); i = j; } \
634 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
636 return CLASS<T1,T2>::New(name); \
638 CLASS ## Descriptor() \
640 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
641 <<bbtk::TypeName<T1>()<<"," \
642 <<bbtk::TypeName<T2>()<<">::" \
643 <<#CLASS<<"Descriptor()"<<std::endl);
644 //============================================================================
646 //============================================================================
647 /// Ends a template AtomicBlackBox description block of template param T1 and T2
648 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
649 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
650 <<bbtk::TypeName<T1>()<<"," \
651 <<bbtk::TypeName<T2>()<<">::" \
652 <<#CLASS<<"Descriptor()"<<std::endl); \
656 //============================================================================
661 //============================================================================
662 // Two template params user black boxes macros
664 /// Begins a template AtomicBlackBox description block of template param T1 and T2
665 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
666 template <TYPE1 T1, TYPE2 T2> \
667 class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
670 virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
674 static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
676 static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
677 bbtk:AtomicBlackBoxDescriptor::Pointer j; \
678 if (!i.lock()) { j = Self::New(); i = j; } \
681 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
683 return new CLASS<T1,T2>(name); \
685 CLASS ## Descriptor() \
687 bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
688 <<"Descriptor()"<<std::endl)
689 //============================================================================
691 //============================================================================
692 /// Ends a template AtomicBlackBox description block of template param T1 and T2
693 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
694 bbtkDecTab("Kernel",9); \
698 //============================================================================
702 //============================================================================
703 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
704 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE) \
705 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
706 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
707 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
708 (&CLASS<T1,T2>::bbGetInput##NAME), \
709 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
710 (&CLASS<T1,T2>::bbSetInput##NAME) ) )
711 //============================================================================
713 //============================================================================
714 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
715 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE) \
716 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
717 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
718 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
719 (&CLASS<T1,T2>::bbGetOutput##NAME), \
720 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
721 (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
722 //============================================================================
724 //============================================================================
725 /// Template AtomicBlackBox std implementation of ctor and dtor
726 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
727 template <class T1, class T2> \
728 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
729 : PARENT(name,false) \
731 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
732 CLASS<T1,T2>::bbUserSetDefaultValues(); \
733 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
735 template <class T1, class T2> \
736 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
737 const std::string& name, bool allocate_connectors) \
738 : PARENT(from,name,false) \
740 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
741 CLASS<T1,T2>::bbUserSetDefaultValues(); \
742 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
744 template <class T1, class T2> \
745 CLASS<T1,T2>::~CLASS() \
747 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
748 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
750 template <class T1, class T2> \
751 void CLASS<T1,T2>::bbLockDescriptor() \
753 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
755 //============================================================================
761 //===========================================================================
763 //===========================================================================