#pragma once #include "CcosFileHandle.h" #include // 添加标准整数类型头文件 class PacketAnalizer { public: PacketAnalizer(void); virtual ~PacketAnalizer(void); static uint32_t GetPacketIdx(ResDataObject* pObj); static PACKET_TYPE GetPacketType(ResDataObject* pObj); static PACKET_CMD GetPacketCmd(ResDataObject* pObj); static std::string GetPacketKey(ResDataObject* pObj); static ResDataObject* GetPacketKeysRes(ResDataObject* pObj); static std::string GetPacketPublisher(ResDataObject* pObj); static bool GetPacketHandleExistance(ResDataObject* pPacket); static bool GetPacketHandle(ResDataObject* pPacket, ResDataObject& Handle); static bool GetPacketHandleBusId(ResDataObject* pPacket, std::string& BusId, bool dev); static bool GetPacketHandleMachineId(ResDataObject* pPacket, std::string& MachineId, bool dev); static bool GetPacketHandleProcId(ResDataObject* pPacket, uint64_t& ProcId, bool dev); static bool GetPacketHandleAddr(ResDataObject* pPacket, uint64_t& Addr, bool dev); static bool GetDestinationMachineId(ResDataObject& packet, std::string& machineId); static bool GetDestinationBusId(ResDataObject& packet, std::string& busId); static bool GetDestinationProcId(ResDataObject& packet, uint64_t& procId); static bool GetPacketHandleCrc(ResDataObject* pPacket, uint64_t& Crc); static bool MakePacketContextExistance(ResDataObject* pPacket); static bool GetPacketRoute(ResDataObject* pPacket, CCOS_PACKET_ROUTE& Route); static bool GetPacketContext(ResDataObject* pPacket, ResDataObject& Context); static bool GetPacketRetCode(ResDataObject* pPacket, RET_STATUS& retcode); static bool GetPacketMsgInfo(ResDataObject* pPacket, std::string& Info); static bool GetPacketTransaction(ResDataObject* pPacket, std::string& transaction); static bool CloneResponse(ResDataObject& Obj, ResDataObject* pReq); static uint32_t MakePacketIdx(); static ACTION_SYNC_MODE GetPacketSyncMode(ResDataObject* pObj); static void MakeRetCode(RET_STATUS retcode, ResDataObject* pObj, const char* pMsg = NULL); static bool MakeResponseByReq(ResDataObject& Response, ResDataObject& Req, RET_STATUS ret, const char* pInfo = NULL); static void MakeNotify(ResDataObject& Obj, PACKET_CMD cmd, ResDataObject& Key, const ResDataObject& Context); static void MakeNotify(ResDataObject& Obj, PACKET_CMD cmd, const char* pKey, const ResDataObject& Context); static void MakeNotify(ResDataObject& Obj, PACKET_CMD cmd, const char* pKey, const char* pContext); static void MakeNotifyP2P(ResDataObject& Obj, PACKET_CMD cmd, ResDataObject* pReq, const char* pKey, const char* pContext); static uint32_t MakeActionRequest(ResDataObject& Obj, CcosDevFileHandle& handle, const char* pActionName, ResDataObject& ReqParams, ACTION_SYNC_MODE mode = ACTION_SYNC); static uint32_t MakeRequest(ResDataObject& Obj, const char* pszReqName, PACKET_CMD cmd, ResDataObject* reqParams); static uint32_t MakeOpenRequest(ResDataObject& Obj, CcosDevFileHandle& handle, const char* pFilePath); static bool MakeOpenResponse(ResDataObject& Req, ResDataObject& Res, ResDataObject& DevResource); static bool MakeCloseNotifyByRes(ResDataObject& Response, ResDataObject& Req); static bool MakeCloseRequestByRes(ResDataObject& Response, ResDataObject& Req); static bool MakeCloseRequest(ResDataObject& Obj, CcosDevFileHandle& handle, PACKET_TYPE Type = PACKET_TYPE_REQ); static bool MakeCloseResponse(ResDataObject& Req, ResDataObject& Res); static bool UpdatePacketRoute(ResDataObject& Obj, CCOS_PACKET_ROUTE Route); static bool UpdateOpenRequest(ResDataObject& Req, ResDataObject& MachineId, ResDataObject& busId, uint64_t ProcId, uint64_t Addr); static bool UpdateNotifyHandle(ResDataObject& Obj, CcosDevFileHandle& handle); static bool UpdateDeviceNotifyResponse(ResDataObject& Req, ResDataObject& MachineId, ResDataObject& busId, uint64_t ProcId, uint64_t Addr); static bool UpdatePacketContext(ResDataObject& packet, ResDataObject& Context); static bool UpdatePacketTransaction(ResDataObject& packet, std::string strTransaction); static bool GetParam(ResDataObject* pReq, unsigned int ParamIdx, ResDataObject& value); static bool AddParam(ResDataObject* pRes, unsigned int ParamIdx, ResDataObject& value); static bool UpdateParam(ResDataObject* pRes, unsigned int ParamIdx, ResDataObject& value); static bool UpdatePacketTopic(ResDataObject* Obj, const char* pszTopic, const char* pszClientID); static bool UpdatePacketKey(ResDataObject* Obj, const char* keystr); static bool UpdateContextTopic(ResDataObject* Obj, const char* pszRespTopic); static bool GetContextTopic(ResDataObject* Obj, ResDataObject& topic); static bool GetPacketTopic(ResDataObject* Obj, ResDataObject& topic); static bool CloneTransaction(ResDataObject* req, ResDataObject* res); static std::string GetActionTopic(const char* szDevicePath, const char* szAction); static bool UpdateHandleId(ResDataObject* Obj, uint64_t id); static bool GetHandleId(ResDataObject* Obj, uint64_t& Id); };