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: 2008/10/17 08:18:12 $
00006   Version:   $Revision: 1.11 $
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   private:                                                              \
00057   CLASS() : PARENT("") {}                                               \
00058   CLASS(const CLASS&) : PARENT("") {}                                   
00059 
00060 //============================================================================
00061 
00062 //============================================================================
00065 #define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT)         \
00066   BBTK_OBJECT_MINIMAL_INTERFACE;                                \
00067   private:                                                              \
00068   protected:                                                            \
00069   CLASS(const std::string& name, bool allocate_connectors = true);      \
00070   CLASS(Self& from, const std::string& name,                            \
00071         bool allocate_connectors = true);                               \
00072   ~CLASS();                                                             \
00073   public:                                                               \
00074   std::string GetObjectName() const                                     \
00075   { return std::string(#CLASS)+std::string(" '")                        \
00076       +bbGetNameWithParent()+std::string("'"); }                        \
00077   inline static Pointer New(const std::string& name)                    \
00078   {                                                                     \
00079     bbtkDebugMessage("object",1,"##> "<<#CLASS                          \
00080                      <<"::New(\""<<name<<"\")"<<std::endl);             \
00081     Pointer p = MakeBlackBoxPointer(new Self(name));                    \
00082     bbtkDebugMessage("object",1,"<## "<<#CLASS                          \
00083                      <<"::New(\""<<name<<"\")"<<std::endl);             \
00084     return p;                                                           \
00085   }                                                                     \
00086   inline bbtk::BlackBox::Pointer bbClone(const std::string& name)       \
00087   {                                                                     \
00088     bbtkDebugMessage("object",1,"##> "<<#CLASS                          \
00089                      <<"::bbClone(\""<<name<<"\")"<<std::endl);         \
00090     Pointer p = MakeBlackBoxPointer(new Self(*this,name));              \
00091     bbtkDebugMessage("object",1,"<## "<<#CLASS                          \
00092                      <<"::bbClone(\""<<name<<"\")"<<std::endl);         \
00093     return p;                                                           \
00094   }                                                                     \
00095   virtual void bbLockDescriptor();                                      \
00096   private:                                                              \
00097   CLASS() : PARENT("") {}                                               \
00098   CLASS(const CLASS&) : PARENT("") {}                                   
00099 
00100 //============================================================================
00101 
00102 //============================================================================
00103 #define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT)  \
00104   public : typedef CLASS Self;                          \
00105   BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
00106 //============================================================================
00107 
00108 //============================================================================
00109 #define BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENT)      \
00110   public : typedef CLASS Self;                          \
00111   BBTK_BLACK_BOX_INTERFACE_INTERNAL_WITHOUT_NEW(CLASS,PARENT);
00112 //============================================================================
00113 
00114 //============================================================================
00116 #define BBTK_PROCESS(CALLBACK)                                          \
00117   public:                                                               \
00118   inline void bbUserProcess()                                           \
00119   {                                                                     \
00120     bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName()    \
00121                      <<"]"<<std::endl);                                 \
00122     CALLBACK();                                                         \
00123     bbtkDebugMessage("process",2,"<** Processing ["<<bbGetFullName()    \
00124                      <<"]"<<std::endl);                                 \
00125   }
00126 //============================================================================
00127 
00128 
00129 //============================================================================
00131 #define BBTK_DECLARE_INPUT(NAME,TYPE)                                   \
00132   protected:                                                            \
00133   TYPE bbmInput##NAME;                                                  \
00134   public:                                                               \
00135   TYPE bbGetInput##NAME ()                                              \
00136   { return bbmInput##NAME; }                                            \
00137   void bbSetInput##NAME (TYPE d)                                        \
00138   { bbmInput##NAME = d;                                                 \
00139     /*bbSetModifiedStatus();*/ }                                
00140 //============================================================================
00141 
00142 //============================================================================
00144 #define BBTK_DECLARE_OUTPUT(NAME,TYPE)                                  \
00145   protected:                                                            \
00146   TYPE bbmOutput##NAME;                                                 \
00147   public:                                                               \
00148   TYPE bbGetOutput##NAME ()                                             \
00149   { return bbmOutput##NAME; }                                           \
00150   void  bbSetOutput##NAME (TYPE d)                                      \
00151   { bbmOutput##NAME = d; }                                      
00152 //============================================================================
00153 
00154 //============================================================================
00156 #define BBTK_DECLARE_INHERITED_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD)     \
00157   public:                                                               \
00158   TYPE bbGetInput##NAME ()                                              \
00159   { return GETMETHOD(); }                                               \
00160   void bbSetInput##NAME (TYPE d)                                        \
00161   { SETMETHOD(d);                                                       \
00162     /*bbSetModifiedStatus();*/ }                        
00163 //============================================================================
00164 
00165 
00166 //============================================================================
00168 #define BBTK_DECLARE_INHERITED_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD)    \
00169   public:                                                               \
00170   TYPE bbGetOutput##NAME () const                                       \
00171   { return GETMETHOD(); }                                               \
00172   void bbSetOutput##NAME (TYPE d)                                       \
00173   { SETMETHOD(d); }                                                     
00174 //============================================================================
00175 
00176 
00177 
00178 //============================================================================
00179 #define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC)                   \
00180   bbtkDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS              \
00181                    <<"(\""<<bbGetName()<<"\")"<<std::endl);             \
00182   if (ALLOC)                                                            \
00183     {                                                                   \
00184       bbLockDescriptor();                                               \
00185       bbAllocateConnectors();                                           \
00186     }
00187 //============================================================================
00188 
00189 //============================================================================
00190 #define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS)                           \
00191   bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS              \
00192                    <<"(\""<<bbGetName()<<"\")"<<std::endl);             
00193 //============================================================================
00194 
00195 //============================================================================
00196 #define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC)         \
00197   bbtkDebugMessageInc("object",2,"==> "<<#CLASS<<"::"<<#CLASS           \
00198                       <<"("<<FROM.bbGetFullName()<<",\""                \
00199                       <<bbGetName()<<"\")"<<std::endl);                 \
00200   if (ALLOC)                                                            \
00201     {                                                                   \
00202       bbLockDescriptor();                                               \
00203       bbAllocateConnectors();                                           \
00204       bbCopyIOValues(FROM);                                             \
00205    }
00206 //============================================================================
00207 
00208 //============================================================================
00209 #define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM)                 \
00210   bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS              \
00211                    <<"("<<FROM.bbGetFullName()<<",\""                   \
00212                    <<bbGetName()<<"\")"<<std::endl);            
00213 //============================================================================
00214 
00215 //============================================================================
00216 #define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS)                          \
00217   bbtkDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS           \
00218                    <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
00219 //============================================================================
00220 
00221 //============================================================================
00222 #define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS)                            \
00223   bbtkDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS           \
00224                    <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
00225 
00226 //============================================================================
00227 
00228 
00229 //============================================================================
00231 #define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT)             \
00232   CLASS::CLASS(const std::string& name, bool allocate_connectors)       \
00233     : PARENT(name,false)                                                \
00234   {                                                                     \
00235     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors);        \
00236     CLASS::bbUserConstructor();                                         \
00237     BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS);                              \
00238   }                                                                     \
00239   CLASS::CLASS(CLASS& from,                                             \
00240                const std::string& name, bool allocate_connectors)       \
00241     : PARENT(from,name,false)                                           \
00242   {                                                                     \
00243     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
00244     CLASS::bbUserCopyConstructor();                                     \
00245     BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from);                    \
00246   }                                                                     \
00247   CLASS::~CLASS()                                                       \
00248   {                                                                     \
00249     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
00250     CLASS::bbUserDestructor();                                          \
00251     BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS);                               \
00252   }                                                                     \
00253   void CLASS::bbLockDescriptor()                                        \
00254   {                                                                     \
00255     bbmDescriptorPointer = CLASS ## Descriptor::Instance();             \
00256   }
00257 //============================================================================
00258 
00259 
00260 //============================================================================
00262 #define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT)                     \
00263   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
00264   {                                                                     \
00265   public: typedef CLASS ## Descriptor Self;                             \
00266     BBTK_OBJECT_MINIMAL_INTERFACE;                                      \
00267   public:                                                               \
00268     std::string GetObjectName() const                                   \
00269     {                                                                   \
00270       return std::string(BBTK_STRINGIFY(CLASS))                         \
00271         +std::string("Descriptor '")+GetFullTypeName()                  \
00272         +std::string("'");                                              \
00273     }                                                                   \
00274     size_t GetObjectSize() const { return sizeof(*this); }              \
00275     bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)        \
00276     {                                                                   \
00277       return CLASS::New(name);                                          \
00278     }                                                                   \
00279     virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance()       const \
00280       {                                                                 \
00281         return Instance();                                              \
00282       }                                                                 \
00283     static bbtk::AtomicBlackBoxDescriptor::Pointer Instance()                   \
00284       {                                                                 \
00285         static bbtk::AtomicBlackBoxDescriptor::WeakPointer i;                   \
00286         bbtk::AtomicBlackBoxDescriptor::Pointer j;                              \
00287         if (!i.lock()) { j = Self::New(); i = j; }                      \
00288         return i.lock();                                                \
00289       }                                                                 \
00290     static CLASS ## Descriptor::Pointer New()                           \
00291       {                                                                 \
00292         bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS)       \
00293                          <<"Descriptor::New" <<std::endl);              \
00294         CLASS ## Descriptor::Pointer p =                                \
00295           MakePointer(new CLASS ## Descriptor());                       \
00296         bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS)       \
00297                          <<"Descriptor::New" <<std::endl);              \
00298         return p;                                                       \
00299       }                                                                 \
00300   protected:                                                            \
00301     CLASS ## Descriptor()                                               \
00302       {                                                                 \
00303         bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::"      \
00304                          <<#CLASS<<"Descriptor()"<<std::endl);          
00305 //============================================================================
00306 
00307 //============================================================================
00309 #define BBTK_END_DESCRIBE_BLACK_BOX(CLASS)                              \
00310   bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::"            \
00311                    <<#CLASS<<"Descriptor()"<<std::endl);                \
00312   }                                                                     \
00313   };                                                                    \
00314   
00315 //============================================================================
00316 
00317 
00318 //============================================================================
00320 #define BBTK_NAME(NAME) SetTypeName(NAME)
00321 //============================================================================
00322 
00323 //============================================================================
00325 #define BBTK_AUTHOR(AUTHOR) AddToAuthor(AUTHOR)
00326 //============================================================================
00327 
00328 //============================================================================
00330 #define BBTK_CATEGORY(CATEGORY) AddToCategory(CATEGORY)
00331 //============================================================================
00332 
00333 //============================================================================
00335 #define BBTK_DESCRIPTION(DESCR) AddToDescription(DESCR)
00336 //============================================================================
00337 
00338 //============================================================================
00340 //#define BBTK_KIND(KIND) SetKind(KIND)
00341 //============================================================================
00342 
00343 //============================================================================
00345 #define BBTK_ADAPTOR()                        \
00346   SetKind(bbtk::BlackBoxDescriptor::ADAPTOR); \
00347   AddToCategory("adaptor")
00348 //============================================================================
00349 
00350 //============================================================================
00352 #define BBTK_DEFAULT_ADAPTOR()                          \
00353   SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR);   \
00354   AddToCategory("adaptor")
00355 //============================================================================
00356 
00357 
00358 //============================================================================
00360 #define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE)                        \
00361   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
00362                      (typeid(CLASS ## Descriptor),                      \
00363                       #NAME,DESCR,NATURE,                               \
00364                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
00365                       (&CLASS::bbGetInput##NAME),                       \
00366                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
00367                       (&CLASS::bbSetInput##NAME) ) )
00368 //============================================================================
00369 
00370 //============================================================================
00372 #define BBTK_OUTPUT(CLASS,NAME,DESCR,TYPE,NATURE)                       \
00373   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
00374                       (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE,  \
00375                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
00376                        (&CLASS::bbGetOutput##NAME),                     \
00377                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
00378                        (&CLASS::bbSetOutput##NAME) ) )
00379 //============================================================================
00380 
00381 
00382 //============================================================================
00384 #define BBTK_INPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE)                 \
00385   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
00386                      (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE,   \
00387                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
00388                       (&CLASS::bbGetInput##NAME),                       \
00389                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
00390                       (&CLASS::bbSetInput##NAME),                       \
00391                       false) )
00392 //============================================================================
00393 
00394 //============================================================================
00396 #define BBTK_OUTPUT_NOCOPY(CLASS,NAME,DESCR,TYPE,NATURE)                \
00397   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
00398                       (typeid(CLASS ## Descriptor),#NAME,DESCR,NATURE,  \
00399                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS,TYPE,TYPE > \
00400                        (&CLASS::bbGetOutput##NAME),                     \
00401                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS,TYPE,TYPE > \
00402                        (&CLASS::bbSetOutput##NAME),\
00403                        false) )
00404 //============================================================================
00405 
00406 
00407 
00408 
00409 
00410 
00411 
00412 
00413 
00414 
00415 //============================================================================
00416 //============================================================================
00417 // Template user black boxes macros
00418 //============================================================================
00419 //============================================================================
00420 
00421 //============================================================================
00422 #define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T)       \
00423   public : typedef CLASS<T> Self;                               \
00424   BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
00425 //============================================================================
00426 
00427 //============================================================================
00429 #define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT)            \
00430   template <class T>                                                    \
00431   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
00432   {                                                                     \
00433   public: typedef CLASS ## Descriptor<T> Self;                          \
00434     BBTK_OBJECT_MINIMAL_INTERFACE;                                      \
00435   public:                                                               \
00436     std::string GetObjectName() const                                   \
00437     {                                                                   \
00438       return std::string(BBTK_STRINGIFY(CLASS))                         \
00439         +std::string("Descriptor<")+bbtk::TypeName<T>()                 \
00440         +std::string("> '")+GetFullTypeName()                           \
00441         +std::string("'");                                              \
00442     }                                                                   \
00443     static Pointer New()                                                \
00444       {                                                                 \
00445         bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS)       \
00446                          <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
00447                          <<std::endl);                                  \
00448         Pointer p = MakePointer(new Self());                            \
00449         bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS)       \
00450                          <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
00451                          <<std::endl);                                  \
00452         return p;                                                       \
00453       }                                                                 \
00454     virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance()       const \
00455       {                                                                 \
00456         return Instance();                                              \
00457       }                                                                 \
00458     static bbtk::AtomicBlackBoxDescriptor::Pointer Instance()           \
00459       {                                                                 \
00460         static bbtk::AtomicBlackBoxDescriptor::WeakPointer i;           \
00461         bbtk::AtomicBlackBoxDescriptor::Pointer j;                      \
00462         if (!i.lock()) { j = Self::New(); i = j; }                      \
00463         return i.lock();                                                \
00464       }                                                                 \
00465     bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)        \
00466     {                                                                   \
00467       return CLASS<T>::New(name);                                       \
00468     }                                                                   \
00469     CLASS ## Descriptor()                                               \
00470       {                                                                 \
00471         bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<"       \
00472                          <<bbtk::TypeName<T>()<<">::"                   \
00473                          <<#CLASS<<"Descriptor()"<<std::endl);          
00474 
00475 //============================================================================
00476 
00477 //============================================================================
00479 #define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS)                     \
00480   bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<"             \
00481                    <<bbtk::TypeName<T>()<<">::"                         \
00482                    <<#CLASS<<"Descriptor()"<<std::endl);                \
00483   }                                                                     \
00484   };                                                                    
00485 
00486 //============================================================================
00487 
00488 //============================================================================
00490 #define BBTK_TEMPLATE_INPUT(CLASS,NAME,DESCR,TYPE)                      \
00491   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
00492                      (typeid(CLASS ## Descriptor),#NAME,DESCR,"",       \
00493                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
00494                       (&CLASS<T>::bbGetInput##NAME),                    \
00495                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
00496                       (&CLASS<T>::bbSetInput##NAME) ) )
00497 //============================================================================
00498 
00499 //============================================================================
00501 #define BBTK_TEMPLATE_OUTPUT(CLASS,NAME,DESCR,TYPE)                     \
00502   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
00503                       (typeid(CLASS ## Descriptor),#NAME,DESCR,"",      \
00504                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T>,TYPE,TYPE > \
00505                        (&CLASS<T>::bbGetOutput##NAME),                  \
00506                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T>,TYPE,TYPE > \
00507                        (&CLASS<T>::bbSetOutput##NAME) ) )
00508 //============================================================================
00509 
00510 //============================================================================
00512 #define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT)            \
00513   template <class T>                                                    \
00514   CLASS<T>::CLASS(const std::string& name, bool alloc)                  \
00515     : PARENT(name,false)                                                \
00516   {                                                                     \
00517     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
00518     CLASS<T>::bbUserConstructor();                                      \
00519     BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS);                              \
00520   }                                                                     \
00521   template <class T>                                                    \
00522   CLASS<T>::CLASS(CLASS<T>& from,                                       \
00523                   const std::string& name, bool allocate_connectors)    \
00524     : PARENT(from,name,false)                                           \
00525   {                                                                     \
00526     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
00527     CLASS<T>::bbUserCopyConstructor();                                  \
00528     BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from);                    \
00529   }                                                                     \
00530   template <class T>                                                    \
00531   CLASS<T>::~CLASS()                                                    \
00532   {                                                                     \
00533     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
00534     CLASS<T>::bbUserDestructor();                                       \
00535     BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS);                               \
00536   }                                                                     \
00537   template <class T>                                                    \
00538   void CLASS<T>::bbLockDescriptor()                                     \
00539   {                                                                     \
00540     bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance();          \
00541   }
00542 //============================================================================
00543 
00544 
00545 
00546 //============================================================================
00547 // Two template params user black boxes macros
00548 //============================================================================
00549 
00550 //============================================================================
00551 #define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2)  \
00552   public : typedef CLASS<T1,T2> Self;                                   \
00553   BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
00554 //===========================================================================
00555 
00556 //============================================================================
00558 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT)           \
00559   template <class T1, class T2>                                         \
00560   class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
00561   {                                                                     \
00562   public: typedef CLASS ## Descriptor<T1,T2> Self;                      \
00563     BBTK_OBJECT_MINIMAL_INTERFACE;                                      \
00564   public:                                                               \
00565     std::string GetObjectName() const                                   \
00566     {                                                                   \
00567       return std::string(BBTK_STRINGIFY(CLASS))                         \
00568         +std::string("Descriptor<")+bbtk::TypeName<T1>()                \
00569         +std::string(",")+bbtk::TypeName<T2>()                          \
00570         +std::string("> '")+GetFullTypeName()                           \
00571         +std::string("'");                                              \
00572     }                                                                   \
00573     static Pointer New()                                                \
00574       {                                                                 \
00575         bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS)       \
00576                          <<"Descriptor<"<<bbtk::TypeName<T1>()<<","     \
00577                          <<bbtk::TypeName<T2>()<<">::New"<<std::endl);  \
00578         Pointer p = MakePointer(new Self());                            \
00579         bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS)       \
00580                          <<"Descriptor<"<<bbtk::TypeName<T1>()<<","     \
00581                          <<bbtk::TypeName<T2>()<<">::New"<<std::endl);  \
00582         return p;                                                       \
00583       }                                                                 \
00584     virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
00585       {                                                                 \
00586         return Instance();                                              \
00587       }                                                                 \
00588     static bbtk::AtomicBlackBoxDescriptor::Pointer Instance()           \
00589       {                                                                 \
00590         static bbtk::AtomicBlackBoxDescriptor::WeakPointer i;           \
00591         bbtk::AtomicBlackBoxDescriptor::Pointer j;                      \
00592         if (!i.lock()) { j = Self::New(); i = j; }                      \
00593         return i.lock();                                                \
00594       }                                                                 \
00595     bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)        \
00596     {                                                                   \
00597       return CLASS<T1,T2>::New(name);                                   \
00598     }                                                                   \
00599     CLASS ## Descriptor()                                               \
00600       {                                                                 \
00601         bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<"       \
00602                          <<bbtk::TypeName<T1>()<<","                    \
00603                          <<bbtk::TypeName<T2>()<<">::"                  \
00604                          <<#CLASS<<"Descriptor()"<<std::endl);          
00605 //============================================================================
00606 
00607 //============================================================================
00609 #define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS)                    \
00610   bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<"             \
00611                    <<bbtk::TypeName<T1>()<<","                          \
00612                    <<bbtk::TypeName<T2>()<<">::"                        \
00613                    <<#CLASS<<"Descriptor()"<<std::endl);                \
00614   }                                                                     \
00615   };                                                                    
00616 
00617 //============================================================================
00618 
00619 
00620 
00621 /*
00622 //============================================================================
00623 // Two template params user black boxes macros
00624 
00626 #define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)           \
00627   template <TYPE1 T1, TYPE2 T2>                                         \
00628   class  CLASS ## Descriptor : public bbtk::BlackBoxDescriptor          \
00629   {                                                                     \
00630   public:                                                               \
00631     virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance()        const   \
00632       {                                                                 \
00633         return Instance();                                              \
00634       }                                                                 \
00635     static bbtk:AtomicBlackBoxDescriptor::Pointer Instance()                    \
00636       {                                                                 \
00637         static bbtk:AtomicBlackBoxDescriptor::WeakPointer i;                    \
00638         bbtk:AtomicBlackBoxDescriptor::Pointer j;                               \
00639         if (!i.lock()) { j = Self::New(); i = j; }                      \
00640         return i.lock();                                                \
00641       }                                                                 \
00642     bbtk::BlackBox::Pointer NewBlackBox(const std::string& name)        \
00643     {                                                                   \
00644       return new CLASS<T1,T2>(name);                                    \
00645     }                                                                   \
00646     CLASS ## Descriptor()                                               \
00647       {                                                                 \
00648       bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS     \
00649                           <<"Descriptor()"<<std::endl)
00650 //============================================================================
00651 
00652 //============================================================================
00654 #define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2)     \
00655   bbtkDecTab("Kernel",9);                                                       \
00656   }                                                                     \
00657   };                                                                    
00658 
00659 //============================================================================
00660 
00661 */
00662 
00663 //============================================================================
00665 #define BBTK_TEMPLATE2_INPUT(CLASS,NAME,DESCR,TYPE)                     \
00666   AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor            \
00667                      (typeid(CLASS ## Descriptor),#NAME,DESCR,"",       \
00668                       new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE >      \
00669                       (&CLASS<T1,T2>::bbGetInput##NAME),                \
00670                       new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE >      \
00671                       (&CLASS<T1,T2>::bbSetInput##NAME) ) )
00672 //============================================================================
00673 
00674 //============================================================================
00676 #define BBTK_TEMPLATE2_OUTPUT(CLASS,NAME,DESCR,TYPE)                    \
00677   AddOutputDescriptor(new bbtk::AtomicBlackBoxOutputDescriptor          \
00678                       (typeid(CLASS ## Descriptor),#NAME,DESCR,"",      \
00679                        new bbtk::AtomicBlackBoxTGetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
00680                        (&CLASS<T1,T2>::bbGetOutput##NAME),              \
00681                        new bbtk::AtomicBlackBoxTSetFunctor<CLASS<T1,T2>,TYPE,TYPE > \
00682                        (&CLASS<T1,T2>::bbSetOutput##NAME) ) )
00683 //============================================================================
00684 
00685 //============================================================================
00687 #define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT)           \
00688   template <class T1, class T2>                                         \
00689   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)              \
00690     : PARENT(name,false)                                                \
00691   {                                                                     \
00692     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
00693     CLASS<T1,T2>::bbUserConstructor();                                  \
00694     BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS);                              \
00695   }                                                                     \
00696   template <class T1, class T2>                                         \
00697   CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                               \
00698                       const std::string& name, bool allocate_connectors) \
00699     : PARENT(from,name,false)                                           \
00700   {                                                                     \
00701     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
00702     CLASS<T1,T2>::bbUserCopyConstructor();                              \
00703     BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from);                    \
00704   }                                                                     \
00705   template <class T1, class T2>                                         \
00706   CLASS<T1,T2>::~CLASS()                                                \
00707   {                                                                     \
00708     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
00709     CLASS<T1,T2>::bbUserDestructor();                                   \
00710     BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS);                               \
00711   }                                                                     \
00712   template <class T1, class T2>                                         \
00713   void CLASS<T1,T2>::bbLockDescriptor()                                 \
00714   {                                                                     \
00715     bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance();      \
00716   }
00717 //============================================================================
00718 
00719 
00720 /*
00721 //============================================================================
00723 #define BBTK_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
00724   template <TYPE1 T1, TYPE2 T2>                                         \
00725   CLASS<T1,T2>::CLASS(const std::string& name, bool alloc)              \
00726     : PARENT(name,false)                                                \
00727   {                                                                     \
00728     BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc);                      \
00729     this->bbUserConstructor();                                          \
00730     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
00731   }                                                                     \
00732   template <TYPE1 T1, TYPE2 T2>                                         \
00733   CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from,                               \
00734                       const std::string& name, bool allocate_connectors) \
00735     : PARENT(from,name,false)                                           \
00736   {                                                                     \
00737     BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
00738     this->bbUserCopyConstructor();                                      \
00739     BBTK_END_BLACK_BOX_CONSTRUCTOR;                                     \
00740   }                                                                     \
00741   template <TYPE1 T1, TYPE2 T2>                                         \
00742   CLASS<T1,T2>::~CLASS()                                                \
00743   {                                                                     \
00744     BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS);                             \
00745     this->bbUserDestructor();                                           \
00746     BBTK_END_BLACK_BOX_DESTRUCTOR;                                      \
00747   }                                                                     \
00748   template <class T1, class T2>                                         \
00749   void CLASS<T1,T2>::bbLockDescriptor()                                 \
00750   {                                                                     \
00751     bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance();      \
00752   }
00753 //============================================================================
00754 
00755 */
00756 
00757 
00758 
00759 
00760 
00761 
00762 
00763 //===========================================================================
00765 //===========================================================================
00766 #endif

Generated on Wed Nov 12 11:37:08 2008 for BBTK by  doxygen 1.5.6