]> Creatis software - bbtk.git/blob - packages/std/src/bbstdGetVectorElement.h
Acces to the i-th element of a vector
[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_OUTPUT(GetVectorElement, Out,"Output",T);
33   BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(GetVectorElement);
34   //=================================================================
35
36   //=================================================================
37   template <class T>
38   void GetVectorElement<T>::DoIt()
39   {
40    // std::string out;
41    // std::ostringstream oss;
42     int i = bbGetInputI();
43     //oss << bbGetInputIn()[i];
44     //bbSetOutputOut(out.str());
45     bbSetOutputOut(bbGetInputIn()[i]);
46   }
47   //=================================================================
48
49   //=================================================================  
50   template <class T>
51   void GetVectorElement<T>::bbUserConstructor()
52   {
53
54   }
55   //=================================================================
56
57 } // namespace bbstd
58
59 #endif //__bbstdGetVectorElement_INCLUDED_h__
60