LCOV - code coverage report
Current view: top level - server - state_manager.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 94.1 % 17 16
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 5 5

            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              : #include "state_manager.h"
      12              : #include "common/bqs_log.h"
      13              : #include "fsm/state_define.h"
      14              : 
      15              : namespace dgw {
      16         4486 : StateManager &StateManager::Instance()
      17              : {
      18         4486 :     static StateManager instance;
      19         4486 :     return instance;
      20              : }
      21              : 
      22           19 : void StateManager::RegisterState(const FsmState id, const EntityType eType, const StateBase *const state,
      23              :                                  const char_t * const idDesc, const char_t * const typeDesc)
      24              : {
      25              :     // Overwrite old when repeating
      26           19 :     state_[static_cast<size_t>(eType)][static_cast<size_t>(id)] = const_cast<StateBase *>(state);
      27           19 :     stateDesc_[static_cast<size_t>(eType)][static_cast<size_t>(id)] = idDesc;
      28           19 :     typeDesc_[static_cast<size_t>(eType)]= typeDesc;
      29           19 : }
      30              : 
      31          383 : StateBase *StateManager::GetState(const FsmState id, const EntityType eType) const
      32              : {
      33          383 :     auto state = state_[static_cast<size_t>(eType)][static_cast<size_t>(id)];
      34          383 :     if (state == nullptr) {
      35            0 :         DGW_LOG_ERROR("[FSM] Failed id:%d eType:%d.", static_cast<int32_t>(id), static_cast<int32_t>(eType));
      36              :     }
      37          383 :     return state;
      38              : }
      39              : 
      40         1869 : const std::string &StateManager::GetStateDesc(const FsmState id, const EntityType eType)
      41              : {
      42         1869 :     return stateDesc_[static_cast<size_t>(eType)][static_cast<size_t>(id)];
      43              : }
      44              : 
      45         2213 : const std::string &StateManager::GetTypeDesc(const EntityType eType)
      46              : {
      47         2213 :     return typeDesc_[static_cast<size_t>(eType)];
      48              : }
      49              : }  // namespace dgw
        

Generated by: LCOV version 2.0-1