bbtkAtomicBlackBoxMacros.h

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
00004   Language:  C++
00005   Date:      $Date: 2009/06/10 11:36:51 $
00006   Version:   $Revision: 1.19 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and 
00015 *  abiding by the rules of distribution of free software. You can  use, 
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability. 
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */                                                                         
00030 
00031 
00032 
00037 #ifndef __bbtkAtomicBlackBoxMacros_h__
00038 #define __bbtkAtomicBlackBoxMacros_h__
00039 
00040 //============================================================================
00043 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT)     \
00044   BBTK_OBJECT_MINIMAL_INTERFACE;                                        \
00045   private:                                                              \
00046   protected:                                                            \
00047   CLASS(const std::string& name, bool allocate_connectors = true);      \
00048   CLASS(Self& from, const std::string& name,                            \
00049         bool allocate_connectors = true);                               \
00050   ~CLASS();                                                             \
00051   public:                                                               \
00052   std::string GetObjectName() const                                     \
00053   { return std::string(#CLASS)+std::string(" '")                        \
00054       +bbGetNameWithParent()+std::string("'"); }                        \
00055   virtual void bbLockDescriptor();                                      \
00056   virtual void bbUserSetDefaultValues();                                \
00057   virtual void bbUserInitializeProcessing();                            \
00058   virtual void bbUserFinalizeProcessing();                              \
00059   virtual void bbRecursiveInitializeProcessing()                        \
00060   {                                                                     \
00061     PARENT::bbRecursiveInitializeProcessing();                          \
00062     CLASS::bbUserInitializeProcessing();                                \
00063   }                                                                     \
00064   virtual void bbRecursiveFinalizeProcessing()                          \
00065   {                                                                     \
00066     CLASS::bbUserFinalizeProcessing();                                  \
00067     PARENT::bbRecursiveFinalizeProcessing();                            \
00068   }                                                                     \
00069   private:                                                              \
00070   CLASS() : PARENT("") {}                                               \
00071   CLASS(const CLASS&) : PARENT("") {}                                   
00072   
00073 //============================================================================
00074 
00075 //============================================================================
00078 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT)         \
00079   BBTK_OBJECT_MINIMAL_INTERFACE;                                \
00080   private:                                                              \
00081   protected:                                                            \
00082   CLASS(const std::string& name, bool allocate_connectors = true);      \
00083   CLASS(Self& from, const std::string& name,                            \
00084         bool allocate_connectors = true);                               \
00085   ~CLASS();                                                             \
00086   public:                                                               \
00087   std::string GetObjectName() const                                     \
00088   { return std::string(#CLASS)+std::string(" '")                        \
00089       +bbGetNameWithParent()+std::string("'"); }                        \
00090   inline static Pointer New(const std::string& name)                    \
00091   {                                                                     \
00092     bbtkDebugMessage("object",1,"##> "<<#CLASS                          \
00093                      <<"::New(\""<<name<<"\")"<<std::endl);             \
00094     Pointer p = MakeBlackBoxPointer(new Self(name));                    \
00095     bbtkDebugMessage("object",1,"<## "<<#CLASS                          \
00096                      <<"::New(\""<<name<<"\")"<<std::endl);             \
00097     return p;                                                           \
00098   }                                                                     \
00099   inline bbtk::BlackBox::Pointer bbClone(const std::string& name)       \
00100   {                                                                     \
00101     bbtkBlackBoxDebugMessage("object",1,"##> "<<#CLASS                  \
00102                              <<"::bbClone(\""<<name<<"\")"<<std::endl); \
00103     Pointer p = MakeBlackBoxPointer(new Self(*this,name));              \
00104     bbtkBlackBoxDebugMessage("object",1,"<## "<<#CLASS                  \
00105                      <<"::bbClone(\""<<name<<"\")"<<std::endl);         \
00106     return p;                                                           \
00107   }                                                                     \
00108   virtual void bbLockDescriptor();                                      \
00109   virtual void bbUserSetDefaultValues();                                \
00110   virtual void bbUserInitializeProcessing();                            \
00111   virtual void bbUserFinalizeProcessing();                              \
00112   virtual void bbRecursiveInitializeProcessing()                        \
00113   {                                                                     \
00114     PARENT::bbRecursiveInitializeProcessing();                          \
00115     CLASS::bbUserInitializeProcessing();                                \
00116   }                                                                     \
00117   virtual void bbRecursiveFinalizeProcessing()                          \
00118   {                                                                     \
00119     CLASS::bbUserFinalizeProcessing();                                  \
00120     PARENT::bbRecursiveFinalizeProcessing();                            \
00121   }                                                                     \
00122   private:                                                              \
00123   CLASS() : PARENT("") {}                                               \
00124   CLASS(const CLASS&) : PARENT("") {}                                   
00125 
00126 //============================================================================
00127 
00128 //============================================================================
00129 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT)  \
00130   public : typedef CLASS Self;                          \
00131   BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
00132 //============================================================================
00133 
00134 //============================================================================
00135 #define BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENT)      \
00136   public : typedef CLASS Self;                          \
00137   BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT);
00138 //============================================================================
00139 
00140 //============================================================================
00142 #define BBTK_PROCESS(CALLBACK)                                          \
00143   public:                                                               \
00144   inline void bbUserProcess()                                           \
00145   {                                                                     \
00146     bbtkBlackBoxDebugMessage("process",1,"**> Processing..."            \
00147                              <<std::endl);                              \
00148     CALLBACK();                                                         \
00149     bbtkBlackBoxDebugMessage("process",1,"<** Processing"               \
00150                              <<std::endl);                              \
00151   }
00152 //============================================================================
00153 
00154 
00155 //============================================================================
00157 #define BBTK_DECLARE_INPUT(NAME,TYPE)                                   \
00158   protected:                                                            \
00159   TYPE bbmInput##NAME;                                                  \
00160   public:                                                               \
00161   TYPE bbGetInput##NAME ()                                              \
00162   { return bbmInput##NAME; }                                            \
00163   void bbSetInput##NAME (TYPE d)                                        \
00164   { bbmInput##NAME = d;                                                 \
00165     /*bbSetModifiedStatus();*/ }                                
00166 //============================================================================
00167 
00168 //============================================================================
00170 #define BBTK_DECLARE_OUTPUT(NAME,TYPE)                                  \
00171   protected:                                                            \
00172   TYPE bbmOutput##NAME;                                                 \
00173   public:                                                               \
00174   TYPE bbGetOutput##NAME ()                                             \
00175   { return bbmOutput##NAME; }                                           \
00176   void  bbSetOutput##NAME (TYPE d)                                      \
00177   { bbmOutput##NAME = d; }                                      
00178 //============================================================================
00179 
00180 //============================================================================
00182 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD)     \
00183   public:                                                               \
00184   TYPE bbGetInput##NAME ()                                              \
00185   { return GETMETHOD(); }                                               \
00186   void bbSetInput##NAME (TYPE d)                                        \
00187   { SETMETHOD(d);                                                       \
00188     /*bbSetModifiedStatus();*/ }                        
00189 //============================================================================
00190 
00191 
00192 //============================================================================
00194 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD)    \
00195   public:                                                               \
00196   TYPE bbGetOutput##NAME () const                                       \
00197   { return GETMETHOD(); }                                               \
00198   void bbSetOutput##NAME (TYPE d)                                       \
00199   { SETMETHOD(d); }                                                     
00200 //============================================================================
00201 
00202 
00203 
00204 //============================================================================
00205 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC)                   \
00206   bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS      \
00207                            <<"()"<<std::endl);                          \
00208   if (ALLOC)                                                            \
00209     {                                                                   \
00210       bbLockDescriptor();                                               \
00211       bbAllocateConnectors();                                           \
00212     }                                                                   
00213 
00214 //============================================================================
00215 
00216 //============================================================================
00217 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS)                           \
00218   bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS      \
00219                            <<"()"<<std::endl);          
00220 //============================================================================
00221 
00222 //============================================================================
00223 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC)         \
00224   bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS      \
00225                            <<"("<<FROM.bbGetFullName()                  \
00226                            <<")"<<std::endl);                           \
00227   if (ALLOC)                                                            \
00228     {                                                                   \
00229       bbLockDescriptor();                                               \
00230       bbAllocateConnectors();                                           \
00231     }
00232 //============================================================================
00233 
00234 //============================================================================
00235 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC)           \
00236   bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS      \
00237                            <<"("<<FROM.bbGetFullName()                  \
00238                            <<")"<<std::endl);                           \
00239   if (ALLOC)                                                            \
00240     {                                                                   \
00241       bbCopyIOValues(FROM);                                             \
00242     }
00243 //============================================================================
00244 
00245 //============================================================================
00246 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS)                          \
00247   bbtkBlackBoxDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS   \
00248                            <<"()"<<std::endl); \
00249   bbFinalizeProcessing();                                               
00250 
00251 
00252 //============================================================================
00253 
00254 //============================================================================
00255 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS)                            \
00256   bbtkBlackBoxDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS   \
00257                            <<"()"<<std::endl);
00258 
00259 //============================================================================
00260 
00261 
00262 //============================================================================
00264 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT)             \
00265   CLASS::CLASS(const std::string& name, bool allocate_connectors)       \
00266     : PARENT(name,false)                                                \
00267   {                                                                     \
00268     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors);        \
00269     CLASS::bbUserSetDefaultValues();                                            \
00270     BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS);                              \
00271   }                                                                     \
00272   CLASS::CLASS(CLASS& from,                                             \
00273                const std::string& name, bool allocate_connectors)       \
00274     : PARENT(from,name,false)                                           \
00275   {                                                                     \
00276     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
00277     CLASS::bbUserSetDefaultValues();                                            \
00278     BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors);                        \
00279   }                                                                     \
00280   CLASS::~CLASS()                                                       \
00281   {                                                                     \
00282     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
00283     BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS);                               \
00284   }                                                                     \
00285   void CLASS::bbLockDescriptor()                                        \
00286   {                                                                     \
00287     bbmDescriptorPointer = CLASS ## Descriptor::Instance();             \
00288   }
00289 //============================================================================
00290 
00291 
00292 //============================================================================
00294 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS)                       \
00295   {                                                                     \
00296   public: typedef CLASS ## Descriptor Self;                             \
00297     BBTK_OBJECT_MINIMAL_INTERFACE;                                      \
00298   public:                                                               \
00299     std::string GetObjectName() const                                   \
00300     {                                                                   \
00301       return std::string(BBTK_STRINGIFY(CLASS))                         \
00302         +std::string("Descriptor '")+GetFullTypeName()                  \
00303         +std::string("'");                                              \
00304     }                                                                   \
00305     size_t GetObjectSize() const { return sizeof(*this); }              \
00306     bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)        \
00307     {                                                                   \
00308       return CLASS::New(name);                                          \
00309     }                                                                   \
00310     virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance()       const \
00311       {                                                                 \
00312         return Instance();                                              \
00313       }                                                                 \
00314     static bbtk::AtomicBlackBoxDescriptor::Pointer Instance()           \
00315       {                                                                 \
00316         static bbtk::AtomicBlackBoxDescriptor::WeakPointer i;           \
00317         bbtk::AtomicBlackBoxDescriptor::Pointer j;                      \
00318         if (!i.lock()) { j = Self::New(); i = j; }                      \
00319         return i.lock();                                                \
00320       }                                                                 \
00321     static CLASS ## Descriptor::Pointer New()                           \
00322       {                                                                 \
00323         bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS)       \
00324                          <<"Descriptor::New" <<std::endl);              \
00325         CLASS ## Descriptor::Pointer p =                                \
00326           MakePointer(new CLASS ## Descriptor());                       \
00327         bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS)       \
00328                          <<"Descriptor::New" <<std::endl);              \
00329         return p;                                                       \
00330       }                                                                 \
00331   protected:                                                            \
00332     CLASS ## Descriptor()                                               \
00333       {                                                                 \
00334         bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::"      \
00335                          <<#CLASS<<"Descriptor()"<<std::endl);          
00336 //============================================================================
00337 
00338 //============================================================================
00340 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT)                     \
00341   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
00342   BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(CLASS);
00343 
00344 //============================================================================
00346 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS)                              \
00347   bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::"            \
00348                    <<#CLASS<<"Descriptor()"<<std::endl);                \
00349   }                                                                     \
00350   };                                                                    \
00351   
00352 //============================================================================
00353 
00354 
00355 //============================================================================
00357 #define BBTK_NAME(NAME) SetTypeName(NAME)
00358 //============================================================================
00359 
00360 //============================================================================
00362 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
00363 //============================================================================
00364 
00365 //============================================================================
00367 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
00368 //============================================================================
00369 
00370 //============================================================================
00372 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
00373 //============================================================================
00374 
00375 //============================================================================
00377 //#define BBTK_KIND(KIND) SetKind(KIND)
00378 //============================================================================
00379 
00380 //============================================================================
00382 #define BBTK_ADAPTOR()                        \
00383   SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
00384   AddToCategory("adaptor")
00385 //============================================================================
00386 
00387 //============================================================================
00389 #define BBTK_DEFAULT_ADAPTOR()                          \
00390   SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR);   \
00391   AddToCategory("adaptor")
00392 //============================================================================
00393 
00394 
00395 //============================================================================
00397 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE)                        \
00398   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
00399                      (typeid(CLASS ## Descriptor),                      \
00400                       #NAME,DESCR,NATURE,                               \
00401                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
00402                       (&CLASS::bbGetInput##NAME),                       \
00403                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
00404                       (&CLASS::bbSetInput##NAME) ) )
00405 //============================================================================
00406 
00407 //============================================================================
00409 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE)                       \
00410   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
00411                       (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE,  \
00412                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
00413                        (&CLASS::bbGetOutput##NAME),                     \
00414                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
00415                        (&CLASS::bbSetOutput##NAME) ) )
00416 //============================================================================
00417 
00418 
00419 //============================================================================
00421 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE)                 \
00422   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
00423                      (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE,   \
00424                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
00425                       (&CLASS::bbGetInput##NAME),                       \
00426                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
00427                       (&CLASS::bbSetInput##NAME),                       \
00428                       false) )
00429 //============================================================================
00430 
00431 //============================================================================
00433 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE)                \
00434   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
00435                       (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE,  \
00436                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
00437                        (&CLASS::bbGetOutput##NAME),                     \
00438                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
00439                        (&CLASS::bbSetOutput##NAME),\
00440                        false) )
00441 //============================================================================
00442 
00443 
00444 
00445 
00446 
00447 
00448 
00449 
00450 
00451 
00452 //============================================================================
00453 //============================================================================
00454 // Template user black boxes macros
00455 //============================================================================
00456 //============================================================================
00457 
00458 //============================================================================
00459 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T)       \
00460   public : typedef CLASS<T> Self;                               \
00461   BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
00462 //============================================================================
00463 
00464 //============================================================================
00466 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT)            \
00467   template <class T>                                                    \
00468   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
00469   {                                                                     \
00470   public: typedef CLASS ## Descriptor<T> Self;                          \
00471     BBTK_OBJECT_MINIMAL_INTERFACE;                                      \
00472   public:                                                               \
00473     std::string GetObjectName() const                                   \
00474     {                                                                   \
00475       return std::string(BBTK_STRINGIFY(CLASS))                         \
00476         +std::string("Descriptor<")+bbtk::TypeName<T>()                 \
00477         +std::string("> '")+GetFullTypeName()                           \
00478         +std::string("'");                                              \
00479     }                                                                   \
00480     static Pointer New()                                                \
00481       {                                                                 \
00482         bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS)       \
00483                          <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
00484                          <<std::endl);                                  \
00485         Pointer p = MakePointer(new Self());                            \
00486         bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS)       \
00487                          <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
00488                          <<std::endl);                                  \
00489         return p;                                                       \
00490       }                                                                 \
00491     virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance()       const \
00492       {                                                                 \
00493         return Instance();                                              \
00494       }                                                                 \
00495     static bbtk::AtomicBlackBoxDescriptor::Pointer Instance()           \
00496       {                                                                 \
00497         static bbtk::AtomicBlackBoxDescriptor::WeakPointer i;           \
00498         bbtk::AtomicBlackBoxDescriptor::Pointer j;                      \
00499         if (!i.lock()) { j = Self::New(); i = j; }                      \
00500         return i.lock();                                                \
00501       }                                                                 \
00502     bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)        \
00503     {                                                                   \
00504       return CLASS<T>::New(name);                                       \
00505     }                                                                   \
00506     CLASS ## Descriptor()                                               \
00507       {                                                                 \
00508         bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<"       \
00509                          <<bbtk::TypeName<T>()<<">::"                   \
00510                          <<#CLASS<<"Descriptor()"<<std::endl);          
00511 
00512 //============================================================================
00513 
00514 //============================================================================
00516 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)                     \
00517   bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<"             \
00518                    <<bbtk::TypeName<T>()<<">::"                         \
00519                    <<#CLASS<<"Descriptor()"<<std::endl);                \
00520   }                                                                     \
00521   };                                                                    
00522 
00523 //============================================================================
00524 
00525 //============================================================================
00527 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE)                      \
00528   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
00529                      (typeid(CLASS ## Descriptor),#NAME,DESCR,"",       \
00530                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
00531                       (&CLASS<T>::bbGetInput##NAME),                    \
00532                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
00533                       (&CLASS<T>::bbSetInput##NAME) ) )
00534 //============================================================================
00535 
00536 //============================================================================
00538 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE)                     \
00539   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
00540                       (typeid(CLASS ## Descriptor),#NAME,DESCR,"",      \
00541                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
00542                        (&CLASS<T>::bbGetOutput##NAME),                  \
00543                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
00544                        (&CLASS<T>::bbSetOutput##NAME) ) )
00545 //============================================================================
00546 
00547 
00548 //JCP 09JUIN2009 BBTK_EXPORT
00549 
00550 //============================================================================
00552 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT)            \
00553   template <class T>                                                    \
00554   CLASS<T>::CLASS(const std::string& name, bool alloc)                  \
00555     : PARENT(name,false)                                                \
00556   {                                                                     \
00557     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
00558     CLASS<T>::bbUserSetDefaultValues();                                 \
00559     BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS);                              \
00560   }                                                                     \
00561   template <class T>                                                    \
00562   CLASS<T>::CLASS(CLASS<T>& from,                                       \
00563                   const std::string& name, bool allocate_connectors)    \
00564     : PARENT(from,name,false)                                           \
00565   {                                                                     \
00566     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
00567     CLASS<T>::bbUserSetDefaultValues();                                 \
00568     BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors);                        \
00569   }                                                                     \
00570   template <class T>                                                    \
00571   CLASS<T>::~CLASS()                                                    \
00572   {                                                                     \
00573     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
00574     BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS);                               \
00575   }                                                                     \
00576   template <class T>                                                    \
00577   void CLASS<T>::bbLockDescriptor()                                     \
00578   {                                                                     \
00579     bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance();          \
00580   }
00581 //============================================================================
00582 
00583 
00584 
00585 //============================================================================
00586 // Two template params user black boxes macros
00587 //============================================================================
00588 
00589 //============================================================================
00590 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2)  \
00591   public : typedef CLASS<T1,T2> Self;                                   \
00592   BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
00593 //===========================================================================
00594 
00595 //============================================================================
00597 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT)           \
00598   template <class T1, class T2>                                         \
00599   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
00600   {                                                                     \
00601   public: typedef CLASS ## Descriptor<T1,T2> Self;                      \
00602     BBTK_OBJECT_MINIMAL_INTERFACE;                                      \
00603   public:                                                               \
00604     std::string GetObjectName() const                                   \
00605     {                                                                   \
00606       return std::string(BBTK_STRINGIFY(CLASS))                         \
00607         +std::string("Descriptor<")+bbtk::TypeName<T1>()                \
00608         +std::string(",")+bbtk::TypeName<T2>()                          \
00609         +std::string("> '")+GetFullTypeName()                           \
00610         +std::string("'");                                              \
00611     }                                                                   \
00612     static Pointer New()                                                \
00613       {                                                                 \
00614         bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS)       \
00615                          <<"Descriptor<"<<bbtk::TypeName<T1>()<<","     \
00616                          <<bbtk::TypeName<T2>()<<">::New"<<std::endl);  \
00617         Pointer p = MakePointer(new Self());                            \
00618         bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS)       \
00619                          <<"Descriptor<"<<bbtk::TypeName<T1>()<<","     \
00620                          <<bbtk::TypeName<T2>()<<">::New"<<std::endl);  \
00621         return p;                                                       \
00622       }                                                                 \
00623     virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
00624       {                                                                 \
00625         return Instance();                                              \
00626       }                                                                 \
00627     static bbtk::AtomicBlackBoxDescriptor::Pointer Instance()           \
00628       {                                                                 \
00629         static bbtk::AtomicBlackBoxDescriptor::WeakPointer i;           \
00630         bbtk::AtomicBlackBoxDescriptor::Pointer j;                      \
00631         if (!i.lock()) { j = Self::New(); i = j; }                      \
00632         return i.lock();                                                \
00633       }                                                                 \
00634     bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)        \
00635     {                                                                   \
00636       return CLASS<T1,T2>::New(name);                                   \
00637     }                                                                   \
00638     CLASS ## Descriptor()                                               \
00639       {                                                                 \
00640         bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<"       \
00641                          <<bbtk::TypeName<T1>()<<","                    \
00642                          <<bbtk::TypeName<T2>()<<">::"                  \
00643                          <<#CLASS<<"Descriptor()"<<std::endl);          
00644 //============================================================================
00645 
00646 //============================================================================
00648 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)                    \
00649   bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<"             \
00650                    <<bbtk::TypeName<T1>()<<","                          \
00651                    <<bbtk::TypeName<T2>()<<">::"                        \
00652                    <<#CLASS<<"Descriptor()"<<std::endl);                \
00653   }                                                                     \
00654   };                                                                    
00655 
00656 //============================================================================
00657 
00658 
00659 
00660 /*
00661 //============================================================================
00662 // Two template params user black boxes macros
00663 
00665 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)           \
00666   template <TYPE1 T1, TYPE2 T2>                                         \
00667   class  CLASS ## Descriptor : public bbtk::BlackBoxDescriptor          \
00668   {                                                                     \
00669   public:                                                               \
00670     virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance()        const   \
00671       {                                                                 \
00672         return Instance();                                              \
00673       }                                                                 \
00674     static bbtk:AtomicBlackBoxDescriptor::Pointer Instance()                    \
00675       {                                                                 \
00676         static bbtk:AtomicBlackBoxDescriptor::WeakPointer i;                    \
00677         bbtk:AtomicBlackBoxDescriptor::Pointer j;                               \
00678         if (!i.lock()) { j = Self::New(); i = j; }                      \
00679         return i.lock();                                                \
00680       }                                                                 \
00681     bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)        \
00682     {                                                                   \
00683       return new CLASS<T1,T2>(name);                                    \
00684     }                                                                   \
00685     CLASS ## Descriptor()                                               \
00686       {                                                                 \
00687       bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS     \
00688                           <<"Descriptor()"<<std::endl)
00689 //============================================================================
00690 
00691 //============================================================================
00693 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)     \
00694   bbtkDecTab("Kernel",9);                                                       \
00695   }                                                                     \
00696   };                                                                    
00697 
00698 //============================================================================
00699 
00700 */
00701 
00702 //============================================================================
00704 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE)                     \
00705   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
00706                      (typeid(CLASS ## Descriptor),#NAME,DESCR,"",       \
00707                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE >      \
00708                       (&CLASS<T1,T2>::bbGetInput##NAME),                \
00709                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE >      \
00710                       (&CLASS<T1,T2>::bbSetInput##NAME) ) )
00711 //============================================================================
00712 
00713 //============================================================================
00715 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE)                    \
00716   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
00717                       (typeid(CLASS ## Descriptor),#NAME,DESCR,"",      \
00718                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
00719                        (&CLASS<T1,T2>::bbGetOutput##NAME),              \
00720                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
00721                        (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
00722 //============================================================================
00723 
00724 //============================================================================
00726 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT)           \
00727   template <class T1, class T2>                                         \
00728   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)              \
00729     : PARENT(name,false)                                                \
00730   {                                                                     \
00731     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
00732     CLASS<T1,T2>::bbUserSetDefaultValues();                             \
00733     BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS);                              \
00734   }                                                                     \
00735   template <class T1, class T2>                                         \
00736   CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                               \
00737                       const std::string& name, bool allocate_connectors) \
00738     : PARENT(from,name,false)                                           \
00739   {                                                                     \
00740     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
00741     CLASS<T1,T2>::bbUserSetDefaultValues();                             \
00742     BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors);                        \
00743   }                                                                     \
00744   template <class T1, class T2>                                         \
00745   CLASS<T1,T2>::~CLASS()                                                \
00746   {                                                                     \
00747     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
00748     BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS);                               \
00749   }                                                                     \
00750   template <class T1, class T2>                                         \
00751   void CLASS<T1,T2>::bbLockDescriptor()                                 \
00752   {                                                                     \
00753     bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance();      \
00754   }
00755 //============================================================================
00756 
00757 
00758 
00759 
00760 
00761 //===========================================================================
00763 //===========================================================================
00764 #endif

Generated on Thu May 31 14:12:03 2012 for BBTK by  doxygen 1.5.7.1