LCOV - code coverage report
Current view: top level - aicpu_schedule/common/ts_to_aicpu_msg_adapter - ts_msg_adapter_factory.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 92.6 % 27 25
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 2 2

            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              : #include "ts_msg_adapter_factory.h"
      11              : #include "ts_msg_adapter_common.h"
      12              : namespace AicpuSchedule {
      13            3 : std::unique_ptr<TsMsgAdapter> TsMsgAdapterFactory::CreateAdapter(const char_t *msg) const
      14              : {
      15            3 :     if (msg == nullptr) {
      16            0 :         aicpusd_err("Create adapter failed: input_message=null.");
      17            0 :         return nullptr;
      18              :     }
      19            3 :     const uint8_t version = FeatureCtrl::GetTsMsgVersion();
      20            3 :     switch (static_cast<uint8_t>(version)) {
      21            1 :         case VERSION_0: {
      22            1 :             const TsAicpuSqe* const sqe = PtrToPtr<const char_t, const TsAicpuSqe>(msg);
      23            1 :             return std::make_unique<TsAicpuSqeAdapter>(*sqe);
      24              :         }
      25            1 :         case VERSION_1: {
      26            1 :             const TsAicpuMsgInfo * const msgInfo = PtrToPtr<const char_t, const TsAicpuMsgInfo>(msg);
      27            1 :             return std::make_unique<TsAicpuMsgInfoAdapter>(*msgInfo);
      28              :         }
      29            1 :         default:
      30            1 :             aicpusd_err("Create adapter failed: unsupported_version=%u.", version);
      31            1 :             break;
      32              :     }
      33            1 :     return nullptr;
      34              : }
      35              : 
      36            3 : std::unique_ptr<TsMsgAdapter> TsMsgAdapterFactory::CreateAdapter() const
      37              : {
      38            3 :     const uint8_t version = FeatureCtrl::GetTsMsgVersion();
      39            3 :     switch (static_cast<uint8_t>(version)) {
      40            1 :         case VERSION_0: {
      41            1 :             return std::make_unique<TsAicpuSqeAdapter>();
      42              :         }
      43            1 :         case VERSION_1: {
      44            1 :             return std::make_unique<TsAicpuMsgInfoAdapter>();
      45              :         }
      46            1 :         default:
      47            1 :             aicpusd_err("Create adapter failed: unsupported_version=%u.", version);
      48            1 :             break;
      49              :     }
      50            1 :     return nullptr;
      51              : }
      52              : } // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1