]> Creatis software - bbtk.git/blob - packages/std/src/bbstdCast.h
=== MAJOR RELEASE ====
[bbtk.git] / packages / std / src / bbstdCast.h
1 #ifndef __bbstdCast_h_INCLUDED__
2 #define __bbstdCast_h_INCLUDED__
3
4 #include "bbtkAtomicBlackBox.h"
5
6 namespace bbstd 
7 {
8   
9   //=================================================================
10   // UserBlackBox declaration
11   template <class T, class U>
12   class Cast : public bbtk::AtomicBlackBox
13   {  
14     BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(Cast,bbtk::AtomicBlackBox,T,U);
15     BBTK_DECLARE_INPUT(In,T);
16     BBTK_DECLARE_OUTPUT(Out,U);
17     BBTK_PROCESS(DoIt);
18     void DoIt() {  
19       bbtkDebugMessage("Data",5,"bbstd::Cast In  = "
20                        <<bbGetInputIn()<<" <"<<bbtk::HumanTypeName<T>()
21                        <<">"<<std::endl);
22       bbSetOutputOut( static_cast<U>(bbGetInputIn()) );
23       bbtkDebugMessage("Data",5,"bbstd::Cast Out = "
24                        <<(U)bbGetInputIn()<<" <"<<bbtk::HumanTypeName<U>()
25                        <<">"<<std::endl);
26     }
27   };
28   //=================================================================
29   
30   
31   
32   
33   //=================================================================
34   // UserBlackBox description
35   BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(Cast,bbtk::AtomicBlackBox);
36   BBTK_NAME("Cast"+bbtk::HumanTypeName<T1>()+"To"+bbtk::HumanTypeName<T2>());
37   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
38   BBTK_DESCRIPTION("Static cast from "+bbtk::HumanTypeName<T1>()+" ("
39                    +bbtk::TypeName<T1>()+") to "+bbtk::HumanTypeName<T2>()
40                    +" ("+bbtk::TypeName<T2>()+")");
41   BBTK_DEFAULT_ADAPTOR();
42   BBTK_TEMPLATE2_INPUT(Cast,In,"Input",T1);
43   BBTK_TEMPLATE2_OUTPUT(Cast,Out,"Output",T2);
44   BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(Cast);
45   //=================================================================
46
47
48 } // namespace bbstd
49
50 #endif // __bbstdCast_h_INCLUDED__
51