]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdMagicBox.h
Renamed UserBlackBox into AtomicBlackBox which is a better name (versus ComplexBlackB...
[bbtk.git] / packages / std / src / bbstdMagicBox.h
index 3b084b35cfb6ee4794222ba7bc1a1a884b33e5a2..951f92eaa6214d189c5e44d9f1ac955e4ced863f 100644 (file)
@@ -1,16 +1,16 @@
 #ifndef __bbstdMagicBox_h_INCLUDED_H__
 #define __bbstdMagicBox_h_INCLUDED_H__
 
-#include "bbtkUserBlackBox.h"
+#include "bbtkAtomicBlackBox.h"
 
 namespace bbstd
 {
   //==================================================================
   class MagicBox
     : 
-    public bbtk::UserBlackBox
+    public bbtk::AtomicBlackBox
   {
-    BBTK_USER_BLACK_BOX_INTERFACE(MagicBox,bbtk::UserBlackBox);
+    BBTK_USER_BLACK_BOX_INTERFACE(MagicBox,bbtk::AtomicBlackBox);
        BBTK_DECLARE_INPUT(In,bbtk::Data);
        BBTK_DECLARE_OUTPUT(Out,bbtk::Data);
     BBTK_PROCESS(DoProcess);
@@ -29,9 +29,9 @@ namespace bbstd
   // 1) an any cannot store an any (construction with an any invokes the copy constr.)
   // 2) we cannot invoke the Set method with the content of the any because 
   //   it expects an any 
-  // hence the method Set **MUST NOT** extract the content of the Data 
-  // prior to invoking the set method
-  class MagicBoxSetFunctor : public bbtk::UserBlackBoxSetFunctor
+  // hence the Set method of the functor **MUST NOT** extract the 
+  // content of the Data prior to invoking the set method of the box
+  class MagicBoxSetFunctor : public bbtk::AtomicBlackBoxSetFunctor
   {
   public:
     /// Type of pointer on a UBB::Set method  
@@ -43,7 +43,7 @@ namespace bbstd
     {}
     
     /// Concrete application of the Set method of object o
-    void Set(bbtk::UserBlackBox* o, const bbtk::Data& d)
+    void Set(bbtk::AtomicBlackBox* o, const bbtk::Data& d)
     { 
       bbtkDebugMessage("Data",9,"MagicBoxSetfunctor::Set()"<<std::endl);
       (((MagicBox*)o)->*mSetMethodPointer)(d);
@@ -54,7 +54,7 @@ namespace bbstd
     std::string GetTypeName() const { return bbtk::TypeName<bbtk::Data>(); }
     std::string GetHumanTypeName() const { return bbtk::HumanTypeName<bbtk::Data>(); }
     bool IsPointerType() const { return false; }
-    void BruteForceSetPointer(bbtk::UserBlackBox*, void*) {}
+    void BruteForceSetPointer(bbtk::AtomicBlackBox*, void*) {}
   private:
     ///  Pointer on the Set method  
     SetMethodPointerType mSetMethodPointer;
@@ -62,26 +62,29 @@ namespace bbstd
   //===========================================================================
 
 
-  BBTK_BEGIN_DESCRIBE_BLACK_BOX(MagicBox,bbtk::UserBlackBox);
+  //===========================================================================
+  BBTK_BEGIN_DESCRIBE_BLACK_BOX(MagicBox,bbtk::AtomicBlackBox);
   BBTK_NAME("MagicBox");
   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
   BBTK_CATEGORY("adaptor");
-  BBTK_DESCRIPTION("MagicBox");
+  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::UserBlackBoxInputDescriptor
+  (new bbtk::AtomicBlackBoxInputDescriptor
    (typeid(MagicBoxDescriptor),
     "In","Input data",
-    new bbtk::UserBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data>
+    new bbtk::AtomicBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data>
     (&MagicBox::bbGetInputIn),
     new MagicBoxSetFunctor (&MagicBox::bbSetInputIn) ) );
   AddOutputDescriptor
-  (new bbtk::UserBlackBoxOutputDescriptor
+  (new bbtk::AtomicBlackBoxOutputDescriptor
    (typeid(MagicBoxDescriptor),
     "Out","Output data",
-    new bbtk::UserBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data>
+    new bbtk::AtomicBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data>
     (&MagicBox::bbGetOutputOut),
     new MagicBoxSetFunctor (&MagicBox::bbSetOutputOut) ) );
   BBTK_END_DESCRIBE_BLACK_BOX(MagicBox);
+  //===========================================================================
+
 }
 // namespace bbstd