LCOV - code coverage report
Current view: top level - adcore/device - adx_device.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 32 32
Test Date: 2026-07-28 10:54:24 Functions: 100.0 % 6 6

            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 <string>
      11              : #include "adx_device.h"
      12              : #include "log/adx_log.h"
      13              : namespace Adx {
      14            2 : void AdxDevice::EnableNotify(const std::string &devId)
      15              : {
      16            2 :     auto it = devices_.find(devId);
      17            2 :     if (it != devices_.end() && it->second != DeviceState::ENABLE_STATE) {
      18            1 :         IDE_LOGI("device %s going up.", devId.c_str());
      19            1 :         devices_[devId] = DeviceState::ENABLE_STATE;
      20              :     }
      21            2 : }
      22              : 
      23            2 : void AdxDevice::DisableNotify(const std::string &devId)
      24              : {
      25            2 :     auto it = devices_.find(devId);
      26            2 :     if (it != devices_.end() && it->second != DeviceState::DISABLE_STATE) {
      27            2 :         IDE_LOGI("device %s going suspend.", devId.c_str());
      28            2 :         devices_[devId] = DeviceState::DISABLE_STATE;
      29              :     }
      30            2 : }
      31              : 
      32           19 : void AdxDevice::GetEnableDevices(std::vector<std::string> &devices) const
      33              : {
      34           19 :     auto it = devices_.begin();
      35           41 :     for (; it != devices_.end(); it++) {
      36           22 :         if (it->second == DeviceState::ENABLE_STATE) {
      37           22 :             devices.push_back(it->first);
      38              :         }
      39              :     }
      40           19 : }
      41              : 
      42           15 : void AdxDevice::GetDisableDevices(std::vector<std::string> &devices) const
      43              : {
      44           15 :     devices.clear();
      45           15 :     auto it = devices_.begin();
      46           31 :     for (; it != devices_.end(); it++) {
      47           16 :         if (it->second == DeviceState::DISABLE_STATE) {
      48            2 :             devices.push_back(it->first);
      49              :         }
      50              :     }
      51           15 : }
      52              : 
      53           16 : bool AdxDevice::NoDevice() const
      54              : {
      55           16 :     return devices_.empty();
      56              : }
      57              : 
      58            6 : void AdxDevice::InitDevice(const std::string &devId)
      59              : {
      60            6 :     auto it = devices_.find(devId);
      61            6 :     if (it == devices_.end()) {
      62            6 :         devices_[devId] = DeviceState::ENABLE_STATE;
      63              :     }
      64            6 : }
      65              : }
        

Generated by: LCOV version 2.0-1