#pragma once #include #include #include #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 ********************************************************************************
	Copyright (c) E-COM 2009-2017.
	All rights reserved.

	CLASS NAME:  CAuto_NomalMemPtr
	DESCRIPTION: 内存智能模板指针。
	NOTES:

	AUTHOR:     
	VERSION:
	HISTORY:     2016-6-27   First version

	
*******************************************************************************/ template 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 ********************************************************************************
		FUNCTION NAME:  reset
		DESCRIPTION:    更换内存数据,并将原有内存数据.
		PARAM:
		[in]ptr :需要更换的新内存数据
		RETURN:         void
		HISTORY:        2016-6-27   First version
		
*******************************************************************************/ virtual void reset(T* ptr = NULL)throw() { if (m_pAutoPointer != ptr) { if (m_pAutoPointer != NULL) delete[] m_pAutoPointer; m_pAutoPointer = ptr; } } /*! @function ********************************************************************************
		FUNCTION NAME:  operator[]
		DESCRIPTION:    []操作符重载.
		PARAM:
		[in]nIndex :内存数据单元索引
		RETURN:         void
		HISTORY:        2016-6-27   First version
		
*******************************************************************************/ T& operator[](const int &nIndex) const throw() { return m_pAutoPointer[nIndex]; } /*! @function ********************************************************************************
		FUNCTION NAME:  operator->
		DESCRIPTION:    ->操作符重载.
		PARAM:
		无
		RETURN:         T*
		HISTORY:        2016-6-27   First version
		
*******************************************************************************/ T* operator->()const throw() { return m_pAutoPointer; } /*! @function ********************************************************************************
		FUNCTION NAME:  IsEmpty
		DESCRIPTION:    判断智能指针是否为空.
		PARAM:
		无
		RETURN:         bool
		HISTORY:        2016-6-27   First version
		
*******************************************************************************/ bool IsEmpty() { return (m_pAutoPointer == NULL); } /*! @function ********************************************************************************
		FUNCTION NAME:  get
		DESCRIPTION:    获取智能指针地址.
		PARAM:
		无
		RETURN:         T*
		HISTORY:        2016-6-27   First version
		
*******************************************************************************/ T* get()const throw() { return m_pAutoPointer; } /*! @function ********************************************************************************
		FUNCTION NAME:  release
		DESCRIPTION:    释放智能指针对数据地址的控制权.
		PARAM:
		无
		RETURN:         T*
		HISTORY:        2016-6-27   First version
		
*******************************************************************************/ T* release()throw() { T* tmp(m_pAutoPointer); m_pAutoPointer = NULL; return tmp; } private: T* m_pAutoPointer; }; template class CAuto_NormalClassPtr { public: //constructor & destructor----------------------------------- explicit CAuto_NormalClassPtr(T*ptr = 0)throw() :m_pAutoPointer(ptr) { } ~CAuto_NormalClassPtr()throw() { SAFE_DELETE(m_pAutoPointer); } /*! @function ********************************************************************************
		FUNCTION NAME:  operator*
		DESCRIPTION:    *操作符重载.
		PARAM:
		无
		RETURN:         T&
		HISTORY:        2016-6-2   First version
		
*******************************************************************************/ T& operator*()const throw() { return *m_pAutoPointer; } /*! @function ********************************************************************************
		FUNCTION NAME:  operator->
		DESCRIPTION:    ->操作符重载.
		PARAM:
		无
		RETURN:         T*
		HISTORY:        2016-6-2   First version
		
*******************************************************************************/ T* operator->()const throw() { return m_pAutoPointer; } /*! @function ********************************************************************************
		FUNCTION NAME:  IsEmpty
		DESCRIPTION:    判断智能指针是否为空.
		PARAM:
		无
		RETURN:         bool
		HISTORY:        2016-6-27   First version
		
*******************************************************************************/ bool IsEmpty() { return (m_pAutoPointer == NULL); } /*! @function ********************************************************************************
		FUNCTION NAME:  reset
		DESCRIPTION:    更换数据对象,并将原有对象释放.
		PARAM:
		[in]ptr :需要更换的新数据对象
		RETURN:         void
		HISTORY:        2016-6-2   First version
		
*******************************************************************************/ virtual void reset(T*ptr = NULL)throw() { if (m_pAutoPointer != ptr) { SAFE_DELETE(m_pAutoPointer); m_pAutoPointer = ptr; } } /*! @function ********************************************************************************
		FUNCTION NAME:  get
		DESCRIPTION:    获取智能指针地址.
		PARAM:
		无
		RETURN:         T*
		HISTORY:        2016-6-27   First version
		
*******************************************************************************/ T* get()const throw() { return m_pAutoPointer; } /*! @function ********************************************************************************
		FUNCTION NAME:  release
		DESCRIPTION:    释放智能指针对数据地址的控制权.
		PARAM:
		无
		RETURN:         T*
		HISTORY:        2016-6-27   First version
		
*******************************************************************************/ 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* 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* 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* m_poDataElementMap; std::map* 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* 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* 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* m_pvecInput; std::vector* m_pvecOutput; std::vector* 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* 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* 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* m_pUserDefPixelInfoMap;//用户定义像素信息 std::map* m_poMgrAttr;//属性信息 }; /*! @class ********************************************************************************
	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

	
*******************************************************************************/ 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 ********************************************************************************
	Copyright (c) E-COM 2009-2017.
	All rights reserved.

	CLASS NAME:  CDataMgr
	DESCRIPTION:  DIOS 数据单元对象管理者。
	NOTES:

	AUTHOR:     王凯
	VERSION:
	HISTORY:     2017-6-1   First version

	
*******************************************************************************/ 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**)