1 /*=========================================================================
3 Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
5 Date: $Date: 2009/05/14 14:43:33 $
6 Version: $Revision: 1.16 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
35 * \brief Defines macros for the creation of new user black boxes
37 #ifndef __bbtkAtomicBlackBoxMacros_h__
38 #define __bbtkAtomicBlackBoxMacros_h__
40 //============================================================================
41 /// Declares the standard interface of a AtomicBlackBox
42 /// (ctor, New, descriptor related methods)
43 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT) \
44 BBTK_OBJECT_MINIMAL_INTERFACE; \
47 CLASS(const std::string& name, bool allocate_connectors = true); \
48 CLASS(Self& from, const std::string& name, \
49 bool allocate_connectors = true); \
52 std::string GetObjectName() const \
53 { return std::string(#CLASS)+std::string(" '") \
54 +bbGetNameWithParent()+std::string("'"); } \
55 virtual void bbLockDescriptor(); \
56 virtual void bbUserSetDefaultValues(); \
57 virtual void bbUserInitializeProcessing(); \
58 virtual void bbUserFinalizeProcessing(); \
59 virtual void bbRecursiveInitializeProcessing() \
61 PARENT::bbRecursiveInitializeProcessing(); \
62 CLASS::bbUserInitializeProcessing(); \
64 virtual void bbRecursiveFinalizeProcessing() \
66 CLASS::bbUserFinalizeProcessing(); \
67 PARENT::bbRecursiveFinalizeProcessing(); \
70 CLASS() : PARENT("") {} \
71 CLASS(const CLASS&) : PARENT("") {}
73 //============================================================================
75 //============================================================================
76 /// Declares the standard interface of a AtomicBlackBox
77 /// (ctor, New, descriptor related methods)
78 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT) \
79 BBTK_OBJECT_MINIMAL_INTERFACE; \
82 CLASS(const std::string& name, bool allocate_connectors = true); \
83 CLASS(Self& from, const std::string& name, \
84 bool allocate_connectors = true); \
87 std::string GetObjectName() const \
88 { return std::string(#CLASS)+std::string(" '") \
89 +bbGetNameWithParent()+std::string("'"); } \
90 inline static Pointer New(const std::string& name) \
92 bbtkDebugMessage("object",1,"##> "<<#CLASS \
93 <<"::New(\""<<name<<"\")"<<std::endl); \
94 Pointer p = MakeBlackBoxPointer(new Self(name)); \
95 bbtkDebugMessage("object",1,"<## "<<#CLASS \
96 <<"::New(\""<<name<<"\")"<<std::endl); \
99 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
101 bbtkDebugMessage("object",1,"##> "<<#CLASS \
102 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
103 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
104 bbtkDebugMessage("object",1,"<## "<<#CLASS \
105 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
108 virtual void bbLockDescriptor(); \
109 virtual void bbUserSetDefaultValues(); \
110 virtual void bbUserInitializeProcessing(); \
111 virtual void bbUserFinalizeProcessing(); \
112 virtual void bbRecursiveInitializeProcessing() \
114 PARENT::bbRecursiveInitializeProcessing(); \
115 CLASS::bbUserInitializeProcessing(); \
117 virtual void bbRecursiveFinalizeProcessing() \
119 CLASS::bbUserFinalizeProcessing(); \
120 PARENT::bbRecursiveFinalizeProcessing(); \
123 CLASS() : PARENT("") {} \
124 CLASS(const CLASS&) : PARENT("") {}
126 //============================================================================
128 //============================================================================
129 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
130 public : typedef CLASS Self; \
131 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
132 //============================================================================
134 //============================================================================
135 #define BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENT) \
136 public : typedef CLASS Self; \
137 BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT);
138 //============================================================================
140 //============================================================================
141 /// Defines the bbUserProcess method
142 #define BBTK_PROCESS(CALLBACK) \
144 inline void bbUserProcess() \
146 bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName() \
149 bbtkDebugMessage("process",1,"<** Processing ["<<bbGetFullName() \
152 //============================================================================
155 //============================================================================
156 /// Declares a new AtomicBlackBox input (to be put in the class interface)
157 #define BBTK_DECLARE_INPUT(NAME,TYPE) \
159 TYPE bbmInput##NAME; \
161 TYPE bbGetInput##NAME () \
162 { return bbmInput##NAME; } \
163 void bbSetInput##NAME (TYPE d) \
164 { bbmInput##NAME = d; \
165 /*bbSetModifiedStatus();*/ }
166 //============================================================================
168 //============================================================================
169 /// Declares a new AtomicBlackBox output (to be put in the class interface)
170 #define BBTK_DECLARE_OUTPUT(NAME,TYPE) \
172 TYPE bbmOutput##NAME; \
174 TYPE bbGetOutput##NAME () \
175 { return bbmOutput##NAME; } \
176 void bbSetOutput##NAME (TYPE d) \
177 { bbmOutput##NAME = d; }
178 //============================================================================
180 //============================================================================
181 /// Declares an inherited AtomicBlackBox input (to be put in the class interface)
182 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
184 TYPE bbGetInput##NAME () \
185 { return GETMETHOD(); } \
186 void bbSetInput##NAME (TYPE d) \
188 /*bbSetModifiedStatus();*/ }
189 //============================================================================
192 //============================================================================
193 /// Declares an inherited AtomicBlackBox output (to be put in the class interface)
194 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD) \
196 TYPE bbGetOutput##NAME () const \
197 { return GETMETHOD(); } \
198 void bbSetOutput##NAME (TYPE d) \
200 //============================================================================
204 //============================================================================
205 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC) \
206 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
207 <<"(\""<<bbGetName()<<"\")"<<std::endl); \
210 bbLockDescriptor(); \
211 bbAllocateConnectors(); \
214 //============================================================================
216 //============================================================================
217 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS) \
218 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
219 <<"(\""<<bbGetName()<<"\")"<<std::endl);
220 //============================================================================
222 //============================================================================
223 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
224 bbtkDebugMessageInc("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
225 <<"("<<FROM.bbGetFullName()<<",\"" \
226 <<bbGetName()<<"\")"<<std::endl); \
229 bbLockDescriptor(); \
230 bbAllocateConnectors(); \
232 //============================================================================
234 //============================================================================
235 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
236 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
237 <<"("<<FROM.bbGetFullName()<<",\"" \
238 <<bbGetName()<<"\")"<<std::endl); \
241 bbCopyIOValues(FROM); \
243 //============================================================================
245 //============================================================================
246 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
247 bbtkDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
248 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
251 //============================================================================
253 //============================================================================
254 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS) \
255 bbtkDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS \
256 <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
258 //============================================================================
261 //============================================================================
262 /// AtomicBlackBox std implementation of ctor and dtor
263 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
264 CLASS::CLASS(const std::string& name, bool allocate_connectors) \
265 : PARENT(name,false) \
267 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \
268 CLASS::bbUserSetDefaultValues(); \
269 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
271 CLASS::CLASS(CLASS& from, \
272 const std::string& name, bool allocate_connectors) \
273 : PARENT(from,name,false) \
275 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
276 CLASS::bbUserSetDefaultValues(); \
277 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
281 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
282 CLASS::bbUserFinalizeProcessing(); \
283 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
285 void CLASS::bbLockDescriptor() \
287 bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \
289 //============================================================================
292 //============================================================================
293 /// Begins the AtomicBlackBox description block
294 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS) \
296 public: typedef CLASS ## Descriptor Self; \
297 BBTK_OBJECT_MINIMAL_INTERFACE; \
299 std::string GetObjectName() const \
301 return std::string(BBTK_STRINGIFY(CLASS)) \
302 +std::string("Descriptor '")+GetFullTypeName() \
305 size_t GetObjectSize() const { return sizeof(*this); } \
306 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
308 return CLASS::New(name); \
310 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
314 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
316 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
317 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
318 if (!i.lock()) { j = Self::New(); i = j; } \
321 static CLASS ## Descriptor::Pointer New() \
323 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
324 <<"Descriptor::New" <<std::endl); \
325 CLASS ## Descriptor::Pointer p = \
326 MakePointer(new CLASS ## Descriptor()); \
327 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
328 <<"Descriptor::New" <<std::endl); \
332 CLASS ## Descriptor() \
334 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
335 <<#CLASS<<"Descriptor()"<<std::endl);
336 //============================================================================
338 //============================================================================
339 /// Begins the AtomicBlackBox description block
340 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT) \
341 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
342 BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS);
344 //============================================================================
345 /// Ends the AtomicBlackBox description block
346 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
347 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
348 <<#CLASS<<"Descriptor()"<<std::endl); \
352 //============================================================================
355 //============================================================================
356 /// Declares the name of a AtomicBlackBox (to be put inside the UBB description block)
357 #define BBTK_NAME(NAME) SetTypeName(NAME)
358 //============================================================================
360 //============================================================================
361 /// Declares the author of a AtomicBlackBox (to be put inside the UBB description block)
362 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
363 //============================================================================
365 //============================================================================
366 /// Declares the categories of a AtomicBlackBox (to be put inside the UBB description block)
367 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
368 //============================================================================
370 //============================================================================
371 /// Declares the description of a AtomicBlackBox (to be put inside the UBB description block)
372 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
373 //============================================================================
375 //============================================================================
376 /// Declares the kind of a AtomicBlackBox (to be put inside the UBB description block)
377 //#define BBTK_KIND(KIND) SetKind(KIND)
378 //============================================================================
380 //============================================================================
381 /// Declares that the AtomicBlackBox is an adaptor (to be put inside the UBB description block)
382 #define BBTK_ADAPTOR() \
383 SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
384 AddToCategory("adaptor")
385 //============================================================================
387 //============================================================================
388 /// Declares that the AtomicBlackBox is the default adaptor of the package (to be put inside the UBB description block)
389 #define BBTK_DEFAULT_ADAPTOR() \
390 SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR); \
391 AddToCategory("adaptor")
392 //============================================================================
395 //============================================================================
396 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
397 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
398 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
399 (typeid(CLASS ## Descriptor), \
400 #NAME,DESCR,NATURE, \
401 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
402 (&CLASS::bbGetInput##NAME), \
403 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
404 (&CLASS::bbSetInput##NAME) ) )
405 //============================================================================
407 //============================================================================
408 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
409 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
410 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
411 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
412 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
413 (&CLASS::bbGetOutput##NAME), \
414 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
415 (&CLASS::bbSetOutput##NAME) ) )
416 //============================================================================
419 //============================================================================
420 /// Describes a AtomicBlackBox input (to be put inside the UBB description block)
421 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
422 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
423 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
424 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
425 (&CLASS::bbGetInput##NAME), \
426 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
427 (&CLASS::bbSetInput##NAME), \
429 //============================================================================
431 //============================================================================
432 /// Describes a AtomicBlackBox output (to be put inside the UBB description block)
433 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE) \
434 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
435 (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE, \
436 new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
437 (&CLASS::bbGetOutput##NAME), \
438 new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
439 (&CLASS::bbSetOutput##NAME),\
441 //============================================================================
452 //============================================================================
453 //============================================================================
454 // Template user black boxes macros
455 //============================================================================
456 //============================================================================
458 //============================================================================
459 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
460 public : typedef CLASS<T> Self; \
461 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
462 //============================================================================
464 //============================================================================
465 /// Begins a template AtomicBlackBox of template param T description block
466 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
468 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
470 public: typedef CLASS ## Descriptor<T> Self; \
471 BBTK_OBJECT_MINIMAL_INTERFACE; \
473 std::string GetObjectName() const \
475 return std::string(BBTK_STRINGIFY(CLASS)) \
476 +std::string("Descriptor<")+bbtk::TypeName<T>() \
477 +std::string("> '")+GetFullTypeName() \
480 static Pointer New() \
482 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
483 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
485 Pointer p = MakePointer(new Self()); \
486 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
487 <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
491 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
495 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
497 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
498 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
499 if (!i.lock()) { j = Self::New(); i = j; } \
502 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
504 return CLASS<T>::New(name); \
506 CLASS ## Descriptor() \
508 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
509 <<bbtk::TypeName<T>()<<">::" \
510 <<#CLASS<<"Descriptor()"<<std::endl);
512 //============================================================================
514 //============================================================================
515 /// Ends a template AtomicBlackBox of template param T description block
516 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
517 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
518 <<bbtk::TypeName<T>()<<">::" \
519 <<#CLASS<<"Descriptor()"<<std::endl); \
523 //============================================================================
525 //============================================================================
526 /// Describes a template AtomicBlackBox input (to be put inside the template UBB description block)
527 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE) \
528 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
529 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
530 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
531 (&CLASS<T>::bbGetInput##NAME), \
532 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
533 (&CLASS<T>::bbSetInput##NAME) ) )
534 //============================================================================
536 //============================================================================
537 /// Describes a template AtomicBlackBox output (to be put inside the template UBB description block)
538 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE) \
539 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
540 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
541 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
542 (&CLASS<T>::bbGetOutput##NAME), \
543 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
544 (&CLASS<T>::bbSetOutput##NAME) ) )
545 //============================================================================
547 //============================================================================
548 /// Template AtomicBlackBox std implementation of ctor and dtor
549 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
551 CLASS<T>::CLASS(const std::string& name, bool alloc) \
552 : PARENT(name,false) \
554 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
555 CLASS<T>::bbUserSetDefaultValues(); \
556 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
559 CLASS<T>::CLASS(CLASS<T>& from, \
560 const std::string& name, bool allocate_connectors) \
561 : PARENT(from,name,false) \
563 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
564 CLASS<T>::bbUserSetDefaultValues(); \
565 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
570 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
571 CLASS<T>::bbFinalizeProcessing(); \
572 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
575 void CLASS<T>::bbLockDescriptor() \
577 bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
579 //============================================================================
583 //============================================================================
584 // Two template params user black boxes macros
585 //============================================================================
587 //============================================================================
588 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
589 public : typedef CLASS<T1,T2> Self; \
590 BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
591 //===========================================================================
593 //============================================================================
594 /// Begins a template AtomicBlackBox description block of template param T1 and T2
595 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
596 template <class T1, class T2> \
597 class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
599 public: typedef CLASS ## Descriptor<T1,T2> Self; \
600 BBTK_OBJECT_MINIMAL_INTERFACE; \
602 std::string GetObjectName() const \
604 return std::string(BBTK_STRINGIFY(CLASS)) \
605 +std::string("Descriptor<")+bbtk::TypeName<T1>() \
606 +std::string(",")+bbtk::TypeName<T2>() \
607 +std::string("> '")+GetFullTypeName() \
610 static Pointer New() \
612 bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
613 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
614 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
615 Pointer p = MakePointer(new Self()); \
616 bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
617 <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
618 <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
621 virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
625 static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
627 static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
628 bbtk::AtomicBlackBoxDescriptor::Pointer j; \
629 if (!i.lock()) { j = Self::New(); i = j; } \
632 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
634 return CLASS<T1,T2>::New(name); \
636 CLASS ## Descriptor() \
638 bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
639 <<bbtk::TypeName<T1>()<<"," \
640 <<bbtk::TypeName<T2>()<<">::" \
641 <<#CLASS<<"Descriptor()"<<std::endl);
642 //============================================================================
644 //============================================================================
645 /// Ends a template AtomicBlackBox description block of template param T1 and T2
646 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
647 bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
648 <<bbtk::TypeName<T1>()<<"," \
649 <<bbtk::TypeName<T2>()<<">::" \
650 <<#CLASS<<"Descriptor()"<<std::endl); \
654 //============================================================================
659 //============================================================================
660 // Two template params user black boxes macros
662 /// Begins a template AtomicBlackBox description block of template param T1 and T2
663 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
664 template <TYPE1 T1, TYPE2 T2> \
665 class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
668 virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
672 static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
674 static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
675 bbtk:AtomicBlackBoxDescriptor::Pointer j; \
676 if (!i.lock()) { j = Self::New(); i = j; } \
679 bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
681 return new CLASS<T1,T2>(name); \
683 CLASS ## Descriptor() \
685 bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
686 <<"Descriptor()"<<std::endl)
687 //============================================================================
689 //============================================================================
690 /// Ends a template AtomicBlackBox description block of template param T1 and T2
691 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
692 bbtkDecTab("Kernel",9); \
696 //============================================================================
700 //============================================================================
701 /// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
702 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE) \
703 AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
704 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
705 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
706 (&CLASS<T1,T2>::bbGetInput##NAME), \
707 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
708 (&CLASS<T1,T2>::bbSetInput##NAME) ) )
709 //============================================================================
711 //============================================================================
712 /// Describes a 2 template params AtomicBlackBox output (to be put inside the UBB description block)
713 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE) \
714 AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor \
715 (typeid(CLASS ## Descriptor),#NAME,DESCR,"", \
716 new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
717 (&CLASS<T1,T2>::bbGetOutput##NAME), \
718 new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
719 (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
720 //============================================================================
722 //============================================================================
723 /// Template AtomicBlackBox std implementation of ctor and dtor
724 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
725 template <class T1, class T2> \
726 CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
727 : PARENT(name,false) \
729 BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
730 CLASS<T1,T2>::bbUserSetDefaultValues(); \
731 BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
733 template <class T1, class T2> \
734 CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
735 const std::string& name, bool allocate_connectors) \
736 : PARENT(from,name,false) \
738 BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
739 CLASS<T1,T2>::bbUserSetDefaultValues(); \
740 BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
742 template <class T1, class T2> \
743 CLASS<T1,T2>::~CLASS() \
745 BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
746 CLASS<T1,T2>::bbFinalizeProcessing(); \
747 BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
749 template <class T1, class T2> \
750 void CLASS<T1,T2>::bbLockDescriptor() \
752 bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
754 //============================================================================
760 //===========================================================================
762 //===========================================================================