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 DGW_STATE_DEFINE_H
12 : #define DGW_STATE_DEFINE_H
13 :
14 : #include <memory>
15 : #include "common/bqs_log.h"
16 :
17 : namespace dgw {
18 : class Entity;
19 : using EntityPtr = std::shared_ptr<Entity>;
20 : class ChannelEntity;
21 : using ChannelEntityPtr = std::shared_ptr<ChannelEntity>;
22 :
23 : enum class FsmStatus : int32_t {
24 : FSM_SUCCESS = 0,
25 : FSM_DEST_FULL,
26 : FSM_KEEP_STATE,
27 : FSM_ERROR_PENDING,
28 : FSM_FAILED,
29 : FSM_CACHED,
30 : FSM_ERROR,
31 : FSM_SRC_EMPTY
32 : };
33 :
34 : enum class InnerMsgType : int32_t {
35 : INNER_MSG_PUSH = 0,
36 : INNER_MSG_F2NF,
37 : INNER_MSG_RECOVER,
38 : INNER_MSG_INVALID
39 : };
40 :
41 : struct InnerMessage {
42 : InnerMsgType msgType = InnerMsgType::INNER_MSG_INVALID;
43 : };
44 :
45 3 : inline const char_t *GetMsgDesc(const InnerMessage &msg)
46 : {
47 3 : if ((msg.msgType >= InnerMsgType::INNER_MSG_PUSH) && (msg.msgType <= InnerMsgType::INNER_MSG_RECOVER)) {
48 3 : const char_t * const msgDesc[static_cast<int32_t>(InnerMsgType::INNER_MSG_INVALID)] = {
49 : "PUSH",
50 : "F2NF",
51 : "RECOVER"
52 : };
53 :
54 3 : return msgDesc[static_cast<int32_t>(msg.msgType)];
55 : } else {
56 0 : return "INNER_MSG_INVALID";
57 : }
58 : }
59 :
60 : enum class EntityType : int32_t {
61 : ENTITY_QUEUE = 0,
62 : ENTITY_TAG,
63 : ENTITY_GROUP,
64 : ENTITY_INVALID
65 : };
66 :
67 : enum class EntityDirection : int32_t {
68 : DIRECTION_SEND = 0,
69 : DIRECTION_RECV,
70 : DIRECTION_INVALID
71 : };
72 :
73 1169 : inline const char_t *GetDirectionDesc(const EntityDirection direction)
74 : {
75 1169 : if ((direction >= EntityDirection::DIRECTION_SEND) && (direction <= EntityDirection::DIRECTION_RECV)) {
76 1169 : const char_t * const directionDesc[static_cast<int32_t>(EntityDirection::DIRECTION_INVALID)] = {
77 : "SEND",
78 : "RECV"
79 : };
80 :
81 1169 : return directionDesc[static_cast<int32_t>(direction)];
82 : } else {
83 0 : return "DIRECTION_INVALID";
84 : }
85 : }
86 :
87 : enum class FsmState : int32_t {
88 : FSM_BASE_STATE = 0,
89 : FSM_IDLE_STATE,
90 : FSM_PEEK_STATE,
91 : FSM_TRY_PUSH_STATE,
92 : FSM_WAIT_PUSH_STATE,
93 : FSM_PUSH_STATE,
94 : FSM_FULL_STATE,
95 : FSM_ERROR_STATE,
96 : FSM_INVALID_STATE
97 : };
98 :
99 : enum class AsyncDataState : int32_t {
100 : FSM_ASYNC_DATA_INIT = 0,
101 : FSM_ASYNC_DATA_WAIT,
102 : FSM_ASYNC_DATA_SENT,
103 : FSM_ASYNC_ENTITY_DONE,
104 : FSM_ASYNC_DATA_INVALID
105 : };
106 :
107 : enum class SubscribeStatus : int32_t {
108 : SUBSCRIBE_PAUSE = 0,
109 : SUBSCRIBE_RESUME,
110 : SUBSCRIBE_INVALID
111 : };
112 :
113 : enum class BufEventType : int32_t {
114 : BUF_EVENT_DEL = 0,
115 : BUF_EVENT_ADD,
116 : };
117 :
118 : enum class ChannelLinkStatus : int32_t {
119 : UNCONNECTED = 0,
120 : CONNECTED,
121 : ABNORMAL,
122 : };
123 : }
124 : #endif
|