1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180 |
- #pragma once
- #include <vector>
- #include <string>
- #include <map>
- #include "TmplBlockBuffer.tlh"
- #define DATAELEMENTDLL_CLASS_DECL
- 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**)
|