2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.20 $
34 =========================================================================*/
42 * \brief Defines macros for the creation of new user black boxes
44 #ifndef __bbtkAtomicBlackBoxMacros_h__
45 #define __bbtkAtomicBlackBoxMacros_h__
47 //============================================================================
48 /// Declares the standard interface of a AtomicBlackBox
49 /// (ctor, New, descriptor related methods)
50 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT) \
51 BBTK_OBJECT_MINIMAL_INTERFACE; \
54 CLASS(const std::string& name, bool allocate_connectors = true); \
55 CLASS(Self& from, const std::string& name, \
56 bool allocate_connectors = true); \
59 std::string GetObjectName() const \
60 { return std::string(#CLASS)+std::string(" '") \
61 +bbGetNameWithParent()+std::string("'"); } \
62 virtual void bbLockDescriptor(); \
63 virtual void bbUserSetDefaultValues(); \
64 virtual void bbUserInitializeProcessing(); \
65 virtual void bbUserFinalizeProcessing(); \
66 virtual void bbRecursiveInitializeProcessing() \
68 PARENT::bbRecursiveInitializeProcessing(); \
69 CLASS::bbUserInitializeProcessing(); \
71 virtual void bbRecursiveFinalizeProcessing() \
73 CLASS::bbUserFinalizeProcessing(); \
74 PARENT::bbRecursiveFinalizeProcessing(); \
77 CLASS() : PARENT("") {} \
78 CLASS(const CLASS&) : PARENT("") {}
80 //============================================================================
84 //============================================================================
85 /// Declares the standard interface of a AtomicBlackBox
86 /// (ctor, New, descriptor related methods)
88 //EED 2017-08-29 itk3to4
90 std::string GetObjectName() const \
93 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT) \
94 BBTK_OBJECT_MINIMAL_INTERFACE; \
97 CLASS(const std::string& name, bool allocate_connectors = true); \
98 CLASS(Self& from, const std::string& name, \
99 bool allocate_connectors = true); \
102 std::string GetObjectName() \
103 { return std::string(#CLASS)+std::string(" '") \
104 +bbGetNameWithParent()+std::string("'"); } \
105 inline static Pointer New(const std::string& name) \
107 bbtkDebugMessage("object",1,"##> "<<#CLASS \
108 <<"::New(\""<<name<<"\")"<<std::endl); \
109 Pointer p = MakeBlackBoxPointer(new Self(name)); \
110 bbtkDebugMessage("object",1,"<## "<<#CLASS \
111 <<"::New(\""<<name<<"\")"<<std::endl); \
114 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
116 bbtkBlackBoxDebugMessage("object",1,"##> "<<#CLASS \
117 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
118 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
119 bbtkBlackBoxDebugMessage("object",1,"<## "<<#CLASS \
120 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
123 virtual void bbLockDescriptor(); \
124 virtual void bbUserSetDefaultValues(); \
125 virtual void bbUserInitializeProcessing(); \
126 virtual void bbUserFinalizeProcessing(); \
127 virtual void bbRecursiveInitializeProcessing() \
129 PARENT::bbRecursiveInitializeProcessing(); \
130 CLASS::bbUserInitializeProcessing(); \
132 virtual void bbRecursiveFinalizeProcessing() \
134 CLASS::bbUserFinalizeProcessing(); \
135 PARENT::bbRecursiveFinalizeProcessing(); \
138 CLASS() : PARENT("") {} \
139 CLASS(const CLASS&) : PARENT("") {}
141 //============================================================================
143 //============================================================================
144 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
145 public : typedef CLASS Self; \
146 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
147 //============================================================================
149 //============================================================================
150 #define BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENT) \
151 public : typedef CLASS Self; \
152 BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT);
153 //============================================================================
155 //============================================================================
156 /// Defines the bbUserProcess method
157 #define BBTK_PROCESS(CALLBACK) \
159 inline void bbUserProcess() \
161 bbtkBlackBoxDebugMessage("process",1,"**> Processing..." \
164 bbtkBlackBoxDebugMessage("process",1,"<** Processing" \
167 //============================================================================
170 //============================================================================
171 /// Declares a new AtomicBlackBox input (to be put in the class interface)
172 #define BBTK_DECLARE_INPUT(NAME,TYPE) \
174 TYPE bbmInput##NAME; \
176 TYPE bbGetInput##NAME () \
177 { return bbmInput##NAME; } \
178 void bbSetInput##NAME (TYPE d) \
179 { bbmInput##NAME = d; \
180 /*bbSetModifiedStatus();*/ }
181 //============================================================================
183 //============================================================================
184 /// Declares a new AtomicBlackBox output (to be put in the class interface)
185 #define BBTK_DECLARE_OUTPUT(NAME,TYPE) \
187 TYPE bbmOutput##NAME; \
189 TYPE bbGetOutput##NAME () \
190 { return bbmOutput##NAME; } \
191 void bbSetOutput##NAME (TYPE d) \
192 { bbmOutput##NAME = d; }
193 //============================================================================
195 //============================================================================
196 /// Declares an inherited AtomicBlackBox input (to be put in the class interface)
197 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
199 TYPE bbGetInput##NAME () \
200 { return GETMETHOD(); } \
201 void bbSetInput##NAME (TYPE d) \
203 /*bbSetModifiedStatus();*/ }
204 //============================================================================
207 //============================================================================
208 /// Declares an inherited AtomicBlackBox output (to be put in the class interface)
209 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
211 TYPE bbGetOutput##NAME () const \
212 { return GETMETHOD(); } \
213 void bbSetOutput##NAME (TYPE d) \
215 //============================================================================
219 //============================================================================
220 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC) \
221 bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
222 <<"()"<<std::endl); \
225 bbLockDescriptor(); \
226 bbAllocateConnectors(); \
229 //============================================================================
231 //============================================================================
232 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS) \
233 bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
235 //============================================================================
237 //============================================================================
238 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
239 bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
240 <<"("<<FROM.bbGetFullName() \
244 bbLockDescriptor(); \
245 bbAllocateConnectors(); \
247 //============================================================================
249 //============================================================================
250 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
251 bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
252 <<"("<<FROM.bbGetFullName() \
256 bbCopyIOValues(FROM); \
258 //============================================================================
260 //============================================================================
261 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
262 bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
263 <<"()"<<std::endl); \
264 bbFinalizeProcessing();
267 //============================================================================
269 //============================================================================
270 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS) \
271 bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS \
274 //============================================================================
277 //============================================================================
278 /// AtomicBlackBox std implementation of ctor and dtor
279 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
280 CLASS::CLASS(const std::string& name, bool allocate_connectors) \
281 : PARENT(name,false) \
283 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \
284 CLASS::bbUserSetDefaultValues(); \
285 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
287 CLASS::CLASS(CLASS& from, \
288 const std::string& name, bool allocate_connectors) \
289 : PARENT(from,name,false) \
291 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
292 CLASS::bbUserSetDefaultValues(); \
293 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
297 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
298 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
300 void CLASS::bbLockDescriptor() \
302 bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \
304 //============================================================================
307 //============================================================================
308 /// Begins the AtomicBlackBox description block
309 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS) \
311 public: typedef CLASS ## Descriptor Self; \
312 BBTK_OBJECT_MINIMAL_INTERFACE; \
314 std::string GetObjectName() const \
316 return std::string(BBTK_STRINGIFY(CLASS)) \
317 +std::string("Descriptor '")+GetFullTypeName() \
320 size_t GetObjectSize() const { return sizeof(*this); } \
321 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
323 return CLASS::New(name); \
325 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
329 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
331 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
332 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
333 if (!i.lock()) { j = Self::New(); i = j; } \
336 static CLASS ## Descriptor::Pointer New() \
338 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
339 <<"Descriptor::New" <<std::endl); \
340 CLASS ## Descriptor::Pointer p = \
341 MakePointer(new CLASS ## Descriptor()); \
342 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
343 <<"Descriptor::New" <<std::endl); \
347 CLASS ## Descriptor() \
349 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
350 <<#CLASS<<"Descriptor()"<<std::endl);
351 //============================================================================
353 //============================================================================
354 /// Begins the AtomicBlackBox description block
355 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT) \
356 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
357 BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS);
359 //============================================================================
360 /// Ends the AtomicBlackBox description block
361 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
362 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
363 <<#CLASS<<"Descriptor()"<<std::endl); \
367 //============================================================================
370 //============================================================================
371 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
372 #define BBTK_NAME(NAME) SetTypeName(NAME)
373 //============================================================================
375 //============================================================================
376 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
377 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
378 //============================================================================
380 //============================================================================
381 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
382 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
383 //============================================================================
385 //============================================================================
386 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
387 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
388 //============================================================================
390 //============================================================================
391 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
392 //#define BBTK_KIND(KIND) SetKind(KIND)
393 //============================================================================
395 //============================================================================
396 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
397 #define BBTK_ADAPTOR() \
398 SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
399 AddToCategory("adaptor")
400 //============================================================================
402 //============================================================================
403 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
404 #define BBTK_DEFAULT_ADAPTOR() \
405 SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR); \
406 AddToCategory("adaptor")
407 //============================================================================
410 //============================================================================
411 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
412 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
413 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
414 (typeid(CLASS ## Descriptor), \
415 #NAME,DESCR,NATURE, \
416 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
417 (&CLASS::bbGetInput##NAME), \
418 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
419 (&CLASS::bbSetInput##NAME) ) )
420 //============================================================================
422 //============================================================================
423 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
424 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
425 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
426 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
427 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
428 (&CLASS::bbGetOutput##NAME), \
429 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
430 (&CLASS::bbSetOutput##NAME) ) )
431 //============================================================================
434 //============================================================================
435 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
436 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
437 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
438 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
439 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
440 (&CLASS::bbGetInput##NAME), \
441 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
442 (&CLASS::bbSetInput##NAME), \
444 //============================================================================
446 //============================================================================
447 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
448 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
449 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
450 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
451 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
452 (&CLASS::bbGetOutput##NAME), \
453 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
454 (&CLASS::bbSetOutput##NAME),\
456 //============================================================================
467 //============================================================================
468 //============================================================================
469 // Template user black boxes macros
470 //============================================================================
471 //============================================================================
473 //============================================================================
474 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
475 public : typedef CLASS<T> Self; \
476 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
477 //============================================================================
479 //============================================================================
480 /// Begins a template AtomicBlackBox of template param T description block
481 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
483 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
485 public: typedef CLASS ## Descriptor<T> Self; \
486 BBTK_OBJECT_MINIMAL_INTERFACE; \
488 std::string GetObjectName() const \
490 return std::string(BBTK_STRINGIFY(CLASS)) \
491 +std::string("Descriptor<")+bbtk::TypeName<T>() \
492 +std::string("> '")+GetFullTypeName() \
495 static Pointer New() \
497 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
498 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
500 Pointer p = MakePointer(new Self()); \
501 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
502 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
506 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
510 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
512 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
513 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
514 if (!i.lock()) { j = Self::New(); i = j; } \
517 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
519 return CLASS<T>::New(name); \
521 CLASS ## Descriptor() \
523 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
524 <<bbtk::TypeName<T>()<<">::" \
525 <<#CLASS<<"Descriptor()"<<std::endl);
527 //============================================================================
529 //============================================================================
530 /// Ends a template AtomicBlackBox of template param T description block
531 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
532 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
533 <<bbtk::TypeName<T>()<<">::" \
534 <<#CLASS<<"Descriptor()"<<std::endl); \
538 //============================================================================
540 //============================================================================
541 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
542 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE) \
543 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
544 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
545 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
546 (&CLASS<T>::bbGetInput##NAME), \
547 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
548 (&CLASS<T>::bbSetInput##NAME) ) )
549 //============================================================================
551 //============================================================================
552 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
553 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE) \
554 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
555 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
556 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
557 (&CLASS<T>::bbGetOutput##NAME), \
558 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
559 (&CLASS<T>::bbSetOutput##NAME) ) )
560 //============================================================================
563 //JCP 09JUIN2009 BBTK_EXPORT
565 //============================================================================
566 /// Template AtomicBlackBox std implementation of ctor and dtor
567 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
569 CLASS<T>::CLASS(const std::string& name, bool alloc) \
570 : PARENT(name,false) \
572 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
573 CLASS<T>::bbUserSetDefaultValues(); \
574 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
577 CLASS<T>::CLASS(CLASS<T>& from, \
578 const std::string& name, bool allocate_connectors) \
579 : PARENT(from,name,false) \
581 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
582 CLASS<T>::bbUserSetDefaultValues(); \
583 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
588 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
589 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
592 void CLASS<T>::bbLockDescriptor() \
594 bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
596 //============================================================================
600 //============================================================================
601 // Two template params user black boxes macros
602 //============================================================================
604 //============================================================================
605 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
606 public : typedef CLASS<T1,T2> Self; \
607 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
608 //===========================================================================
610 //============================================================================
611 /// Begins a template AtomicBlackBox description block of template param T1 and T2
612 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
613 template <class T1, class T2> \
614 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
616 public: typedef CLASS ## Descriptor<T1,T2> Self; \
617 BBTK_OBJECT_MINIMAL_INTERFACE; \
619 std::string GetObjectName() const \
621 return std::string(BBTK_STRINGIFY(CLASS)) \
622 +std::string("Descriptor<")+bbtk::TypeName<T1>() \
623 +std::string(",")+bbtk::TypeName<T2>() \
624 +std::string("> '")+GetFullTypeName() \
627 static Pointer New() \
629 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
630 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
631 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
632 Pointer p = MakePointer(new Self()); \
633 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
634 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
635 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
638 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
642 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
644 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
645 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
646 if (!i.lock()) { j = Self::New(); i = j; } \
649 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
651 return CLASS<T1,T2>::New(name); \
653 CLASS ## Descriptor() \
655 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
656 <<bbtk::TypeName<T1>()<<"," \
657 <<bbtk::TypeName<T2>()<<">::" \
658 <<#CLASS<<"Descriptor()"<<std::endl);
659 //============================================================================
661 //============================================================================
662 /// Ends a template AtomicBlackBox description block of template param T1 and T2
663 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
664 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
665 <<bbtk::TypeName<T1>()<<"," \
666 <<bbtk::TypeName<T2>()<<">::" \
667 <<#CLASS<<"Descriptor()"<<std::endl); \
671 //============================================================================
676 //============================================================================
677 // Two template params user black boxes macros
679 /// Begins a template AtomicBlackBox description block of template param T1 and T2
680 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
681 template <TYPE1 T1, TYPE2 T2> \
682 class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
685 virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
689 static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
691 static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
692 bbtk:AtomicBlackBoxDescriptor::Pointer j; \
693 if (!i.lock()) { j = Self::New(); i = j; } \
696 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
698 return new CLASS<T1,T2>(name); \
700 CLASS ## Descriptor() \
702 bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
703 <<"Descriptor()"<<std::endl)
704 //============================================================================
706 //============================================================================
707 /// Ends a template AtomicBlackBox description block of template param T1 and T2
708 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
709 bbtkDecTab("Kernel",9); \
713 //============================================================================
717 //============================================================================
718 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
719 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE) \
720 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
721 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
722 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
723 (&CLASS<T1,T2>::bbGetInput##NAME), \
724 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
725 (&CLASS<T1,T2>::bbSetInput##NAME) ) )
726 //============================================================================
728 //============================================================================
729 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
730 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE) \
731 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
732 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
733 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
734 (&CLASS<T1,T2>::bbGetOutput##NAME), \
735 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
736 (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
737 //============================================================================
739 //============================================================================
740 /// Template AtomicBlackBox std implementation of ctor and dtor
741 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
742 template <class T1, class T2> \
743 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
744 : PARENT(name,false) \
746 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
747 CLASS<T1,T2>::bbUserSetDefaultValues(); \
748 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
750 template <class T1, class T2> \
751 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
752 const std::string& name, bool allocate_connectors) \
753 : PARENT(from,name,false) \
755 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
756 CLASS<T1,T2>::bbUserSetDefaultValues(); \
757 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
759 template <class T1, class T2> \
760 CLASS<T1,T2>::~CLASS() \
762 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
763 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
765 template <class T1, class T2> \
766 void CLASS<T1,T2>::bbLockDescriptor() \
768 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
770 //============================================================================
776 //===========================================================================
778 //===========================================================================