Program: bbtk
Module: $RCSfile: bbvtkGetVectorElement.h,v $
Language: C++
- Date: $Date: 2010/04/01 15:46:54 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2011/07/02 08:00:36 $
+ Version: $Revision: 1.2 $
=========================================================================*/
/* ---------------------------------------------------------------------
{
BBTK_TEMPLATE_BLACK_BOX_INTERFACE(GetVectorElement,bbtk::AtomicBlackBox,T);
BBTK_DECLARE_INPUT(In,std::vector<T>);
- BBTK_DECLARE_INPUT(I,int);
+ BBTK_DECLARE_INPUT(I,int);
+ BBTK_DECLARE_INPUT(ErrorValue,T);
BBTK_DECLARE_OUTPUT(Out,T);
BBTK_PROCESS(DoIt);
void DoIt();
BBTK_DESCRIPTION("Gets the i-th element from the input vector ("+bbtk::TypeName<std::vector<T> >());
typedef std::vector<T> Tvector;
BBTK_TEMPLATE_INPUT(GetVectorElement, In,"Input",Tvector);
- BBTK_TEMPLATE_INPUT(GetVectorElement, I, "Input",int);
+ BBTK_TEMPLATE_INPUT(GetVectorElement, I, "Input",int);
+ BBTK_TEMPLATE_INPUT(GetVectorElement, ErrorValue, "ErrorValue",T);
BBTK_TEMPLATE_OUTPUT(GetVectorElement,Out,"Output",T);
BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(GetVectorElement);
//=================================================================
template <class T>
void GetVectorElement<T>::DoIt()
{
- // unsigned int i = bbGetInputI();
- bbSetOutputOut(bbGetInputIn()[bbGetInputI()]);
+ if (( bbGetInputI() < bbGetInputIn().size() ) && ( bbGetInputI() >= 0 ) )
+ {
+ bbSetOutputOut( bbGetInputIn()[bbGetInputI()] );
+ } else
+ {
+ bbSetOutputOut( bbGetInputErrorValue() );
+ }
}
//=================================================================