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 //============================================================================
82 //============================================================================
83 /// Declares the standard interface of a AtomicBlackBox
84 /// (ctor, New, descriptor related methods)
85 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT) \
86 BBTK_OBJECT_MINIMAL_INTERFACE; \
89 CLASS(const std::string& name, bool allocate_connectors = true); \
90 CLASS(Self& from, const std::string& name, \
91 bool allocate_connectors = true); \
94 std::string GetObjectName() const \
95 { return std::string(#CLASS)+std::string(" '") \
96 +bbGetNameWithParent()+std::string("'"); } \
97 inline static Pointer New(const std::string& name) \
99 bbtkDebugMessage("object",1,"##> "<<#CLASS \
100 <<"::New(\""<<name<<"\")"<<std::endl); \
101 Pointer p = MakeBlackBoxPointer(new Self(name)); \
102 bbtkDebugMessage("object",1,"<## "<<#CLASS \
103 <<"::New(\""<<name<<"\")"<<std::endl); \
106 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
108 bbtkBlackBoxDebugMessage("object",1,"##> "<<#CLASS \
109 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
110 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
111 bbtkBlackBoxDebugMessage("object",1,"<## "<<#CLASS \
112 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
115 virtual void bbLockDescriptor(); \
116 virtual void bbUserSetDefaultValues(); \
117 virtual void bbUserInitializeProcessing(); \
118 virtual void bbUserFinalizeProcessing(); \
119 virtual void bbRecursiveInitializeProcessing() \
121 PARENT::bbRecursiveInitializeProcessing(); \
122 CLASS::bbUserInitializeProcessing(); \
124 virtual void bbRecursiveFinalizeProcessing() \
126 CLASS::bbUserFinalizeProcessing(); \
127 PARENT::bbRecursiveFinalizeProcessing(); \
130 CLASS() : PARENT("") {} \
131 CLASS(const CLASS&) : PARENT("") {}
133 //============================================================================
135 //============================================================================
136 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
137 public : typedef CLASS Self; \
138 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
139 //============================================================================
141 //============================================================================
142 #define BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENT) \
143 public : typedef CLASS Self; \
144 BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT);
145 //============================================================================
147 //============================================================================
148 /// Defines the bbUserProcess method
149 #define BBTK_PROCESS(CALLBACK) \
151 inline void bbUserProcess() \
153 bbtkBlackBoxDebugMessage("process",1,"**> Processing..." \
156 bbtkBlackBoxDebugMessage("process",1,"<** Processing" \
159 //============================================================================
162 //============================================================================
163 /// Declares a new AtomicBlackBox input (to be put in the class interface)
164 #define BBTK_DECLARE_INPUT(NAME,TYPE) \
166 TYPE bbmInput##NAME; \
168 TYPE bbGetInput##NAME () \
169 { return bbmInput##NAME; } \
170 void bbSetInput##NAME (TYPE d) \
171 { bbmInput##NAME = d; \
172 /*bbSetModifiedStatus();*/ }
173 //============================================================================
175 //============================================================================
176 /// Declares a new AtomicBlackBox output (to be put in the class interface)
177 #define BBTK_DECLARE_OUTPUT(NAME,TYPE) \
179 TYPE bbmOutput##NAME; \
181 TYPE bbGetOutput##NAME () \
182 { return bbmOutput##NAME; } \
183 void bbSetOutput##NAME (TYPE d) \
184 { bbmOutput##NAME = d; }
185 //============================================================================
187 //============================================================================
188 /// Declares an inherited AtomicBlackBox input (to be put in the class interface)
189 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
191 TYPE bbGetInput##NAME () \
192 { return GETMETHOD(); } \
193 void bbSetInput##NAME (TYPE d) \
195 /*bbSetModifiedStatus();*/ }
196 //============================================================================
199 //============================================================================
200 /// Declares an inherited AtomicBlackBox output (to be put in the class interface)
201 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
203 TYPE bbGetOutput##NAME () const \
204 { return GETMETHOD(); } \
205 void bbSetOutput##NAME (TYPE d) \
207 //============================================================================
211 //============================================================================
212 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC) \
213 bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
214 <<"()"<<std::endl); \
217 bbLockDescriptor(); \
218 bbAllocateConnectors(); \
221 //============================================================================
223 //============================================================================
224 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS) \
225 bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
227 //============================================================================
229 //============================================================================
230 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
231 bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
232 <<"("<<FROM.bbGetFullName() \
236 bbLockDescriptor(); \
237 bbAllocateConnectors(); \
239 //============================================================================
241 //============================================================================
242 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
243 bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
244 <<"("<<FROM.bbGetFullName() \
248 bbCopyIOValues(FROM); \
250 //============================================================================
252 //============================================================================
253 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
254 bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
255 <<"()"<<std::endl); \
256 bbFinalizeProcessing();
259 //============================================================================
261 //============================================================================
262 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS) \
263 bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS \
266 //============================================================================
269 //============================================================================
270 /// AtomicBlackBox std implementation of ctor and dtor
271 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
272 CLASS::CLASS(const std::string& name, bool allocate_connectors) \
273 : PARENT(name,false) \
275 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \
276 CLASS::bbUserSetDefaultValues(); \
277 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
279 CLASS::CLASS(CLASS& from, \
280 const std::string& name, bool allocate_connectors) \
281 : PARENT(from,name,false) \
283 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
284 CLASS::bbUserSetDefaultValues(); \
285 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
289 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
290 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
292 void CLASS::bbLockDescriptor() \
294 bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \
296 //============================================================================
299 //============================================================================
300 /// Begins the AtomicBlackBox description block
301 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS) \
303 public: typedef CLASS ## Descriptor Self; \
304 BBTK_OBJECT_MINIMAL_INTERFACE; \
306 std::string GetObjectName() const \
308 return std::string(BBTK_STRINGIFY(CLASS)) \
309 +std::string("Descriptor '")+GetFullTypeName() \
312 size_t GetObjectSize() const { return sizeof(*this); } \
313 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
315 return CLASS::New(name); \
317 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
321 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
323 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
324 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
325 if (!i.lock()) { j = Self::New(); i = j; } \
328 static CLASS ## Descriptor::Pointer New() \
330 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
331 <<"Descriptor::New" <<std::endl); \
332 CLASS ## Descriptor::Pointer p = \
333 MakePointer(new CLASS ## Descriptor()); \
334 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
335 <<"Descriptor::New" <<std::endl); \
339 CLASS ## Descriptor() \
341 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
342 <<#CLASS<<"Descriptor()"<<std::endl);
343 //============================================================================
345 //============================================================================
346 /// Begins the AtomicBlackBox description block
347 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT) \
348 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
349 BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS);
351 //============================================================================
352 /// Ends the AtomicBlackBox description block
353 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
354 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
355 <<#CLASS<<"Descriptor()"<<std::endl); \
359 //============================================================================
362 //============================================================================
363 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
364 #define BBTK_NAME(NAME) SetTypeName(NAME)
365 //============================================================================
367 //============================================================================
368 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
369 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
370 //============================================================================
372 //============================================================================
373 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
374 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
375 //============================================================================
377 //============================================================================
378 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
379 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
380 //============================================================================
382 //============================================================================
383 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
384 //#define BBTK_KIND(KIND) SetKind(KIND)
385 //============================================================================
387 //============================================================================
388 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
389 #define BBTK_ADAPTOR() \
390 SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
391 AddToCategory("adaptor")
392 //============================================================================
394 //============================================================================
395 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
396 #define BBTK_DEFAULT_ADAPTOR() \
397 SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR); \
398 AddToCategory("adaptor")
399 //============================================================================
402 //============================================================================
403 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
404 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
405 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
406 (typeid(CLASS ## Descriptor), \
407 #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) ) )
412 //============================================================================
414 //============================================================================
415 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
416 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
417 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
418 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
419 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
420 (&CLASS::bbGetOutput##NAME), \
421 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
422 (&CLASS::bbSetOutput##NAME) ) )
423 //============================================================================
426 //============================================================================
427 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
428 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
429 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
430 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
431 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
432 (&CLASS::bbGetInput##NAME), \
433 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
434 (&CLASS::bbSetInput##NAME), \
436 //============================================================================
438 //============================================================================
439 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
440 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
441 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
442 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
443 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
444 (&CLASS::bbGetOutput##NAME), \
445 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
446 (&CLASS::bbSetOutput##NAME),\
448 //============================================================================
459 //============================================================================
460 //============================================================================
461 // Template user black boxes macros
462 //============================================================================
463 //============================================================================
465 //============================================================================
466 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
467 public : typedef CLASS<T> Self; \
468 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
469 //============================================================================
471 //============================================================================
472 /// Begins a template AtomicBlackBox of template param T description block
473 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
475 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
477 public: typedef CLASS ## Descriptor<T> Self; \
478 BBTK_OBJECT_MINIMAL_INTERFACE; \
480 std::string GetObjectName() const \
482 return std::string(BBTK_STRINGIFY(CLASS)) \
483 +std::string("Descriptor<")+bbtk::TypeName<T>() \
484 +std::string("> '")+GetFullTypeName() \
487 static Pointer New() \
489 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
490 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
492 Pointer p = MakePointer(new Self()); \
493 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
494 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
498 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
502 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
504 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
505 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
506 if (!i.lock()) { j = Self::New(); i = j; } \
509 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
511 return CLASS<T>::New(name); \
513 CLASS ## Descriptor() \
515 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
516 <<bbtk::TypeName<T>()<<">::" \
517 <<#CLASS<<"Descriptor()"<<std::endl);
519 //============================================================================
521 //============================================================================
522 /// Ends a template AtomicBlackBox of template param T description block
523 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
524 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
525 <<bbtk::TypeName<T>()<<">::" \
526 <<#CLASS<<"Descriptor()"<<std::endl); \
530 //============================================================================
532 //============================================================================
533 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
534 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE) \
535 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
536 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
537 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
538 (&CLASS<T>::bbGetInput##NAME), \
539 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
540 (&CLASS<T>::bbSetInput##NAME) ) )
541 //============================================================================
543 //============================================================================
544 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
545 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE) \
546 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
547 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
548 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
549 (&CLASS<T>::bbGetOutput##NAME), \
550 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
551 (&CLASS<T>::bbSetOutput##NAME) ) )
552 //============================================================================
555 //JCP 09JUIN2009 BBTK_EXPORT
557 //============================================================================
558 /// Template AtomicBlackBox std implementation of ctor and dtor
559 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
561 CLASS<T>::CLASS(const std::string& name, bool alloc) \
562 : PARENT(name,false) \
564 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
565 CLASS<T>::bbUserSetDefaultValues(); \
566 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
569 CLASS<T>::CLASS(CLASS<T>& from, \
570 const std::string& name, bool allocate_connectors) \
571 : PARENT(from,name,false) \
573 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
574 CLASS<T>::bbUserSetDefaultValues(); \
575 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
580 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
581 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
584 void CLASS<T>::bbLockDescriptor() \
586 bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
588 //============================================================================
592 //============================================================================
593 // Two template params user black boxes macros
594 //============================================================================
596 //============================================================================
597 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
598 public : typedef CLASS<T1,T2> Self; \
599 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
600 //===========================================================================
602 //============================================================================
603 /// Begins a template AtomicBlackBox description block of template param T1 and T2
604 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
605 template <class T1, class T2> \
606 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
608 public: typedef CLASS ## Descriptor<T1,T2> Self; \
609 BBTK_OBJECT_MINIMAL_INTERFACE; \
611 std::string GetObjectName() const \
613 return std::string(BBTK_STRINGIFY(CLASS)) \
614 +std::string("Descriptor<")+bbtk::TypeName<T1>() \
615 +std::string(",")+bbtk::TypeName<T2>() \
616 +std::string("> '")+GetFullTypeName() \
619 static Pointer New() \
621 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
622 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
623 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
624 Pointer p = MakePointer(new Self()); \
625 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
626 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
627 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
630 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
634 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
636 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
637 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
638 if (!i.lock()) { j = Self::New(); i = j; } \
641 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
643 return CLASS<T1,T2>::New(name); \
645 CLASS ## Descriptor() \
647 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
648 <<bbtk::TypeName<T1>()<<"," \
649 <<bbtk::TypeName<T2>()<<">::" \
650 <<#CLASS<<"Descriptor()"<<std::endl);
651 //============================================================================
653 //============================================================================
654 /// Ends a template AtomicBlackBox description block of template param T1 and T2
655 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
656 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
657 <<bbtk::TypeName<T1>()<<"," \
658 <<bbtk::TypeName<T2>()<<">::" \
659 <<#CLASS<<"Descriptor()"<<std::endl); \
663 //============================================================================
668 //============================================================================
669 // Two template params user black boxes macros
671 /// Begins a template AtomicBlackBox description block of template param T1 and T2
672 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
673 template <TYPE1 T1, TYPE2 T2> \
674 class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
677 virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
681 static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
683 static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
684 bbtk:AtomicBlackBoxDescriptor::Pointer j; \
685 if (!i.lock()) { j = Self::New(); i = j; } \
688 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
690 return new CLASS<T1,T2>(name); \
692 CLASS ## Descriptor() \
694 bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
695 <<"Descriptor()"<<std::endl)
696 //============================================================================
698 //============================================================================
699 /// Ends a template AtomicBlackBox description block of template param T1 and T2
700 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
701 bbtkDecTab("Kernel",9); \
705 //============================================================================
709 //============================================================================
710 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
711 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE) \
712 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
713 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
714 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
715 (&CLASS<T1,T2>::bbGetInput##NAME), \
716 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
717 (&CLASS<T1,T2>::bbSetInput##NAME) ) )
718 //============================================================================
720 //============================================================================
721 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
722 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE) \
723 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
724 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
725 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
726 (&CLASS<T1,T2>::bbGetOutput##NAME), \
727 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
728 (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
729 //============================================================================
731 //============================================================================
732 /// Template AtomicBlackBox std implementation of ctor and dtor
733 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
734 template <class T1, class T2> \
735 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
736 : PARENT(name,false) \
738 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
739 CLASS<T1,T2>::bbUserSetDefaultValues(); \
740 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
742 template <class T1, class T2> \
743 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
744 const std::string& name, bool allocate_connectors) \
745 : PARENT(from,name,false) \
747 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
748 CLASS<T1,T2>::bbUserSetDefaultValues(); \
749 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
751 template <class T1, class T2> \
752 CLASS<T1,T2>::~CLASS() \
754 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
755 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
757 template <class T1, class T2> \
758 void CLASS<T1,T2>::bbLockDescriptor() \
760 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
762 //============================================================================
768 //===========================================================================
770 //===========================================================================