]> Creatis software - bbtk.git/blob - packages/std/src/bbstdGetVectorElement.h
8599acb173966faae9c9cebb07d935beab24593a
[bbtk.git] / packages / std / src / bbstdGetVectorElement.h
1 #ifndef __bbstdGetVectorElement_INCLUDED_h__
2 #define __bbstdGetVectorElement_INCLUDED_h__
3
4 #include "bbtkAtomicBlackBox.h"
5
6 namespace bbstd
7 {
8   //=================================================================
9   // BlackBox declaration
10   template <class T>
11   class GetVectorElement : public bbtk::AtomicBlackBox
12   {  
13     BBTK_TEMPLATE_BLACK_BOX_INTERFACE(GetVectorElement,bbtk::AtomicBlackBox,T);
14     BBTK_DECLARE_INPUT(In,std::vector<T>);
15     BBTK_DECLARE_INPUT(I,int);    
16     BBTK_DECLARE_OUTPUT(Out,T);
17     BBTK_PROCESS(DoIt);
18     void DoIt(); 
19     virtual void bbUserConstructor();
20   };
21   //=================================================================
22
23   //=================================================================
24   // BlackBox description
25   BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(GetVectorElement,bbtk::AtomicBlackBox);
26   BBTK_NAME("Get"+bbtk::HumanTypeName<std::vector<T> >()+"Element");
27   BBTK_AUTHOR("jpr@creatis.insa-lyon.fr");
28  // BBTK_DEFAULT_ADAPTOR();
29   BBTK_DESCRIPTION("Gets the i-th element from the input vector ("+bbtk::TypeName<std::vector<T> >());
30   typedef std::vector<T> Tvector;
31   BBTK_TEMPLATE_INPUT(GetVectorElement, In,"Input",Tvector);
32   BBTK_TEMPLATE_INPUT(GetVectorElement, I, "Input",int);  
33   BBTK_TEMPLATE_OUTPUT(GetVectorElement,Out,"Output",T);
34   BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(GetVectorElement);
35   //=================================================================
36
37   //=================================================================
38   template <class T>
39   void GetVectorElement<T>::DoIt()
40   {
41    // std::string out;
42    // std::ostringstream oss;
43     int i = bbGetInputI();
44     //oss << bbGetInputIn()[i];
45     //bbSetOutputOut(out.str());
46     bbSetOutputOut(bbGetInputIn()[i]);
47   }
48   //=================================================================
49
50   //=================================================================  
51   template <class T>
52   void GetVectorElement<T>::bbUserConstructor()
53   {
54
55   }
56   //=================================================================
57
58 } // namespace bbstd
59
60 #endif //__bbstdGetVectorElement_INCLUDED_h__
61