]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdMagicBox.h
*** empty log message ***
[bbtk.git] / packages / std / src / bbstdMagicBox.h
index ec5a16966850b9784203a82deb465682adc97edc..4f0bebe06f61353be8b87c4856afb0b3fbc49b72 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbstdMagicBox.h,v $
   Language:  C++
-  Date:      $Date: 2009/05/14 14:43:38 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2009/06/08 14:50:06 $
+  Version:   $Revision: 1.13 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 
 namespace bbstd
 {
-#define BBTK_MB_DECLARE_INPUT(NAME,TYPE)                               \
-  protected:                                                           \
-  TYPE bbmInput##NAME;                                                 \
-public:                                                                        \
-  TYPE bbGetInput##NAME ()                                             \
-  { return bbmInput##NAME; }                                           \
-    void bbSetInput##NAME (TYPE d)                                     \
-    { bbmInput##NAME = d;                                              \
-      if (mCanSet) { bbSetOutputOut(d); mCanSet = false; } }                           
 
   //==================================================================
   class bbstd_EXPORT MagicBox
@@ -53,28 +44,13 @@ public:                                                                     \
     public bbtk::AtomicBlackBox
   {
     BBTK_BLACK_BOX_INTERFACE(MagicBox,bbtk::AtomicBlackBox);
-    BBTK_MB_DECLARE_INPUT(In,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In1,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In2,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In3,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In4,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In5,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In6,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In7,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In8,bbtk::Data);
-    BBTK_MB_DECLARE_INPUT(In9,bbtk::Data);
+    BBTK_DECLARE_INPUT(In,bbtk::Data);
     BBTK_DECLARE_OUTPUT(Out,bbtk::Data);
     BBTK_PROCESS(DoProcess);
     void DoProcess();
-  protected:
-    //    virtual void bbUserConstructor();
-    virtual void bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c,
-                                        bbtk::IOStatus s);
-    bool mCanSet;
  };
   //==================================================================
   
-#undef BBTK_MB_DECLARE_INPUT  
 
   //==================================================================
   // We have to create a particular SetFunctor for MagicBox because
@@ -117,33 +93,14 @@ public:                                                                    \
   };
   //===========================================================================
   
-#define MAGIC_BOX_INPUT(NAME)                                          \
-  AddInputDescriptor                                                   \
-  (new bbtk::AtomicBlackBoxInputDescriptor                             \
-   (typeid(MagicBoxDescriptor),                                                \
-    #NAME,"Input data","",                                             \
-    new bbtk::AtomicBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data>        \
-    (&MagicBox::bbGetInput ## NAME),                                   \
-    new MagicBoxSetFunctor (&MagicBox::bbSetInput ## NAME) ) );                
 
   //===========================================================================
   BBTK_BEGIN_DESCRIBE_BLACK_BOX(MagicBox,bbtk::AtomicBlackBox);
   BBTK_NAME("MagicBox");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_CATEGORY("misc");
-  BBTK_DESCRIPTION("Takes *any kind* of data and copies it to its output. Is a magic box as any box output can be plugged into it and its output can be plugged into any other box input (dynamic type checking, see below), hence it can be put between **any** two boxes. Type matching between its output and the input of the box(es) to which it is connected is made at *run-time*. The pipeline will be executed if the data types : i) match exactly ii) can be transformed by an adaptor iii) are related pointers, i.e. if the output pointer can be upcasted (static_cast) or downcasted (dynamic_cast) to an input type pointer (see the bbtk::any output connection rule in the guide for details). Important uses of the MagicBox are : 1) performing run-time pointer cast, either upward or backward an object hierarchy 2) perform data adaptation (adaptor creation) at run-time vs. pipeline creation time. Any has now 9 more inputs and the value of the output is the value of the lower index input which has changed. This functionality is used to implement a memory which can be written by different boxes. The current value of the memory (the output) is that of the last input which has changed, i.e. has 'written' the memory. It is used for example for synchronization issues between boxes.");
-  MAGIC_BOX_INPUT(In)  
-  MAGIC_BOX_INPUT(In1) 
-  MAGIC_BOX_INPUT(In2) 
-  MAGIC_BOX_INPUT(In3) 
-  MAGIC_BOX_INPUT(In4) 
-  MAGIC_BOX_INPUT(In5) 
-  MAGIC_BOX_INPUT(In6) 
-  MAGIC_BOX_INPUT(In7) 
-  MAGIC_BOX_INPUT(In8) 
-  MAGIC_BOX_INPUT(In9) 
-
- /*
+  BBTK_DESCRIPTION("Takes *any kind* of data and copies it to its output. Is a magic box as any box output can be plugged into it and its output can be plugged into any other box input (dynamic type checking, see below), hence it can be put between **any** two boxes. Type matching between its output and the input of the box(es) to which it is connected is made at *run-time*. The pipeline will be executed if the data types : i) match exactly ii) can be transformed by an adaptor iii) are related pointers, i.e. if the output pointer can be upcasted (static_cast) or downcasted (dynamic_cast) to an input type pointer (see the bbtk::any output connection rule in the guide for details). Important uses of the MagicBox are : 1) performing run-time pointer cast, either upward or backward an object hierarchy 2) perform data adaptation (adaptor creation) at run-time vs. pipeline creation time.");
  AddInputDescriptor
   (new bbtk::AtomicBlackBoxInputDescriptor
    (typeid(MagicBoxDescriptor),
@@ -151,7 +108,7 @@ public:                                                                     \
     new bbtk::AtomicBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data>
     (&MagicBox::bbGetInputIn),
     new MagicBoxSetFunctor (&MagicBox::bbSetInputIn) ) );
- */
+
   AddOutputDescriptor
   (new bbtk::AtomicBlackBoxOutputDescriptor
    (typeid(MagicBoxDescriptor),