#ifndef __RV_READING_H_INCLUDED_
#define __RV_READING_H_INCLUDED_

 

#define RDG_API  WINAPI

 
#include <rvb\rvtypes.h> 
 

#define RD_MAX_TAG_LEN   32
#define RD_MAX_TEXT_LEN  1023

#define RvReadingBank  HANDLE
 

typedef enum _rv_reading_type{  
	RRT_UNKNOWN=-1,
	RRT_INT,
	RRT_LARGE,     //int64
    RRT_DECIMAL,
    RRT_STRING, 
	RRT_RGB,
	RRT_SIZE,       // 单精度浮点数
    RRT_POINT,      // 单精度浮点数
	RRT_LINE,       // 单精度浮点数
	RRT_RECT,       // 单精度浮点数
	RRT_ELLIPSE,    // 单精度浮点数
	RRT_BOOL,       //add by hdy for 4.1 on 2018/08/22
	RRT_BYTE,       //add by hdy on 20191229, 
	RRT_OFFSET,     // 单精度浮点数 add by hdy on 20191229
}RV_READING_TYPE;
  
typedef void  (WINAPI * RDG_RECYCLER)(void*);   

extern "C" RvReadingBank  RDG_API    rvCreateReadingBank();
extern "C" void           RDG_API    rvDestroyReadingBank(RvReadingBank  bank);

//释放原来的元素的内存空间
extern "C" void RDG_API rrdReset(RvReadingBank bank);
//不释放原来的元素的内存空间
extern "C" void RDG_API rrdEmpty(RvReadingBank bank);

 


//获得读数数量
extern "C" int  RDG_API rrdGetCount(RvReadingBank bank);

//获得读数数组素数组元素大小，
extern "C" int  RDG_API rrdGetElemCount(RvReadingBank bank, int index);

extern "C" void RDG_API rrdResetElem(RvReadingBank bank, int index);

//支持读数的值为数组，
//index为读数索引，pos为读数数组的值的索引
extern "C" BOOL RDG_API rrdSetElemValue(RvReadingBank bank, int index, int pos, void* pDataPrt, int nDataSize );
extern "C" BOOL RDG_API rrdGetElemValue(RvReadingBank bank, int index, int pos, void* pDataPrt, int nDataSize);

 
extern "C" RvReadingBank RDG_API rrdDuplicate(RvReadingBank src, RvReadingBank dest = NULL);


//rrdAccord不会复制TAG和attachment,两个bank里面的reading需要完全一致（包括数据类型）
//dest 不能为空
extern "C" void RDG_API rrdAccord(RvReadingBank src, RvReadingBank dest );


extern "C" BOOL RDG_API rrdToString(RvReadingBank bank, int index, TCHAR* pTextBuffer, int bufferSize);

extern "C" RV_READING_TYPE RDG_API rrdGetType(RvReadingBank bank, int index);

//  设置和获取标签
extern "C" void RDG_API rrdSetTag(RvReadingBank bank, int index, const TCHAR* strTag);
extern "C" const TCHAR* RDG_API rrdGetTag(RvReadingBank bank, int index );

//大小写不敏感
extern "C" int RDG_API rrdFindIndex(RvReadingBank self, const TCHAR* strTag);

//设置和获取附加数据,  用户数据在使用过程中如果需要自动释放，
//请输入负责释放函数指针，否则可能造成内存泄漏。
extern "C" void RDG_API rrdSetAttach(RvReadingBank bank, int index, void* pUserData, RDG_RECYCLER fnRecycler = NULL);
extern "C" void* RDG_API rrdGetAttach(RvReadingBank bank, int index );

 
extern "C" void RDG_API rrdSetByte(RvReadingBank bank, RvByte val, int index);
extern "C" void RDG_API rrdSetInteger(RvReadingBank bank, int val, int index);

extern "C" void RDG_API rrdSetLarge(RvReadingBank bank, RvLarge val, int index);

extern "C" void RDG_API rrdSetString(RvReadingBank bank, const TCHAR* strVal, int index);
extern "C" void RDG_API rrdSetSize(RvReadingBank bank, RvSize_f*   pVal, int index);
extern "C" void RDG_API rrdSetOffset(RvReadingBank bank, RvOffset_f*   pVal, int index);

extern "C" void RDG_API rrdSetDecimal(RvReadingBank bank, RvDouble  val, int index);
extern "C" void RDG_API rrdSetRgb(RvReadingBank bank, RvRgb*  pVal, int index);
extern "C" void RDG_API rrdSetPoint(RvReadingBank bank, RvPoint_f*  pVal, int index);
extern "C" void RDG_API rrdSetLine(RvReadingBank bank, RvLine_f*  pVal, int index);
extern "C" void RDG_API rrdSetRect(RvReadingBank bank, RvRect_f*  pVal, int index);
extern "C" void RDG_API rrdSetEllipse(RvReadingBank bank, RvEllipse_f*  pVal, int index);
//extern "C" void RDG_API rrdSetRecord(RvReadingBank bank, RvReadingBank  val, int index);


//extern "C" void RDG_API rrdSetSizeF32(RvReadingBank bank, RvSize_f*   pVal, int index);
//extern "C" void RDG_API rrdSetPointI32(RvReadingBank bank, RvPoint*   pVal, int index);

//for 4.1
extern "C" void RDG_API rrdSetBool(RvReadingBank bank, bool    val, int index);
//extern "C" void RDG_API rrdSetBoolI32(RvReadingBank bank, BOOL  val, int index);
  
extern "C" BOOL RDG_API rrdGetByte(RvReadingBank bank, RvByte* val, int index);
extern "C" BOOL RDG_API rrdGetInteger(RvReadingBank bank, int* pVal, int index);
extern "C" BOOL RDG_API rrdGetLarge(RvReadingBank bank, RvLarge* pVal, int index);

extern "C" BOOL RDG_API rrdGetString(RvReadingBank bank, TCHAR* strVal, int stringSize, int index);
//rrdGetStringEx仅返回一个字符串地址
extern "C" const TCHAR* RDG_API rrdGetStringEx(RvReadingBank bank,   int index);

extern "C" BOOL RDG_API rrdGetSize(RvReadingBank bank, RvSize_f*   pVal, int index);

extern "C" BOOL RDG_API rrdGetOffset(RvReadingBank bank, RvOffset_f*   pVal, int index);

extern "C" BOOL RDG_API rrdGetDecimal(RvReadingBank bank, RvDouble*  pVal, int index);
extern "C" BOOL RDG_API rrdGetRgb(RvReadingBank bank, RvRgb*  pVal, int index);
extern "C" BOOL RDG_API rrdGetPoint(RvReadingBank bank, RvPoint_f*  pVal, int index);
extern "C" BOOL RDG_API rrdGetLine(RvReadingBank bank, RvLine_f*  pVal, int index);
extern "C" BOOL RDG_API rrdGetRect(RvReadingBank bank, RvRect_f*  pVal, int index);
extern "C" BOOL RDG_API rrdGetEllipse(RvReadingBank bank, RvEllipse_f*  pVal, int index);

//扩展函数
//extern "C" BOOL RDG_API rrdGetSizeF32(RvReadingBank bank, RvSize_f*   pVal, int index);
//extern "C" BOOL RDG_API rrdGetPointI32(RvReadingBank bank, RvPoint*  pVal, int index);

//for 4.1
extern "C" BOOL RDG_API rrdGetBool(RvReadingBank bank, bool*   pVal, int index);
//extern "C" BOOL RDG_API rrdGetBoolI32(RvReadingBank bank, int*   pVal, int index);


//extern "C" BOOL RDG_API rrdGetRecord(RvReadingBank bank, RvReadingBank* pVal, int index);

 

//#define  rrdSetBool(bank, val, index)     rrdSetInteger( ( bank),  ( val),  ( index))
//#define  rrdGetBool(bank, pVal, index)    rrdGetInteger( ( bank),  ( pVal),  ( index))









#endif






