LCOV - code coverage report
Current view: top level - basic_component/package_manager/inc - package_env_info.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 15 15
Test Date: 2026-08-12 11:03:52 Functions: 100.0 % 13 13

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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 TSD_PACKAGE_ENV_INFO_H
      12              : #define TSD_PACKAGE_ENV_INFO_H
      13              : 
      14              : #include "plugin_pkg_version.h"
      15              : #include "hdc_message_builder.h"
      16              : #include "driver/ascend_hal.h"
      17              : #include "proto/tsd_message.pb.h"
      18              : #include "basic_define.h"
      19              : 
      20              : #include <string>
      21              : #include <vector>
      22              : 
      23              : namespace tsd {
      24              : 
      25              : class PackageEnvInfo {
      26              : public:
      27              :     PackageEnvInfo(uint32_t logicDeviceId, uint32_t platInfoMode, bool isAdcEnv, uint32_t chipType);
      28        76630 :     ~PackageEnvInfo() = default;
      29              : 
      30              :     // 平台信息
      31            8 :     uint32_t GetPlatInfoMode() const { return platInfoMode_; }
      32           10 :     void SetPlatInfoMode(uint32_t mode) { platInfoMode_ = mode; }
      33           23 :     bool IsAdcEnv() const { return isAdcEnv_; }
      34            9 :     uint32_t GetPlatInfoChipType() const { return chipType_; }
      35            7 :     void SetPlatInfoChipType(uint32_t chipType) { chipType_ = chipType; }
      36          213 :     uint32_t GetLogicDeviceId() const { return logicDeviceId_; }
      37              : 
      38              :     // 包扫描
      39              :     bool CheckPackageExists(const bool loadAicpuKernelFlag = true);
      40              :     bool GetPackageTitle(std::string& packageTitle) const;
      41              :     static bool ResolvePackageTitle(uint32_t chipType, uint32_t platInfoMode, std::string& packageTitle);
      42              :     const std::string& GetPackageName(uint32_t type) const { return packageName_[type]; }
      43              :     const std::string& GetPackagePath(uint32_t type) const { return packagePath_[type]; }
      44              : 
      45              :     // 路径解析
      46              :     void GetAscendLatestIntallPath(std::string& pkgBasePath) const;
      47              :     bool GetShortSocVersion(std::string& shortSocVersion) const;
      48              :     std::string GetCurHostMutexFile(bool useCannPath) const;
      49              :     std::string GetTrustedBasePath(bool useV2) const;
      50              :     TSD_StatusT GetTrustedBasePathFromDevice(int32_t& peerNode, std::string& dstDirPreFix) const;
      51              : 
      52           33 :     const std::string& GetHostSoPath() const { return hostSoPath_; }
      53            7 :     void SetHostSoPath(const std::string& path) { hostSoPath_ = path; }
      54           51 :     std::string& GetPackageNameRef(uint32_t type) { return packageName_[type]; }
      55              :     const std::string& GetPackageNameRef(uint32_t type) const { return packageName_[type]; }
      56           13 :     std::string& GetPackagePathRef(uint32_t type) { return packagePath_[type]; }
      57              :     const std::string& GetPackagePathRef(uint32_t type) const { return packagePath_[type]; }
      58              :     std::string& GetPackagePatternRef(uint32_t type) { return packagePattern_[type]; }
      59              :     const std::string& GetPackagePatternRef(uint32_t type) const { return packagePattern_[type]; }
      60              :     // 供 ClientManager 引用成员绑定(Facade 模式遗留)
      61          408 :     std::string (&GetPackageNameArr())[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]
      62              :     {
      63          408 :         return packageName_;
      64              :     }
      65          408 :     std::string (&GetPackagePathArr())[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]
      66              :     {
      67          408 :         return packagePath_;
      68              :     }
      69              :     std::string (&GetPackagePatternArr())[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]
      70              :     {
      71              :         return packagePattern_;
      72              :     }
      73              : 
      74              :     bool CheckPackageExistsOnce(const uint32_t packageType);
      75              :     bool GetPackagePath(std::string& packagePath, const uint32_t packageType) const;
      76              :     std::vector<std::string> ScanAndMatchPackages(const std::string& pkgPath, const uint32_t packageType) const;
      77              : 
      78              : private:
      79              :     uint32_t platInfoMode_;
      80              :     bool isAdcEnv_;
      81              :     uint32_t chipType_;
      82              :     std::string hostSoPath_;
      83              :     std::string packageName_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)];
      84              :     std::string packagePath_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)];
      85              :     std::string packagePattern_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)];
      86              :     uint32_t logicDeviceId_;
      87              : };
      88              : 
      89              : } // namespace tsd
      90              : 
      91              : #endif // TSD_PACKAGE_ENV_INFO_H
        

Generated by: LCOV version 2.0-1