LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/common - inner_net_dev_manager.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 2 2

            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 HCCLV2_INNER_NET_DEVICE_MANAGER_H
      12              : #define HCCLV2_INNER_NET_DEVICE_MANAGER_H
      13              : 
      14              : #include <mutex>
      15              : #include <unordered_map>
      16              : #include "port.h"
      17              : #include "orion_adapter_hccp.h"
      18              : #include "ip_address.h"
      19              : #include "inner_net_dev.h"
      20              : #include "net_device.h"
      21              : 
      22              : namespace Hccl {
      23              : class InnerNetDevManager {
      24              : public:
      25              :     // 获取单例实例(线程安全)
      26              :     static InnerNetDevManager& GetInstance();
      27              : 
      28              :     // 删除拷贝构造和赋值运算符,防止实例复制
      29              :     InnerNetDevManager(const InnerNetDevManager&) = delete;
      30              :     InnerNetDevManager& operator=(const InnerNetDevManager&) = delete;
      31              : 
      32              :     // 添加设备(增加引用计数)
      33              :     HcclResult AddDevice(const NetDevInfo& info, HcclNetDevice*& device);
      34              : 
      35              :     // 删除设备(减少引用计数,计数为0时删除)
      36              :     HcclResult DeleteDevice(HcclNetDevice* device);
      37              : 
      38              :     // 删除设备(减少引用计数,计数为0时删除)
      39              :     HcclResult RemoveDevice(const NetDevInfo& info);
      40              : 
      41              : private:
      42              :     // 私有构造函数和析构函数
      43            2 :     InnerNetDevManager() = default;
      44            2 :     ~InnerNetDevManager() = default;
      45              : 
      46              :     std::unordered_map<NetDevInfo, unique_ptr<InnerNetDev>> netDevMap_;
      47              :     std::unordered_map<NetDevInfo, uint32_t> netDevCnt_;
      48              : };
      49              : 
      50              : } // namespace Hccl
      51              : 
      52              : #endif // HCCLV2_INNER_NET_DEVICE_MANAGER_H
        

Generated by: LCOV version 2.0-1