LCOV - code coverage report
Current view: top level - common - bqs_so_manager.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 10 10
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 2 2

            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 QUEUE_SCHEDULE_SO_MANAGER_H
      12              : #define QUEUE_SCHEDULE_SO_MANAGER_H
      13              : 
      14              : #include <map>
      15              : #include <string>
      16              : #include <vector>
      17              : 
      18              : namespace bqs {
      19              : class SoManager {
      20              : public:
      21           14 :     SoManager(const std::string &soName, const std::vector<std::string> &funcNames) : soName_(soName),
      22           14 :                                                                                       soHandle_(nullptr),
      23           28 :                                                                                       funcHandleMap_({})
      24              :     {
      25           14 :         OpenSo();
      26           14 :         if (soHandle_ != nullptr) {
      27            4 :             BatchLoadFunc(funcNames);
      28              :         }
      29           14 :     };
      30              : 
      31           14 :     ~SoManager()
      32              :     {
      33           14 :         CloseSo();
      34           14 :     }
      35              : 
      36              :     void *GetFuncHandle(const std::string &funcName) const;
      37              : 
      38              :     bool IsSoLoad() const;
      39              : 
      40              : private:
      41              :     SoManager(const SoManager &) = delete;
      42              :     SoManager &operator=(const SoManager &) = delete;
      43              :     SoManager(SoManager &&) = delete;
      44              :     SoManager &operator=(SoManager &&) = delete;
      45              : 
      46              :     void OpenSo();
      47              :     void CloseSo();
      48              :     void BatchLoadFunc(const std::vector<std::string> &funcNames);
      49              :     void *GetFuncHandleFromSo(const std::string &funcName) const;
      50              : 
      51              :     std::string soName_;
      52              :     void *soHandle_;
      53              :     std::map<std::string, void*> funcHandleMap_;
      54              : };
      55              : } // namespace bqs
      56              : 
      57              : #endif // QUEUE_SCHEDULE_SO_MANAGER_H
        

Generated by: LCOV version 2.0-1