1 /*=========================================================================
3 Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
5 Date: $Date: 2009/04/08 07:56:11 $
6 Version: $Revision: 1.14 $
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(); \
57 CLASS() : PARENT("") {} \
58 CLASS(const CLASS&) : PARENT("") {}
60 //============================================================================
62 //============================================================================
63 /// Declares the standard interface of a AtomicBlackBox
64 /// (ctor, New, descriptor related methods)
65 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT) \
66 BBTK_OBJECT_MINIMAL_INTERFACE; \
69 CLASS(const std::string& name, bool allocate_connectors = true); \
70 CLASS(Self& from, const std::string& name, \
71 bool allocate_connectors = true); \
74 std::string GetObjectName() const \
75 { return std::string(#CLASS)+std::string(" '") \
76 +bbGetNameWithParent()+std::string("'"); } \
77 inline static Pointer New(const std::string& name) \
79 bbtkDebugMessage("object",1,"##> "<<#CLASS \
80 <<"::New(\""<<name<<"\")"<<std::endl); \
81 Pointer p = MakeBlackBoxPointer(new Self(name)); \
82 bbtkDebugMessage("object",1,"<## "<<#CLASS \
83 <<"::New(\""<<name<<"\")"<<std::endl); \
86 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
88 bbtkDebugMessage("object",1,"##> "<<#CLASS \
89 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
90 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
91 bbtkDebugMessage("object",1,"<## "<<#CLASS \
92 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
95 virtual void bbLockDescriptor(); \
97 CLASS() : PARENT("") {} \
98 CLASS(const CLASS&) : PARENT("") {}
100 //============================================================================
102 //============================================================================
103 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
104 public : typedef CLASS Self; \
105 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
106 //============================================================================
108 //============================================================================
109 #define BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENT) \
110 public : typedef CLASS Self; \
111 BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT);
112 //============================================================================
114 //============================================================================
115 /// Defines the bbUserProcess method
116 #define BBTK_PROCESS(CALLBACK) \
118 inline void bbUserProcess() \
120 bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName() \
123 bbtkDebugMessage("process",1,"<** Processing ["<<bbGetFullName() \
126 //============================================================================
129 //============================================================================
130 /// Declares a new AtomicBlackBox input (to be put in the class interface)
131 #define BBTK_DECLARE_INPUT(NAME,TYPE) \
133 TYPE bbmInput##NAME; \
135 TYPE bbGetInput##NAME () \
136 { return bbmInput##NAME; } \
137 void bbSetInput##NAME (TYPE d) \
138 { bbmInput##NAME = d; \
139 /*bbSetModifiedStatus();*/ }
140 //============================================================================
142 //============================================================================
143 /// Declares a new AtomicBlackBox output (to be put in the class interface)
144 #define BBTK_DECLARE_OUTPUT(NAME,TYPE) \
146 TYPE bbmOutput##NAME; \
148 TYPE bbGetOutput##NAME () \
149 { return bbmOutput##NAME; } \
150 void bbSetOutput##NAME (TYPE d) \
151 { bbmOutput##NAME = d; }
152 //============================================================================
154 //============================================================================
155 /// Declares an inherited AtomicBlackBox input (to be put in the class interface)
156 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
158 TYPE bbGetInput##NAME () \
159 { return GETMETHOD(); } \
160 void bbSetInput##NAME (TYPE d) \
162 /*bbSetModifiedStatus();*/ }
163 //============================================================================
166 //============================================================================
167 /// Declares an inherited AtomicBlackBox output (to be put in the class interface)
168 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
170 TYPE bbGetOutput##NAME () const \
171 { return GETMETHOD(); } \
172 void bbSetOutput##NAME (TYPE d) \
174 //============================================================================
178 //============================================================================
179 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC) \
180 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
181 <<"(\""<<bbGetName()<<"\")"<<std::endl); \
184 bbLockDescriptor(); \
185 bbAllocateConnectors(); \
187 //============================================================================
189 //============================================================================
190 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS) \
191 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
192 <<"(\""<<bbGetName()<<"\")"<<std::endl);
193 //============================================================================
195 //============================================================================
196 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
197 bbtkDebugMessageInc("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
198 <<"("<<FROM.bbGetFullName()<<",\"" \
199 <<bbGetName()<<"\")"<<std::endl); \
202 bbLockDescriptor(); \
203 bbAllocateConnectors(); \
204 bbCopyIOValues(FROM); \
206 //============================================================================
208 //============================================================================
209 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM) \
210 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
211 <<"("<<FROM.bbGetFullName()<<",\"" \
212 <<bbGetName()<<"\")"<<std::endl);
213 //============================================================================
215 //============================================================================
216 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
217 bbtkDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
218 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
219 //============================================================================
221 //============================================================================
222 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS) \
223 bbtkDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS \
224 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
226 //============================================================================
229 //============================================================================
230 /// AtomicBlackBox std implementation of ctor and dtor
231 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
232 CLASS::CLASS(const std::string& name, bool allocate_connectors) \
233 : PARENT(name,false) \
235 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \
236 CLASS::bbUserConstructor(); \
237 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
239 CLASS::CLASS(CLASS& from, \
240 const std::string& name, bool allocate_connectors) \
241 : PARENT(from,name,false) \
243 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
244 CLASS::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>()); \
245 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
249 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
250 CLASS::bbUserDestructor(); \
251 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
253 void CLASS::bbLockDescriptor() \
255 bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \
257 //============================================================================
260 //============================================================================
261 /// Begins the AtomicBlackBox description block
262 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS) \
264 public: typedef CLASS ## Descriptor Self; \
265 BBTK_OBJECT_MINIMAL_INTERFACE; \
267 std::string GetObjectName() const \
269 return std::string(BBTK_STRINGIFY(CLASS)) \
270 +std::string("Descriptor '")+GetFullTypeName() \
273 size_t GetObjectSize() const { return sizeof(*this); } \
274 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
276 return CLASS::New(name); \
278 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
282 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
284 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
285 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
286 if (!i.lock()) { j = Self::New(); i = j; } \
289 static CLASS ## Descriptor::Pointer New() \
291 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
292 <<"Descriptor::New" <<std::endl); \
293 CLASS ## Descriptor::Pointer p = \
294 MakePointer(new CLASS ## Descriptor()); \
295 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
296 <<"Descriptor::New" <<std::endl); \
300 CLASS ## Descriptor() \
302 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
303 <<#CLASS<<"Descriptor()"<<std::endl);
304 //============================================================================
306 //============================================================================
307 /// Begins the AtomicBlackBox description block
308 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT) \
309 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
310 BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS);
312 //============================================================================
313 /// Ends the AtomicBlackBox description block
314 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
315 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
316 <<#CLASS<<"Descriptor()"<<std::endl); \
320 //============================================================================
323 //============================================================================
324 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
325 #define BBTK_NAME(NAME) SetTypeName(NAME)
326 //============================================================================
328 //============================================================================
329 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
330 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
331 //============================================================================
333 //============================================================================
334 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
335 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
336 //============================================================================
338 //============================================================================
339 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
340 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
341 //============================================================================
343 //============================================================================
344 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
345 //#define BBTK_KIND(KIND) SetKind(KIND)
346 //============================================================================
348 //============================================================================
349 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
350 #define BBTK_ADAPTOR() \
351 SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
352 AddToCategory("adaptor")
353 //============================================================================
355 //============================================================================
356 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
357 #define BBTK_DEFAULT_ADAPTOR() \
358 SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR); \
359 AddToCategory("adaptor")
360 //============================================================================
363 //============================================================================
364 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
365 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
366 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
367 (typeid(CLASS ## Descriptor), \
368 #NAME,DESCR,NATURE, \
369 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
370 (&CLASS::bbGetInput##NAME), \
371 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
372 (&CLASS::bbSetInput##NAME) ) )
373 //============================================================================
375 //============================================================================
376 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
377 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
378 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
379 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
380 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
381 (&CLASS::bbGetOutput##NAME), \
382 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
383 (&CLASS::bbSetOutput##NAME) ) )
384 //============================================================================
387 //============================================================================
388 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
389 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
390 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
391 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
392 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
393 (&CLASS::bbGetInput##NAME), \
394 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
395 (&CLASS::bbSetInput##NAME), \
397 //============================================================================
399 //============================================================================
400 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
401 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
402 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
403 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
404 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
405 (&CLASS::bbGetOutput##NAME), \
406 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
407 (&CLASS::bbSetOutput##NAME),\
409 //============================================================================
420 //============================================================================
421 //============================================================================
422 // Template user black boxes macros
423 //============================================================================
424 //============================================================================
426 //============================================================================
427 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
428 public : typedef CLASS<T> Self; \
429 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
430 //============================================================================
432 //============================================================================
433 /// Begins a template AtomicBlackBox of template param T description block
434 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
436 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
438 public: typedef CLASS ## Descriptor<T> Self; \
439 BBTK_OBJECT_MINIMAL_INTERFACE; \
441 std::string GetObjectName() const \
443 return std::string(BBTK_STRINGIFY(CLASS)) \
444 +std::string("Descriptor<")+bbtk::TypeName<T>() \
445 +std::string("> '")+GetFullTypeName() \
448 static Pointer New() \
450 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
451 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
453 Pointer p = MakePointer(new Self()); \
454 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
455 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
459 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
463 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
465 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
466 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
467 if (!i.lock()) { j = Self::New(); i = j; } \
470 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
472 return CLASS<T>::New(name); \
474 CLASS ## Descriptor() \
476 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
477 <<bbtk::TypeName<T>()<<">::" \
478 <<#CLASS<<"Descriptor()"<<std::endl);
480 //============================================================================
482 //============================================================================
483 /// Ends a template AtomicBlackBox of template param T description block
484 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
485 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
486 <<bbtk::TypeName<T>()<<">::" \
487 <<#CLASS<<"Descriptor()"<<std::endl); \
491 //============================================================================
493 //============================================================================
494 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
495 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE) \
496 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
497 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
498 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
499 (&CLASS<T>::bbGetInput##NAME), \
500 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
501 (&CLASS<T>::bbSetInput##NAME) ) )
502 //============================================================================
504 //============================================================================
505 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
506 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE) \
507 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
508 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
509 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
510 (&CLASS<T>::bbGetOutput##NAME), \
511 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
512 (&CLASS<T>::bbSetOutput##NAME) ) )
513 //============================================================================
515 //============================================================================
516 /// Template AtomicBlackBox std implementation of ctor and dtor
517 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
519 CLASS<T>::CLASS(const std::string& name, bool alloc) \
520 : PARENT(name,false) \
522 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
523 CLASS<T>::bbUserConstructor(); \
524 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
527 CLASS<T>::CLASS(CLASS<T>& from, \
528 const std::string& name, bool allocate_connectors) \
529 : PARENT(from,name,false) \
531 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
532 CLASS<T>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>()); \
533 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
538 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
539 CLASS<T>::bbUserDestructor(); \
540 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
543 void CLASS<T>::bbLockDescriptor() \
545 bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
547 //============================================================================
551 //============================================================================
552 // Two template params user black boxes macros
553 //============================================================================
555 //============================================================================
556 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
557 public : typedef CLASS<T1,T2> Self; \
558 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
559 //===========================================================================
561 //============================================================================
562 /// Begins a template AtomicBlackBox description block of template param T1 and T2
563 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
564 template <class T1, class T2> \
565 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
567 public: typedef CLASS ## Descriptor<T1,T2> Self; \
568 BBTK_OBJECT_MINIMAL_INTERFACE; \
570 std::string GetObjectName() const \
572 return std::string(BBTK_STRINGIFY(CLASS)) \
573 +std::string("Descriptor<")+bbtk::TypeName<T1>() \
574 +std::string(",")+bbtk::TypeName<T2>() \
575 +std::string("> '")+GetFullTypeName() \
578 static Pointer New() \
580 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
581 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
582 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
583 Pointer p = MakePointer(new Self()); \
584 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
585 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
586 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
589 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
593 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
595 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
596 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
597 if (!i.lock()) { j = Self::New(); i = j; } \
600 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
602 return CLASS<T1,T2>::New(name); \
604 CLASS ## Descriptor() \
606 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
607 <<bbtk::TypeName<T1>()<<"," \
608 <<bbtk::TypeName<T2>()<<">::" \
609 <<#CLASS<<"Descriptor()"<<std::endl);
610 //============================================================================
612 //============================================================================
613 /// Ends a template AtomicBlackBox description block of template param T1 and T2
614 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
615 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
616 <<bbtk::TypeName<T1>()<<"," \
617 <<bbtk::TypeName<T2>()<<">::" \
618 <<#CLASS<<"Descriptor()"<<std::endl); \
622 //============================================================================
627 //============================================================================
628 // Two template params user black boxes macros
630 /// Begins a template AtomicBlackBox description block of template param T1 and T2
631 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
632 template <TYPE1 T1, TYPE2 T2> \
633 class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
636 virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
640 static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
642 static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
643 bbtk:AtomicBlackBoxDescriptor::Pointer j; \
644 if (!i.lock()) { j = Self::New(); i = j; } \
647 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
649 return new CLASS<T1,T2>(name); \
651 CLASS ## Descriptor() \
653 bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
654 <<"Descriptor()"<<std::endl)
655 //============================================================================
657 //============================================================================
658 /// Ends a template AtomicBlackBox description block of template param T1 and T2
659 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
660 bbtkDecTab("Kernel",9); \
664 //============================================================================
668 //============================================================================
669 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
670 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE) \
671 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
672 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
673 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
674 (&CLASS<T1,T2>::bbGetInput##NAME), \
675 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
676 (&CLASS<T1,T2>::bbSetInput##NAME) ) )
677 //============================================================================
679 //============================================================================
680 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
681 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE) \
682 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
683 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
684 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
685 (&CLASS<T1,T2>::bbGetOutput##NAME), \
686 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
687 (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
688 //============================================================================
690 //============================================================================
691 /// Template AtomicBlackBox std implementation of ctor and dtor
692 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
693 template <class T1, class T2> \
694 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
695 : PARENT(name,false) \
697 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
698 CLASS<T1,T2>::bbUserConstructor(); \
699 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
701 template <class T1, class T2> \
702 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
703 const std::string& name, bool allocate_connectors) \
704 : PARENT(from,name,false) \
706 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
707 CLASS<T1,T2>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>()); \
708 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
710 template <class T1, class T2> \
711 CLASS<T1,T2>::~CLASS() \
713 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
714 CLASS<T1,T2>::bbUserDestructor(); \
715 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
717 template <class T1, class T2> \
718 void CLASS<T1,T2>::bbLockDescriptor() \
720 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
722 //============================================================================
726 //============================================================================
727 /// Template AtomicBlackBox std implementation of ctor and dtor
728 #define BBTK_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
729 template <TYPE1 T1, TYPE2 T2> \
730 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
731 : PARENT(name,false) \
733 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
734 this->bbUserConstructor(); \
735 BBTK_END_BLACK_BOX_CONSTRUCTOR; \
737 template <TYPE1 T1, TYPE2 T2> \
738 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
739 const std::string& name, bool allocate_connectors) \
740 : PARENT(from,name,false) \
742 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
743 this->bbUserCopyConstructor(); \
744 BBTK_END_BLACK_BOX_CONSTRUCTOR; \
746 template <TYPE1 T1, TYPE2 T2> \
747 CLASS<T1,T2>::~CLASS() \
749 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
750 this->bbUserDestructor(); \
751 BBTK_END_BLACK_BOX_DESTRUCTOR; \
753 template <class T1, class T2> \
754 void CLASS<T1,T2>::bbLockDescriptor() \
756 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
758 //============================================================================
768 //===========================================================================
770 //===========================================================================