LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_instance - ccu_instance_mgr.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 1 1

            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 HCOMM_CCU_INSTANCE_MGR_H
      12              : #define HCOMM_CCU_INSTANCE_MGR_H
      13              : 
      14              : #include <memory>
      15              : #include <mutex>
      16              : #include <shared_mutex>
      17              : #include <unordered_map>
      18              : 
      19              : #include "ccu_instance.h"
      20              : #include "ccu_res_desc_mgr.h"
      21              : 
      22              : namespace hcomm {
      23              : 
      24              : class CcuInstanceMgr {
      25              : public:
      26              :     static CcuInstanceMgr& GetInstance(const int32_t deviceLogicId);
      27              : 
      28              :     CcuResult Init();
      29              :     CcuResult Deinit();
      30              : 
      31              :     // 基于实例类型创建实例
      32              :     CcuResult CreateByInsType(const CcuInstanceType insType, CcuInsHandle& insHandle);
      33              :     // 基于资源描述符数组创建实例
      34              :     CcuResult CreateByResDescs(const CcuResDesc* descs[], uint32_t descNum, CcuInsHandle& insHandle);
      35              :     // 使用当前 Device 上所有已使能 ioDie 的全部资源创建实例
      36              :     CcuResult CreateByAllRes(CcuInsHandle& insHandle);
      37              :     // 查询实例持有的资源描述符
      38              :     CcuResult QueryInsResDesc(CcuInsHandle& ccuInsHandle, uint8_t dieId, HcommCcuResDescHandle& resDesc);
      39              :     CcuInstance* Get(CcuInsHandle insHandle) const;
      40              :     CcuResult Destroy(CcuInsHandle insHandle);
      41              :     CcuResDescMgr& GetResDescMgr();
      42              : 
      43              : private:
      44          132 :     explicit CcuInstanceMgr() = default;
      45              :     ~CcuInstanceMgr();
      46              : 
      47              :     CcuInstanceMgr(const CcuInstanceMgr& that) = delete;
      48              :     CcuInstanceMgr& operator=(const CcuInstanceMgr& that) = delete;
      49              : 
      50              : private:
      51              :     bool initializedFlag_{false};
      52              :     int32_t devLogicId_{-1};
      53              :     CcuInsHandle instanceId_{0};
      54              :     mutable std::shared_timed_mutex insMapMutex_;
      55              :     std::unordered_map<CcuInsHandle, std::unique_ptr<CcuInstance>> insMap_{};
      56              :     CcuResDescMgr resDescMgr_;
      57              : };
      58              : }; // namespace hcomm
      59              : 
      60              : #endif // HCOMM_CCU_INSTANCE_MGR_H
        

Generated by: LCOV version 2.0-1