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 : #ifndef ADX_COMMOPT_H
11 : #define ADX_COMMOPT_H
12 : #include <cstdint>
13 : #include <string>
14 : #include <map>
15 : #include "extra_config.h"
16 : #include "device/adx_device.h"
17 : #include "common_utils.h"
18 : #include "adx_service_config.h"
19 : namespace Adx {
20 : constexpr int32_t COMM_OPT_BLOCK = 0;
21 : constexpr int32_t COMM_OPT_NOBLOCK = 1;
22 : constexpr int32_t COMM_OPT_TIMEOUT = 2;
23 : constexpr OptHandle ADX_OPT_INVALID_HANDLE = -1;
24 : const std::string OPT_DEVICE_KEY = "DeviceId";
25 : const std::string OPT_SERVICE_KEY = "ServiceType";
26 : const std::string OPT_PID_KEY = "Pid";
27 :
28 : class AdxCommOpt {
29 : public:
30 98 : AdxCommOpt() : device_(nullptr) {}
31 98 : virtual ~AdxCommOpt() {}
32 : virtual std::string CommOptName() = 0;
33 : virtual OptType GetOptType() = 0;
34 : virtual OptHandle OpenServer(const std::map<std::string, std::string> &info) = 0;
35 : virtual int32_t CloseServer(const OptHandle &handle) const = 0;
36 : virtual OptHandle OpenClient(const std::map<std::string, std::string> &info) = 0;
37 : virtual int32_t CloseClient(OptHandle &handle) const = 0;
38 : virtual OptHandle Accept(const OptHandle handle) const = 0;
39 : virtual OptHandle Connect(const OptHandle handle, const std::map<std::string, std::string> &info) = 0;
40 : virtual int32_t Close(OptHandle &handle) const = 0;
41 : virtual int32_t Write(const OptHandle handle, IdeSendBuffT buffer, int32_t length, int32_t flag) = 0;
42 : virtual int32_t Read(const OptHandle handle, IdeRecvBuffT buffer, int32_t &length, int32_t flag) = 0;
43 : virtual SharedPtr<AdxDevice> GetDevice() = 0;
44 : virtual void Timer(void) const = 0;
45 : protected:
46 : SharedPtr<AdxDevice> device_ = nullptr;
47 : };
48 : }
49 : #endif
|