1 /* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DEVICESTATUS_MSDP_INTERFACE_H 17 #define DEVICESTATUS_MSDP_INTERFACE_H 18 19 #include <string> 20 #include <memory> 21 #include <map> 22 #include <errors.h> 23 24 #include "devicestatus_data_utils.h" 25 26 namespace OHOS { 27 namespace Msdp { 28 class DevicestatusMsdpInterface { 29 public: DevicestatusMsdpInterface()30 DevicestatusMsdpInterface() {} ~DevicestatusMsdpInterface()31 virtual ~DevicestatusMsdpInterface() {} 32 class MsdpAlgorithmCallback { 33 public: 34 MsdpAlgorithmCallback() = default; 35 virtual ~MsdpAlgorithmCallback() = default; 36 virtual void OnResult(const DevicestatusDataUtils::DevicestatusData& data) = 0; 37 }; 38 39 virtual ErrCode RegisterCallback(std::shared_ptr<MsdpAlgorithmCallback> callback) = 0; 40 virtual ErrCode UnregisterCallback() = 0; 41 virtual ErrCode Enable(DevicestatusDataUtils::DevicestatusType type) = 0; 42 virtual ErrCode Disable(DevicestatusDataUtils::DevicestatusType type) = 0; DisableCount(DevicestatusDataUtils::DevicestatusType type)43 virtual ErrCode DisableCount(DevicestatusDataUtils::DevicestatusType type) 44 { 45 return ERR_OK; 46 }; 47 }; 48 struct MsdpAlgorithmHandle { 49 void* handle; 50 DevicestatusMsdpInterface* (*create)(); 51 void* (*destroy)(DevicestatusMsdpInterface*); 52 DevicestatusMsdpInterface* pAlgorithm; MsdpAlgorithmHandleMsdpAlgorithmHandle53 MsdpAlgorithmHandle() : handle(nullptr), create(nullptr), destroy(nullptr), pAlgorithm(nullptr) {} ~MsdpAlgorithmHandleMsdpAlgorithmHandle54 ~MsdpAlgorithmHandle() {} ClearMsdpAlgorithmHandle55 void Clear() 56 { 57 handle = nullptr; 58 create = nullptr; 59 destroy = nullptr; 60 pAlgorithm = nullptr; 61 } 62 }; 63 } 64 } 65 #endif // DEVICESTATUS_MSDP_INTERFACE_H 66