123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200 |
- #pragma once
- #include <vector>
- #include <string>
- #include <map>
- #include "TmplBlockBuffer.tlh"
- #ifdef _DATAELEMENT_CLASSINDLL
- #define DATAELEMENTDLL_CLASS_DECL _declspec(dllexport)
- #else
- #define DATAELEMENTDLL_CLASS_DECL _declspec(dllimport)
- #endif
- #ifndef _DATAELEMENT_CLASSINDLL
- #ifdef X64
- #ifdef _DEBUG
- #pragma comment(lib, "DataElementX64D.lib")
- #else
- #pragma comment(lib, "DataElementX64.lib")
- #endif
- #else
- #ifdef _DEBUG
- #pragma comment(lib, "DataElementD.lib")
- #else
- #pragma comment(lib, "DataElement.lib")
- #endif
- #endif
- #endif
- namespace DIOS_Kernel
- {
- #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
- #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
- /*! @class
- ********************************************************************************
- <PRE>
- Copyright (c) E-COM 2009-2017.
- All rights reserved.
- CLASS NAME: CAuto_NomalMemPtr
- DESCRIPTION: 内存智能模板指针。
- NOTES:
- AUTHOR:
- VERSION:
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- template<typename T>
- class CAuto_NomalMemPtr
- {
- public:
- explicit CAuto_NomalMemPtr(T* ptr) throw()
- :m_pAutoPointer(ptr)
- {
- };
- virtual ~CAuto_NomalMemPtr()throw()
- {
- if (m_pAutoPointer != NULL)
- {
- delete[] m_pAutoPointer;
- m_pAutoPointer = NULL;
- }
- };
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: reset
- DESCRIPTION: 更换内存数据,并将原有内存数据.
- PARAM:
- [in]ptr :需要更换的新内存数据
- RETURN: void
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- virtual void reset(T* ptr = NULL)throw()
- {
- if (m_pAutoPointer != ptr)
- {
- if (m_pAutoPointer != NULL)
- delete[] m_pAutoPointer;
- m_pAutoPointer = ptr;
- }
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: operator[]
- DESCRIPTION: []操作符重载.
- PARAM:
- [in]nIndex :内存数据单元索引
- RETURN: void
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- T& operator[](const int &nIndex) const throw()
- {
- return m_pAutoPointer[nIndex];
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: operator->
- DESCRIPTION: ->操作符重载.
- PARAM:
- 无
- RETURN: T*
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- T* operator->()const throw()
- {
- return m_pAutoPointer;
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: IsEmpty
- DESCRIPTION: 判断智能指针是否为空.
- PARAM:
- 无
- RETURN: bool
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- bool IsEmpty()
- {
- return (m_pAutoPointer == NULL);
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: get
- DESCRIPTION: 获取智能指针地址.
- PARAM:
- 无
- RETURN: T*
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- T* get()const throw()
- {
- return m_pAutoPointer;
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: release
- DESCRIPTION: 释放智能指针对数据地址的控制权.
- PARAM:
- 无
- RETURN: T*
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- T* release()throw()
- {
- T* tmp(m_pAutoPointer);
- m_pAutoPointer = NULL;
- return tmp;
- }
- private:
- T* m_pAutoPointer;
- };
- template<class T>
- class CAuto_NormalClassPtr
- {
- public:
- //constructor & destructor-----------------------------------
- explicit CAuto_NormalClassPtr(T*ptr = 0)throw()
- :m_pAutoPointer(ptr)
- {
- }
- ~CAuto_NormalClassPtr()throw()
- {
- SAFE_DELETE(m_pAutoPointer);
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: operator*
- DESCRIPTION: *操作符重载.
- PARAM:
- 无
- RETURN: T&
- HISTORY: 2016-6-2 First version
- </PRE>
- *******************************************************************************/
- T& operator*()const throw()
- {
- return *m_pAutoPointer;
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: operator->
- DESCRIPTION: ->操作符重载.
- PARAM:
- 无
- RETURN: T*
- HISTORY: 2016-6-2 First version
- </PRE>
- *******************************************************************************/
- T* operator->()const throw()
- {
- return m_pAutoPointer;
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: IsEmpty
- DESCRIPTION: 判断智能指针是否为空.
- PARAM:
- 无
- RETURN: bool
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- bool IsEmpty()
- {
- return (m_pAutoPointer == NULL);
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: reset
- DESCRIPTION: 更换数据对象,并将原有对象释放.
- PARAM:
- [in]ptr :需要更换的新数据对象
- RETURN: void
- HISTORY: 2016-6-2 First version
- </PRE>
- *******************************************************************************/
- virtual void reset(T*ptr = NULL)throw()
- {
- if (m_pAutoPointer != ptr)
- {
- SAFE_DELETE(m_pAutoPointer);
- m_pAutoPointer = ptr;
- }
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: get
- DESCRIPTION: 获取智能指针地址.
- PARAM:
- 无
- RETURN: T*
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- T* get()const throw()
- {
- return m_pAutoPointer;
- }
- /*! @function
- ********************************************************************************
- <PRE>
- FUNCTION NAME: release
- DESCRIPTION: 释放智能指针对数据地址的控制权.
- PARAM:
- 无
- RETURN: T*
- HISTORY: 2016-6-27 First version
- </PRE>
- *******************************************************************************/
- T* release()throw()
- {
- T* tmp(m_pAutoPointer);
- m_pAutoPointer = NULL;
- return tmp;
- }
- private:
- T * m_pAutoPointer;
- };
- }
- namespace DIOS_Kernel
- {
- #ifndef _ENDIANMOD
- #define _ENDIANMOD
- enum EndianMode
- {
- ENDIAN_LITTLE,
- ENDIAN_BIG,
- ENDIAN_MAX,
- };
- #endif
- class CByteBuffer;
- class DATAELEMENTDLL_CLASS_DECL CBytesBuffer
- {
- public:
- CBytesBuffer();
- CBytesBuffer(size_t res);
- CBytesBuffer(const CBytesBuffer &buf);
- virtual ~CBytesBuffer();
- CBytesBuffer &operator<<(bool value);
- CBytesBuffer &operator<<(unsigned char value);
- CBytesBuffer &operator<<(unsigned short value);
- CBytesBuffer &operator<<(unsigned int value);
- CBytesBuffer &operator<<(unsigned long long value);
- CBytesBuffer &operator<<(char value);
- CBytesBuffer &operator<<(short value);
- CBytesBuffer &operator<<(int value);
- CBytesBuffer &operator<<(long long value);
- CBytesBuffer &operator<<(float value);
- CBytesBuffer &operator<<(double value);
- CBytesBuffer &operator<<(const char* value);
- CBytesBuffer &operator>>(bool &value);
- CBytesBuffer &operator>>(unsigned char &value);
- CBytesBuffer &operator>>(unsigned short &value);
- CBytesBuffer &operator>>(unsigned int &value);
- CBytesBuffer &operator>>(unsigned long long &value);
- void SetEndianMode(EndianMode eMode);
- EndianMode GetSystemEndianMode();
- EndianMode GetCodeEndianMode();
- bool Load(const wchar_t* pwstrFilePathName);
- bool CheckUShortValue(const unsigned short& _usValue);
- bool ReadUShortCheck(const unsigned short& _usValue);
- bool CheckSize(unsigned int nSize);
- bool append(const unsigned char *src, size_t cnt);
- bool append(const unsigned char *pSrcBuffer, unsigned int uBlockSize, unsigned int nCount, bool bCodeEndian);
- unsigned char* append(size_t cnt);
- bool NeedEndian();
- bool CheckString();
- const char* ReadString();
- bool CheckBufferSize();
- const unsigned char* ReadBuffer(unsigned int uBlockSize, bool bCodeEndian, unsigned int& nBufferLen);
- void clear();
- void ClearPos();
- bool resize(size_t newsize);
- void reserve(size_t ressize);
- const unsigned char *contents() const;
- size_t Length() const;
- private:
- CByteBuffer* Get() const;
- CByteBuffer* m_pBuffer;
- char* m_pLocalBuffer;
- unsigned int m_nLocalBufferLen;
- };
- class CDIOSDllOpen;
- }
- namespace DIOS_ParseXML
- {
- struct DATATYPEINFO;
- }
- namespace DIOS_DataPixel
- {
- class CDataSampleMgr;
- class CDataPixelMgr;
- class DATAELEMENTDLL_CLASS_DECL CDataSample
- {
- public:
- bool Init();
- const wchar_t* GetDataSampleName() const;
- unsigned int SizeofDataSample() const;
- bool Compare(const CDataSample& oDataSample) const;
- bool Compare(void* pRangList1, unsigned int nBufferLen1, void* pRangList2, unsigned int nBufferLen2) const;
- bool IsExistRangeCompare() const;
- bool IsUserDefined() const;
- private:
- CDataSample(const DIOS_ParseXML::DATATYPEINFO* stDataTypeInfo);
- virtual ~CDataSample();
- DIOS_ParseXML::DATATYPEINFO* m_pstDataTypeInfo;
- bool m_bInit;
- typedef bool(*RangeCompareFunc)(void* pRangList1, unsigned int nBufferLen1, void* pRangList2, unsigned int nBufferLen2);
- RangeCompareFunc m_pfnRangeCompare;
- DIOS_Kernel::CDIOSDllOpen* m_poDLLFunction;
- const wchar_t* m_pwszRangeFunctionSuffix = L"RangeCompare";
- friend class CDataSampleMgr;
- };
- typedef CDataSample* LPDataSample;
- class CDataPixelInfo;
- class DATAELEMENTDLL_CLASS_DECL CDataPixel
- {
- public:
- unsigned int GetSamplesPerPixel() const;
- bool IsAllSamplesSame() const;
- const CDataSample* GetDataSample(unsigned int uSampleId = 0) const;
- const wchar_t* GetUserDefSampleName(unsigned int uSampleId = 0) const;
- void SetUserDefSampleName(const wchar_t* wszUserDefSampleName, unsigned int uSampleId = 0);
- const void* GetDataSampleMinMaxArrayBuffer(unsigned int& nBufferLen, unsigned int uSampleId = 0) const;
- bool SetDefineValueRange(const void* pDataMinMaxArrayBuffer, unsigned int nBufferLen, unsigned int uSampleId = 0);
- unsigned int GetPixelDataLen() const;
- bool Compare(const CDataPixel& oDataPixel) const;
- const wchar_t* ToString() const;
- private:
- CDataPixelInfo* m_pDataPixel;
- bool m_bInit;
- friend class CDataPixelMgr;
- };
- }
- namespace DIOS_DataElement
- {
- class CWStringMapElement;
- }
- namespace DIOS_DataElementCommon
- {
- #define SAMPLEID_ALLSAMPLES (~(unsigned int)0)
- typedef struct _UserDefSampleInfo
- {
- std::wstring wstrSampleDataTypeName;
- void* pDataMinMaxArrayBuffer;
- unsigned int nBufferLen;
- std::wstring wstrSampleName;
- _UserDefSampleInfo()
- {
- wstrSampleDataTypeName = L"";
- pDataMinMaxArrayBuffer = NULL;
- nBufferLen = 0;
- wstrSampleName = L"";
- }
- }
- UserDefSampleInfo;
- class DATAELEMENTDLL_CLASS_DECL CUserDefPixelInfo
- {
- public:
- CUserDefPixelInfo(unsigned int uSamplesPerPixel, DIOS_DataElement::CWStringMapElement* pDiscriptionMap);
- virtual ~CUserDefPixelInfo();
- bool SetSampleInfo(const wchar_t* pwszSampleDataTypeName, const void* pDataMinMaxArrayBuffer, unsigned int nBufferLen, const wchar_t* pwszSampleName = L"", unsigned int nSampleId = SAMPLEID_ALLSAMPLES);
- bool SetSampleUserDefName(const wchar_t* pwszSampleName, unsigned int nSampleId);
- bool SetSampleMinMaxArrayBuffer(const void* pDataMinMaxArrayBuffer, unsigned int nBufferLen, unsigned int nSampleId = SAMPLEID_ALLSAMPLES);
- unsigned int GetSamplesPerPixel() const { return m_uSamplesPerPixel; };
- const wchar_t* GetSampleName(unsigned int nSampleId) const;
- const wchar_t* GetSampleTypeName(unsigned int nSampleId) const;
- const void* GetSampleMinMaxValueRange(unsigned int nSampleId, unsigned int& nBufferLen) const;
- void SetDiscription(const wchar_t* pwszKey, const wchar_t* pwszValue);
- unsigned int GetDiscriptionCount() const;
- const DIOS_DataElement::CWStringMapElement* GetDiscription() const;
- private:
- std::vector<UserDefSampleInfo>* m_pvecPixelInfo;
- DIOS_DataElement::CWStringMapElement* m_pDiscriptionMap;
- unsigned int m_uSamplesPerPixel;
- bool m_bStandardPixelDef;
- };
- }
- namespace DIOS_Description
- {
- class CDescription;
- class DATAELEMENTDLL_CLASS_DECL CDescriptions
- {
- public:
- CDescriptions();
- virtual ~CDescriptions();
- //编码
- virtual bool Encode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- //解码
- virtual bool Decode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- //
- const wchar_t* GetType() const;
- bool IsDescriptionExist(const wchar_t* pwszKey) const;
- void SetDescription(const wchar_t* pwszKey, const wchar_t* pwszValue);//设置描述信息
- const wchar_t* GetDescription(const wchar_t* pwszKey) const;//获取描述信息
- bool IsAttributeExist(const wchar_t* pwszKey) const;
- void SetAttribute(const wchar_t* pwszKey, void* pValue);//设置设备属性信息
- const void* GetAttribute(const wchar_t* pwszKey) const;//获取设备属性信息
- virtual const wchar_t* ToString() const;
- bool CopyTo(CDescriptions& oDescription);
- protected:
- CDescriptions(const wchar_t* pwszType);
- CDescription* m_pDescription;
- };
- }
- namespace DIOS_Kernel
- {
- class CDIOSThreadLock;
- }
- namespace DIOS_TimeStamp
- {
- class ITimeStamp;
- }
- namespace DIOS_DataElement
- {
- #ifndef _DataElement
- #define _DataElement
- enum DataElementType
- {
- TYPE_DESCRIPTION_ELEMENT = 2,
- TYPE_DATAELEMENT,
- TYPE_WSTRINGVECTOR_ELEMENT,
- TYPE_WSTRINGMAP_ELEMENT,
- TYPE_DATAELEMENTGROUP,
- TYPE_DATAELEMENTMAX,
- };
- enum DataCompareType
- {
- CMPTYPE_DISCRIPTION = 1,
- CMPTYPE_NAME = 2,
- CMPTYPE_DATA = 4,
- };
- #endif
-
- class IDataMgr;
- class DATAELEMENTDLL_CLASS_DECL IDataElement
- {
- public:
- bool SetElementName(const wchar_t* pwszName);
- const wchar_t* GetElementName() const;
- inline DataElementType GetElementType()const { return m_eType; };
- void AddRefCount(); //增加引入计数
- bool DeleteRefCount(); //减少引入计数
- void SetTimeStamp(unsigned long long ullTimeStamp);
- void SetDataValidStatus(bool bSet);
- bool IsDataValid() const;
- virtual void Lock() const;
- virtual void UnLock() const;
- //描述设置
- void SetDescription(const wchar_t* pwszKey, const wchar_t* pwszValue);
- const wchar_t* GetDescription(const wchar_t* pwszKey) const;
- const void* GetAttribute(const wchar_t* pwszKey) const;
- void SetAttribute(const wchar_t* pwszKey, void* pValue);
- virtual const wchar_t* ToString() const;
- bool CopyDescriptionTo(IDataElement* poDataElement);
- virtual bool CompareElement(const IDataElement* poDataElement, DataCompareType eType) const = 0;
- //编码
- virtual bool Encode(DIOS_Kernel::CBytesBuffer& oByteBuffer) = 0;
- //元素单元个数
- virtual unsigned int Size() const = 0;
- virtual bool WriteData(const wchar_t* wszDataJson) { return false; };
- virtual const wchar_t* ReadData() const { return L""; };
- protected:
- IDataElement(DIOS_TimeStamp::ITimeStamp* m_poTimeStamp, DataElementType eType);
- virtual ~IDataElement();
- virtual bool Decode(const DIOS_Description::CDescriptions& oMgrDesp, DIOS_Kernel::CBytesBuffer& oByteBuffer) = 0;
- DIOS_TimeStamp::ITimeStamp* m_poTimeStamp; //时间戳
- DIOS_Description::CDescriptions m_oElementDescription; //数据描述
- DataElementType m_eType; //数据元素类型
- volatile long m_nRefCount; //引入计数
- std::wstring* m_pDiscriptionJson;
- std::wstring* m_pDataJson;
- DIOS_Kernel::CDIOSThreadLock* m_pLocker;
- friend class IDataMgr;
- };
- class DATAELEMENTDLL_CLASS_DECL CDataElement : public IDataElement
- {
- public:
- bool CreateDataBuffer(const unsigned int* puDimensionInfo, unsigned int uDimension);
- bool CreateDataBuffer(BlockBuffer& oBuffer, const unsigned int* puDimensionInfo, unsigned int uDimension);
- const unsigned int* GetDimensionInfo(unsigned int& uDimension) const;
- unsigned int Size() const;
- DIOS_DataPixel::CDataPixel* GetPixelInfo() const;
- virtual void Lock() const;
- virtual void UnLock() const;
- const void* ReadSampleDataBuffer(unsigned int nSampleId, unsigned int& uSampleBufferLen) const;
- void* WriteSampleDataBuffer(unsigned int nSampleId, unsigned int& uSampleBufferLen);
- void* WriteSampleDataBuffer(unsigned int& uSampleBufferLen);
- const void* ReadPixelDataBuffer(unsigned int& uSampleBufferLen) const;
- void* WritePixelDataBuffer(unsigned int& uSampleBufferLen);
- BlockBuffer GetBuffer() const;
- bool CompareElement(const IDataElement* poDataElement, DataCompareType eType) const;
- virtual bool WriteData(const wchar_t* wszDataJson);
- virtual const wchar_t* ToString() const;
- };
- class DATAELEMENTDLL_CLASS_DECL CDescriptionElement : public IDataElement
- {
- public:
- unsigned int GetDimension() const;
- unsigned int Size() const;
- bool CompareElement(const IDataElement* poDataElement, DataCompareType eType = CMPTYPE_DISCRIPTION) const;
- const DIOS_DataPixel::CDataPixel* GetPixelInfo() const;
- virtual const wchar_t* ToString() const;
- };
- class DATAELEMENTDLL_CLASS_DECL CDataElementGroup : public IDataElement
- {
- public:
- bool AddElement(IDataElement* poElement);
- inline const IDataElement* GetConstantElement(unsigned int nIndex) const throw();
- inline IDataElement* GetElement(unsigned int nIndex) const throw();
- void Merge(CDataElementGroup* pNewGroup);
- const IDataElement* GetConstantElement(const wchar_t* pwszNameURL) const throw();
- IDataElement* GetElement(const wchar_t* pwszNameURL) const throw();
- bool RemoveElement(size_t nIndex);
- bool AddElement(IDataElement* poElement, const wchar_t* pwszURL);
- bool UpdateElementByName(IDataElement* poElement);
- bool CompareElement(const IDataElement* poDataElement, DataCompareType eType) const;
- bool RemoveElement(const wchar_t* pwszElementName, const wchar_t* pwszURL = L"");
- bool Encode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- void Clear();
- unsigned int Size() const;
- virtual const wchar_t* ToString() const;
- const wchar_t* GetElementNameOfGroup(unsigned int nIndex) const;
- protected:
- CDataElementGroup(DIOS_TimeStamp::ITimeStamp* poTimeStamp);
- virtual ~CDataElementGroup();
- bool Decode(const DIOS_Description::CDescriptions& oMgrDesp, DIOS_Kernel::CBytesBuffer& oByteBuffer);
- std::vector<IDataElement*>* m_pvecElements;
- typedef struct _DataElementInfo
- {
- IDataElement* pElement;
- unsigned int nIndex;
- _DataElementInfo()
- {
- memset(this, 0, sizeof(_DataElementInfo));
- }
- _DataElementInfo& operator = (const _DataElementInfo& rtDataType)
- {
- memcpy(this, &rtDataType, sizeof(_DataElementInfo));
- return *this;
- }
- }
- DEInfo;
- std::map<std::wstring, DEInfo>* m_poDataElementMap;
- std::map<unsigned int, std::wstring>* m_poFastFindMap;
- friend class IDataMgr;
- };
- class DATAELEMENTDLL_CLASS_DECL CWStringVectorElement : public IDataElement
- {
- public:
- unsigned int Size() const;
- void AddWString(const wchar_t* pwszValue);
- bool CompareElement(const IDataElement* poDataElement, DataCompareType eType) const;
- const wchar_t* GetWString(unsigned int nIndex) const;
- bool Encode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- void Clear();
- protected:
- CWStringVectorElement(DIOS_TimeStamp::ITimeStamp* poTimeStamp);
- virtual ~CWStringVectorElement();
- bool Decode(const DIOS_Description::CDescriptions& oMgrDesp, DIOS_Kernel::CBytesBuffer& oByteBuffer);
- std::vector<std::wstring>* m_pvecData;
- friend class IDataMgr;
- };
- class DATAELEMENTDLL_CLASS_DECL CWStringMapElement : public IDataElement
- {
- public:
- unsigned int Size() const;
- void AddWString(const wchar_t* pwszKey, const wchar_t* pwszValue);
- bool CompareElement(const IDataElement* poDataElement, DataCompareType eType) const;
- const wchar_t* GetWString(const wchar_t* pwszKey) const;
- const CWStringVectorElement* GetKeys() const;
- bool Encode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- virtual const wchar_t* ToString() const;
- protected:
- CWStringMapElement(DIOS_TimeStamp::ITimeStamp* poTimeStamp, CWStringVectorElement* povecKeys);
- virtual ~CWStringMapElement();
- bool Decode(const DIOS_Description::CDescriptions& oMgrDesp, DIOS_Kernel::CBytesBuffer& oByteBuffer);
- std::map<std::wstring, std::wstring>* m_poDataMap;
- CWStringVectorElement* m_povecKeys;
- std::wstring* m_pwstrJson;
- friend class IDataMgr;
- };
- }
- namespace DIOS_PipelineDevice
- {
- typedef bool(*NOTIFY) (void* pParent, int nNotifyType, void* pInData, void* pOutData);
- enum FuncInfoGroupType
- {
- GROUPTYPE_INPUT,
- GROUPTYPE_CACHE,
- GROUPTYPE_OUTPUT,
- };
- enum TYPE_PROCESSMODULE :unsigned char
- {
- PROCESSMODULE_FUNCTION,
- PROCESSMODULE_STATICPIPELINE,
- PROCESSMODULE_MAX,
- };
- enum PLWorkMode
- {
- PLWORKMODE_NONE,
- PLWORKMODE_FORPROCESSING,
- PLWORKMODE_FORPRESENTATION,
- PLWORKMODE_MAX,
- };
- enum CHECKMODE
- {
- CKMODE_CHECKALL_ADD,
- CKMODE_CHECKALL,
- CKMODE_CHECKANY,
- CKMODE_MAX,
- };
- class DATAELEMENTDLL_CLASS_DECL CNodeInfo : public DIOS_Description::CDescriptions
- {
- public:
- CNodeInfo();
- virtual ~CNodeInfo();
- void SetType(TYPE_PROCESSMODULE eType);
- TYPE_PROCESSMODULE GetType() const;
- bool IsValid() const;
- size_t size(FuncInfoGroupType eType) const;
- const wchar_t* GetName(FuncInfoGroupType eType, unsigned int nId) const;
- bool Find(FuncInfoGroupType eType, const DIOS_DataElement::CDataElementGroup& oScrDataGroup, DIOS_DataElement::CDataElementGroup& oDesDataGroup, bool bUseStatus) const;
- bool GetOutputStatus(unsigned int nId) const;
- void AddInputInfo(const wchar_t* pwszName);
- void AddOutputInfo(const wchar_t* pwszName, bool bStatus);
- virtual bool Encode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- virtual bool Decode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- private:
- TYPE_PROCESSMODULE m_eType;
- std::vector<std::wstring>* m_pvecInput;
- std::vector<std::wstring>* m_pvecOutput;
- std::vector<bool>* m_pvecOutputStatus;
- };
- class DATAELEMENTDLL_CLASS_DECL CFunctionInfomation : public DIOS_Description::CDescriptions
- {
- public:
- void AddMemWorkMode(const wchar_t* pwszMemTypeName = L"Memory");
- const DIOS_DataElement::CWStringVectorElement* GetMemWorkMode() const;
- void SetAlgorithm(const wchar_t* pwszAlgorithm);
- void AddDataElement(const DIOS_DataElement::CDescriptionElement* poElement, FuncInfoGroupType eGroupType);
- const DIOS_DataElement::CDataElementGroup* GetDataElement(FuncInfoGroupType eGroupType) const;
- bool Check();
- const CNodeInfo* GetFunctionPinInfo() const;
- virtual bool Encode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- virtual bool Decode(DIOS_Kernel::CBytesBuffer& oByteBuffer) ;
- virtual const wchar_t* ToString() const;
- private:
- CFunctionInfomation(const wchar_t* pwszFunctionName, DIOS_DataElement::CDataElementGroup* m_poInputList,
- DIOS_DataElement::CDataElementGroup* m_poCacheList, DIOS_DataElement::CDataElementGroup* m_poOutputList, DIOS_DataElement::CWStringVectorElement* poMemTypeName);
- virtual ~CFunctionInfomation();
- DIOS_DataElement::CDataElementGroup* m_poInputList;
- DIOS_DataElement::CDataElementGroup* m_poCacheList;
- DIOS_DataElement::CDataElementGroup* m_poOutputList;
- DIOS_DataElement::CWStringVectorElement* m_poMemTypeName;
- CNodeInfo* m_pFuncionPinInfo;
- std::wstring* m_pwstrDescriptionJson;
- friend class CFunctionInfo;
- };
- class DATAELEMENTDLL_CLASS_DECL CPLTreeNode
- {
- public:
- bool Set(CNodeInfo* pNode, unsigned int uTTreeNodeId = CPLTreeNode::uInvalidNodeId, unsigned int uFTreeNodeId = CPLTreeNode::uInvalidNodeId);
- void SetSuccessTreeNodeId(unsigned int uTTreeNodeId = CPLTreeNode::uInvalidNodeId);
- void SetFailureTreeNodeId(unsigned int uFTreeNodeId = CPLTreeNode::uInvalidNodeId);
- bool Encode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- bool Decode(DIOS_Kernel::CBytesBuffer& oByteBuffer, unsigned int nNodeCount);
- bool IsValid(unsigned int uMaxTreeNodeId) const;
- const CNodeInfo* GetNodeInfo() const;
- unsigned int GetSuccessTreeNodeId() const;
- unsigned int GetFailureTreeNodeId() const;
- const static unsigned int uInvalidNodeId = (~(unsigned int)0);
- private:
- CPLTreeNode();
- virtual ~CPLTreeNode();
- CNodeInfo* m_poNode;
- unsigned int m_uTTreeNodeId;
- unsigned int m_uFTreeNodeId;
- friend class CPipelineInformation;
- };
- class DATAELEMENTDLL_CLASS_DECL CPipelineInformation : public DIOS_Description::CDescriptions
- {
- public:
- bool SetPLName(const wchar_t* pwszPLName);
- const wchar_t* GetPLName() const;
- bool LoadPLFile(const wchar_t* pwszPLFilePathName);
- bool SavePLFile(const wchar_t* pwszPLFilePathName, DIOS_Kernel::EndianMode eMode = DIOS_Kernel::EndianMode::ENDIAN_LITTLE);
- TYPE_PROCESSMODULE GetType() const;
- const DIOS_DataElement::CWStringVectorElement* GetMemWorkMode() const;
- bool Check(const DIOS_DataElement::CDataElementGroup& oInputList, CHECKMODE eMode);
- bool GetDataElement(FuncInfoGroupType eType, const DIOS_DataElement::CDataElementGroup& oScrDataGroup, DIOS_DataElement::CDataElementGroup& oDesDataGroup);
- bool AddFirstElementInfo(CNodeInfo* poElement, unsigned int& uCurrId);
- bool AddNextElementInfo(unsigned int uPreId, bool bPreIdRes, CNodeInfo* poElement, unsigned int& uCurrId);
- bool AddNextElementInfo(unsigned int uPreId, bool bPreIdRes, unsigned int uCurrId);
- void SetPipelineInfo(CNodeInfo* oPipeLineInfo);
- bool AddMemMode(const wchar_t* pwszMode);
- unsigned int Size() const;
- virtual bool Encode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- virtual bool Decode(DIOS_Kernel::CBytesBuffer& oByteBuffer);
- const CPLTreeNode* Get(unsigned int nIndex) const;
- static void ReleasePLTreeNode(void* pCaller, CPLTreeNode* ppPLTreeNode);
- virtual const wchar_t* ToString() const;
- private:
- CPipelineInformation(DIOS_DataElement::CWStringVectorElement* poMemTypeName);
- virtual ~CPipelineInformation();
- void Clear();
- CNodeInfo* m_poPipeLineInfo;
- std::vector<CPLTreeNode*>* m_pvecPLTree;
- bool m_bPLInfoOK;
- DIOS_DataElement::CWStringVectorElement* m_poMemTypeName;
- DIOS_Kernel::CBytesBuffer m_oPLInfo;
- friend class DIOS_DataElement::IDataMgr;
- };
- class DATAELEMENTDLL_CLASS_DECL CFunctionInfo
- {
- public:
- CFunctionInfomation* CreateFunctionInfomation(const wchar_t* pwszFunctionName);
- CFunctionInfomation* GetFunctionInfomation(unsigned int nIndex) const;
- const CFunctionInfomation* GetFunctionInfomation(const wchar_t* pwszFunctionName) const;
- unsigned int Size() const;
- private:
- CFunctionInfo(DIOS_DataElement::IDataMgr* poDataMgr);
- virtual ~CFunctionInfo();
- static void ReleaseInformation(void* pCaller, DIOS_Description::CDescriptions* pElement);
- static CFunctionInfomation* CreateFunctionInfomation(DIOS_DataElement::IDataMgr* poDataMgr, const wchar_t* pwszFunctionName);
- DIOS_DataElement::IDataMgr* m_poDataMgr;
- std::vector<CFunctionInfomation*>* m_pvecFunctionInfomations;
- friend class DIOS_DataElement::IDataMgr;
- };
- }
- namespace DIOS_DataElement
- {
- #ifndef _DataMgr
- #define _DataMgr
- enum DataMgrType
- {
- MGRTYPE_DATAMGR,
- MGRTYPE_USERDATAMGR,
- };
- #endif
- class IMemDevicesMgr;
- class CDataDimension;
- class CDataDimensionMgr;
- class DATAELEMENTDLL_CLASS_DECL IDataMgr
- {
- public:
- //获取数据管理者类型
- inline DataMgrType GetDataMgrType() const{ return m_eMgrType; };
- //用户定义pixel
- //获取当前用户定义的像素信息
- DIOS_DataElementCommon::CUserDefPixelInfo* GetUserDefPixelInfo(const wchar_t* wstrDefPixelInfo, const wchar_t* wstrName);
- //获取像素通道信息
- const DIOS_DataPixel::LPDataSample* GetSampleList(unsigned int& uSamplesCount);
- //创建组数据单元
- CDataElementGroup* CreateGroupElement(const wchar_t* pwszName = L"");
- CWStringVectorElement* CreateWStringVectorElement(const wchar_t* pwszName = L"");
- CWStringMapElement* CreateWStringMapElement(const wchar_t* pwszName = L"");
- CDescriptionElement* CreateDescriptionElement(const wchar_t* wstrDefPixelInfo, unsigned int uDimension,
- const wchar_t* pwszMemTypeName = L"AnyMemory", const wchar_t* pwszSubMemTypeName = L"Normal");
- //创建和释放算法信息对象
- DIOS_PipelineDevice::CFunctionInfo* CreateFunctionInfo();
- static void ReleaseFunctionInfo(DIOS_PipelineDevice::CFunctionInfo* ppElement);
- static void CallbackReleaseFunctionInfo(void* pCaller, DIOS_PipelineDevice::CFunctionInfo* ppElement);
- //初始化设备
- bool InitDevices();
- bool SupportBufferAllocated(const wchar_t* pwszMemTypeName);
- bool IsSupportMemDevice(const CWStringVectorElement* poDevInfo);
- void GetDeviceTypeNames(CWStringVectorElement& oDevInfo);
- //释放数据单元
- static void ReleaseElement(IDataElement* ppElement);
- static void ReleaseDiscription(void* pCaller, DIOS_Description::CDescriptions* pElement);
- //回调释放
- static void CallbackReleaseElement(void* pCaller, IDataElement* ppElement);
- IDataElement* CreateElement(DIOS_Kernel::CBytesBuffer& oCodeBuffer);
- DIOS_PipelineDevice::CPipelineInformation* CreatePipelineInfo();
- IDataElement* CloneElement(IDataElement* pElement);
- static bool SaveElement(IDataElement* pElement, DIOS_Kernel::CBytesBuffer& oCodeBuffer);
- IDataElement* LoadElement(DIOS_Kernel::CBytesBuffer& oCodeBuffer);
- static bool SaveDiscription(DIOS_Description::CDescriptions* pElement, DIOS_Kernel::CBytesBuffer& oCodeBuffer);
- DIOS_Description::CDescriptions* LoadDiscription(DIOS_Kernel::CBytesBuffer& oCodeBuffer);
- protected:
- //创建数据单元
- CDataElement* CreateElement(const DIOS_DataPixel::CDataPixel* poDataPixel, unsigned int uDimension,
- const wchar_t* pwszName = L"", const wchar_t* pwszMemTypeName = L"Memory",
- unsigned int uMemDeviceId = 0, const wchar_t* pwszSubMemTypeName = L"Normal");
- CDataElement* CreateElement(const wchar_t* wstrPixelDesp, unsigned int uDimension,
- const wchar_t* pwszName = L"", const wchar_t* pwszMemTypeName = L"Memory",
- unsigned int uMemDeviceId = 0, const wchar_t* pwszSubMemTypeName = L"Normal");
- CDataElement* CreateElement(const wchar_t* pwszPixelDataJson, const wchar_t* wstrDefPixelInfo,
- const wchar_t* pwszName = L"", const wchar_t* pwszMemTypeName = L"Memory",
- unsigned int uMemDeviceId = 0, const wchar_t* pwszSubMemTypeName = L"Normal");
- IDataMgr(DataMgrType eType);
- virtual ~IDataMgr();
- //初始化
- bool DataMgrInit(const IDataMgr* oDataMgr = NULL);
- DIOS_DataPixel::CDataSampleMgr* m_poDataSampleMgr;//通道管理
- DIOS_DataPixel::CDataPixelMgr* m_poDataPixelMgr;//像素管理
- CDataDimensionMgr* m_poDataDimensionMgr;//维数管理
- IMemDevicesMgr* m_poMemDeviceMgr;//内存设备管理
- DataMgrType m_eMgrType;//管理者类型
- bool m_bInit;//初始化状态
- bool m_bDeviceInit;//设备初始化状态
- std::map<std::wstring, DIOS_DataElementCommon::CUserDefPixelInfo*>* m_pUserDefPixelInfoMap;//用户定义像素信息
- std::map<std::wstring, std::wstring>* m_poMgrAttr;//属性信息
- };
- /*! @class
- ********************************************************************************
- <PRE>
- Copyright (c) E-COM 2009-2017.
- All rights reserved.
- CLASS NAME: CUserDataMgr
- DESCRIPTION: DIOS 数据单元对象管理者,用于Pipeline和算法单元。
- NOTES:
- AUTHOR: 王凯
- VERSION:
- HISTORY: 2017-6-1 First version
- 2017-6-20 support Pipeline and Algorithm
- </PRE>
- *******************************************************************************/
- class DATAELEMENTDLL_CLASS_DECL CUserDataMgr : public IDataMgr
- {
- public:
- const void* GetMemDeviceAttr(const wchar_t* pwszMemTypeName, const wchar_t* pwszDeviceKey);
- bool SetMemDeviceAttr(const wchar_t* pwszMemTypeName, const wchar_t* pwszDeviceKey, void* pDeviceAttr);
- CDataElement* CreateDataElement(const wchar_t* wstrPixelDesp, unsigned int uDimension,
- const wchar_t* pwszName = L"", const wchar_t* pwszMemTypeName = L"Memory",
- const wchar_t* pwszSubMemTypeName = L"Normal");
- CDataElement* CreateDataElement(const CDescriptionElement* poDataGroup, bool bUpdateName = false, const wchar_t* pwszName = L"");
- bool AddDataElementsForGroup(const CDataElementGroup* poGroupDescription, CDataElementGroup* poDataGroup);
- };
- /*! @class
- ********************************************************************************
- <PRE>
- Copyright (c) E-COM 2009-2017.
- All rights reserved.
- CLASS NAME: CDataMgr
- DESCRIPTION: DIOS 数据单元对象管理者。
- NOTES:
- AUTHOR: 王凯
- VERSION:
- HISTORY: 2017-6-1 First version
- </PRE>
- *******************************************************************************/
- class DATAELEMENTDLL_CLASS_DECL CDataMgr : public IDataMgr
- {
- public:
- CDataMgr();
- virtual ~CDataMgr();
- bool Init(const wchar_t* pwszDataTypeCfgPath = L"", const wchar_t* pwszLogDir = L"");
- CDataElement* CreateDataElement(const wchar_t* wstrPixelDesp,
- unsigned int uDimension,
- const wchar_t* pwszName = L"",
- const wchar_t* pwszMemTypeName = L"Memory",
- unsigned int uMemDeviceId = 0,
- const wchar_t* pwszSubMemTypeName = L"Normal"
- );
- CDataElement* CreateDataElement(const DIOS_DataPixel::CDataPixel* poDataPixel,
- unsigned int uDimension,
- const wchar_t* pwszName = L"",
- const wchar_t* pwszMemTypeName = L"Memory",
- unsigned int uMemDeviceId = 0,
- const wchar_t* pwszSubMemTypeName = L"Normal");
- CDataElement* CreateDataElement(
- const wchar_t* pwszPixelDataJson,
- const wchar_t* wstrDefPixelInfo,
- const wchar_t* pwszName = L"",
- const wchar_t* pwszMemTypeName = L"Memory",
- unsigned int uMemDeviceId = 0,
- const wchar_t* pwszSubMemTypeName = L"Normal");
- CUserDataMgr* CreateUserDataMgr(const IDataElement* poInfo);
- static void ReleaseUserDataMgr(void* pCaller, CUserDataMgr* ppUserDataMgr);
- };
- }
- #define LPPIDataElement (DIOS_DataElement::IDataElement**)
|