Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef TDT_COMMON_COMMON_INC_TSD_MESSAGE_PARSE_INTERFACE_H
12 : #define TDT_COMMON_COMMON_INC_TSD_MESSAGE_PARSE_INTERFACE_H
13 :
14 : #include "driver/ascend_hal.h"
15 : #include "proto/tsd_message.pb.h"
16 :
17 : namespace tsd {
18 : using ParseFuncType = void (*)(const uint32_t sessionID, const tsd::HDCMessage& msg);
19 : class MessageParseInterface {
20 : public:
21 : /**
22 : * @ingroup MessageParseInterface
23 : * @brief 处理消息
24 : * @param [in]msg:消息数据
25 : * @return 无
26 : */
27 : void ProcessMessage(const uint32_t sessionID, const HDCMessage& msg) const;
28 : /**
29 : * @ingroup hiaiengine
30 : * @brief RegisterMsgProcess注册HDC消息处理函数
31 : * @return 无
32 : */
33 : void RegisterMsgProcess(const HDCMessage::MsgType type, const ParseFuncType func);
34 :
35 : protected:
36 : /**
37 : * @ingroup MessageParseInterface
38 : * @brief MessageParseInterface基类构造函数
39 : */
40 : MessageParseInterface();
41 :
42 1 : virtual ~MessageParseInterface() = default;
43 :
44 : MessageParseInterface(const MessageParseInterface&) = delete;
45 : MessageParseInterface(MessageParseInterface&&) = delete;
46 : MessageParseInterface& operator=(const MessageParseInterface&) = delete;
47 : MessageParseInterface& operator=(MessageParseInterface&) = delete;
48 : MessageParseInterface& operator=(MessageParseInterface&&) = delete;
49 :
50 : private:
51 : std::map<HDCMessage::MsgType, ParseFuncType> parseFuncMap_;
52 : };
53 : } // namespace tsd
54 : #endif // TDT_COMMON_COMMON_INC_TSD_MESSAGE_PARSE_INTERFACE_H
|