1 /*=========================================================================
3 Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
5 Date: $Date: 2008/11/25 11:17:13 $
6 Version: $Revision: 1.13 $
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(CLASS,PARENT) \
263 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
265 public: typedef CLASS ## Descriptor Self; \
266 BBTK_OBJECT_MINIMAL_INTERFACE; \
268 std::string GetObjectName() const \
270 return std::string(BBTK_STRINGIFY(CLASS)) \
271 +std::string("Descriptor '")+GetFullTypeName() \
274 size_t GetObjectSize() const { return sizeof(*this); } \
275 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
277 return CLASS::New(name); \
279 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
283 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
285 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
286 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
287 if (!i.lock()) { j = Self::New(); i = j; } \
290 static CLASS ## Descriptor::Pointer New() \
292 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
293 <<"Descriptor::New" <<std::endl); \
294 CLASS ## Descriptor::Pointer p = \
295 MakePointer(new CLASS ## Descriptor()); \
296 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
297 <<"Descriptor::New" <<std::endl); \
301 CLASS ## Descriptor() \
303 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
304 <<#CLASS<<"Descriptor()"<<std::endl);
305 //============================================================================
307 //============================================================================
308 /// Ends the AtomicBlackBox description block
309 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
310 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
311 <<#CLASS<<"Descriptor()"<<std::endl); \
315 //============================================================================
318 //============================================================================
319 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
320 #define BBTK_NAME(NAME) SetTypeName(NAME)
321 //============================================================================
323 //============================================================================
324 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
325 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
326 //============================================================================
328 //============================================================================
329 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
330 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
331 //============================================================================
333 //============================================================================
334 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
335 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
336 //============================================================================
338 //============================================================================
339 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
340 //#define BBTK_KIND(KIND) SetKind(KIND)
341 //============================================================================
343 //============================================================================
344 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
345 #define BBTK_ADAPTOR() \
346 SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
347 AddToCategory("adaptor")
348 //============================================================================
350 //============================================================================
351 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
352 #define BBTK_DEFAULT_ADAPTOR() \
353 SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR); \
354 AddToCategory("adaptor")
355 //============================================================================
358 //============================================================================
359 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
360 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
361 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
362 (typeid(CLASS ## Descriptor), \
363 #NAME,DESCR,NATURE, \
364 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
365 (&CLASS::bbGetInput##NAME), \
366 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
367 (&CLASS::bbSetInput##NAME) ) )
368 //============================================================================
370 //============================================================================
371 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
372 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
373 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
374 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
375 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
376 (&CLASS::bbGetOutput##NAME), \
377 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
378 (&CLASS::bbSetOutput##NAME) ) )
379 //============================================================================
382 //============================================================================
383 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
384 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
385 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
386 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
387 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
388 (&CLASS::bbGetInput##NAME), \
389 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
390 (&CLASS::bbSetInput##NAME), \
392 //============================================================================
394 //============================================================================
395 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
396 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
397 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
398 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
399 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
400 (&CLASS::bbGetOutput##NAME), \
401 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
402 (&CLASS::bbSetOutput##NAME),\
404 //============================================================================
415 //============================================================================
416 //============================================================================
417 // Template user black boxes macros
418 //============================================================================
419 //============================================================================
421 //============================================================================
422 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
423 public : typedef CLASS<T> Self; \
424 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
425 //============================================================================
427 //============================================================================
428 /// Begins a template AtomicBlackBox of template param T description block
429 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
431 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
433 public: typedef CLASS ## Descriptor<T> Self; \
434 BBTK_OBJECT_MINIMAL_INTERFACE; \
436 std::string GetObjectName() const \
438 return std::string(BBTK_STRINGIFY(CLASS)) \
439 +std::string("Descriptor<")+bbtk::TypeName<T>() \
440 +std::string("> '")+GetFullTypeName() \
443 static Pointer New() \
445 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
446 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
448 Pointer p = MakePointer(new Self()); \
449 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
450 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
454 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
458 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
460 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
461 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
462 if (!i.lock()) { j = Self::New(); i = j; } \
465 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
467 return CLASS<T>::New(name); \
469 CLASS ## Descriptor() \
471 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
472 <<bbtk::TypeName<T>()<<">::" \
473 <<#CLASS<<"Descriptor()"<<std::endl);
475 //============================================================================
477 //============================================================================
478 /// Ends a template AtomicBlackBox of template param T description block
479 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
480 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
481 <<bbtk::TypeName<T>()<<">::" \
482 <<#CLASS<<"Descriptor()"<<std::endl); \
486 //============================================================================
488 //============================================================================
489 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
490 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE) \
491 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
492 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
493 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
494 (&CLASS<T>::bbGetInput##NAME), \
495 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
496 (&CLASS<T>::bbSetInput##NAME) ) )
497 //============================================================================
499 //============================================================================
500 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
501 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE) \
502 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
503 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
504 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
505 (&CLASS<T>::bbGetOutput##NAME), \
506 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
507 (&CLASS<T>::bbSetOutput##NAME) ) )
508 //============================================================================
510 //============================================================================
511 /// Template AtomicBlackBox std implementation of ctor and dtor
512 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
514 CLASS<T>::CLASS(const std::string& name, bool alloc) \
515 : PARENT(name,false) \
517 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
518 CLASS<T>::bbUserConstructor(); \
519 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
522 CLASS<T>::CLASS(CLASS<T>& from, \
523 const std::string& name, bool allocate_connectors) \
524 : PARENT(from,name,false) \
526 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
527 CLASS<T>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>()); \
528 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
533 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
534 CLASS<T>::bbUserDestructor(); \
535 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
538 void CLASS<T>::bbLockDescriptor() \
540 bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
542 //============================================================================
546 //============================================================================
547 // Two template params user black boxes macros
548 //============================================================================
550 //============================================================================
551 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
552 public : typedef CLASS<T1,T2> Self; \
553 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
554 //===========================================================================
556 //============================================================================
557 /// Begins a template AtomicBlackBox description block of template param T1 and T2
558 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
559 template <class T1, class T2> \
560 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
562 public: typedef CLASS ## Descriptor<T1,T2> Self; \
563 BBTK_OBJECT_MINIMAL_INTERFACE; \
565 std::string GetObjectName() const \
567 return std::string(BBTK_STRINGIFY(CLASS)) \
568 +std::string("Descriptor<")+bbtk::TypeName<T1>() \
569 +std::string(",")+bbtk::TypeName<T2>() \
570 +std::string("> '")+GetFullTypeName() \
573 static Pointer New() \
575 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
576 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
577 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
578 Pointer p = MakePointer(new Self()); \
579 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
580 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
581 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
584 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
588 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
590 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
591 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
592 if (!i.lock()) { j = Self::New(); i = j; } \
595 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
597 return CLASS<T1,T2>::New(name); \
599 CLASS ## Descriptor() \
601 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
602 <<bbtk::TypeName<T1>()<<"," \
603 <<bbtk::TypeName<T2>()<<">::" \
604 <<#CLASS<<"Descriptor()"<<std::endl);
605 //============================================================================
607 //============================================================================
608 /// Ends a template AtomicBlackBox description block of template param T1 and T2
609 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
610 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
611 <<bbtk::TypeName<T1>()<<"," \
612 <<bbtk::TypeName<T2>()<<">::" \
613 <<#CLASS<<"Descriptor()"<<std::endl); \
617 //============================================================================
622 //============================================================================
623 // Two template params user black boxes macros
625 /// Begins a template AtomicBlackBox description block of template param T1 and T2
626 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
627 template <TYPE1 T1, TYPE2 T2> \
628 class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
631 virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
635 static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
637 static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
638 bbtk:AtomicBlackBoxDescriptor::Pointer j; \
639 if (!i.lock()) { j = Self::New(); i = j; } \
642 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
644 return new CLASS<T1,T2>(name); \
646 CLASS ## Descriptor() \
648 bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
649 <<"Descriptor()"<<std::endl)
650 //============================================================================
652 //============================================================================
653 /// Ends a template AtomicBlackBox description block of template param T1 and T2
654 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
655 bbtkDecTab("Kernel",9); \
659 //============================================================================
663 //============================================================================
664 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
665 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE) \
666 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
667 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
668 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
669 (&CLASS<T1,T2>::bbGetInput##NAME), \
670 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
671 (&CLASS<T1,T2>::bbSetInput##NAME) ) )
672 //============================================================================
674 //============================================================================
675 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
676 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE) \
677 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
678 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
679 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
680 (&CLASS<T1,T2>::bbGetOutput##NAME), \
681 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
682 (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
683 //============================================================================
685 //============================================================================
686 /// Template AtomicBlackBox std implementation of ctor and dtor
687 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
688 template <class T1, class T2> \
689 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
690 : PARENT(name,false) \
692 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
693 CLASS<T1,T2>::bbUserConstructor(); \
694 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
696 template <class T1, class T2> \
697 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
698 const std::string& name, bool allocate_connectors) \
699 : PARENT(from,name,false) \
701 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
702 CLASS<T1,T2>::bbUserCopyConstructor(from.GetThisPointer<bbtk::BlackBox>()); \
703 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
705 template <class T1, class T2> \
706 CLASS<T1,T2>::~CLASS() \
708 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
709 CLASS<T1,T2>::bbUserDestructor(); \
710 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
712 template <class T1, class T2> \
713 void CLASS<T1,T2>::bbLockDescriptor() \
715 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
717 //============================================================================
721 //============================================================================
722 /// Template AtomicBlackBox std implementation of ctor and dtor
723 #define BBTK_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
724 template <TYPE1 T1, TYPE2 T2> \
725 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
726 : PARENT(name,false) \
728 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
729 this->bbUserConstructor(); \
730 BBTK_END_BLACK_BOX_CONSTRUCTOR; \
732 template <TYPE1 T1, TYPE2 T2> \
733 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
734 const std::string& name, bool allocate_connectors) \
735 : PARENT(from,name,false) \
737 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
738 this->bbUserCopyConstructor(); \
739 BBTK_END_BLACK_BOX_CONSTRUCTOR; \
741 template <TYPE1 T1, TYPE2 T2> \
742 CLASS<T1,T2>::~CLASS() \
744 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
745 this->bbUserDestructor(); \
746 BBTK_END_BLACK_BOX_DESTRUCTOR; \
748 template <class T1, class T2> \
749 void CLASS<T1,T2>::bbLockDescriptor() \
751 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
753 //============================================================================
763 //===========================================================================
765 //===========================================================================