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 : #include "cnt_nto1_notify_lite_mgr.h"
11 : #include "binary_stream.h"
12 : #include "log.h"
13 : #include "stl_util.h"
14 :
15 : namespace Hccl {
16 :
17 0 : CntNto1NotifyLite *CntNto1NotifyLiteMgr::Get(u32 postQId, u32 topicId)
18 : {
19 0 : auto key = std::make_pair(postQId, topicId);
20 0 : if (!Contain(notifys, key)) {
21 0 : HCCL_WARNING("CntNto1NotifyLiteMgr::%s postQId(%u), topicId(%u) is not found", __func__, postQId, topicId);
22 0 : return nullptr;
23 : }
24 0 : HCCL_INFO("CntNto1NotifyLiteMgr::%s postQId [%u] topicId [%u]", __func__, postQId, topicId);
25 0 : return notifys[key].get();
26 : }
27 :
28 0 : void CntNto1NotifyLiteMgr::Reset()
29 : {
30 0 : notifys.clear();
31 0 : }
32 :
33 1 : void CntNto1NotifyLiteMgr::ParsePackedData(std::vector<char> &data)
34 : {
35 : u32 poolSize;
36 1 : BinaryStream binaryStream(data);
37 1 : binaryStream >> poolSize;
38 :
39 4 : for (u32 idx = 0; idx < poolSize; idx++) {
40 3 : std::pair<u32, u32> key;
41 3 : binaryStream >> key.first;
42 3 : binaryStream >> key.second;
43 3 : std::vector<char> uniqueId;
44 3 : binaryStream >> uniqueId;
45 3 : if (!Contain(notifys, key)) {
46 3 : notifys[key] = std::make_unique<CntNto1NotifyLite>(uniqueId);
47 : }
48 3 : }
49 1 : }
50 :
51 : } // namespace Hccl
|