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 <memory> 20 21 #include <errors.h> 22 23 #include "stationary_data.h" 24 25 namespace OHOS { 26 namespace Msdp { 27 namespace DeviceStatus { 28 class IMsdp { 29 public: 30 IMsdp() = default; 31 virtual ~IMsdp() = default; 32 class MsdpAlgoCallback { 33 public: 34 MsdpAlgoCallback() = default; 35 virtual ~MsdpAlgoCallback() = default; 36 virtual void OnResult(const Data& data) = 0; 37 }; 38 39 virtual ErrCode RegisterCallback(std::shared_ptr<IMsdp::MsdpAlgoCallback> callback) = 0; 40 virtual ErrCode UnregisterCallback() = 0; 41 virtual ErrCode Enable(Type type) = 0; 42 virtual ErrCode Disable(Type type) = 0; 43 virtual ErrCode DisableCount(Type type) = 0; 44 }; 45 46 struct MsdpAlgoHandle { 47 void* handle; 48 IMsdp* (*create)(); 49 void* (*destroy)(IMsdp*); 50 IMsdp* pAlgorithm; MsdpAlgoHandleMsdpAlgoHandle51 MsdpAlgoHandle() : handle(nullptr), create(nullptr), destroy(nullptr), pAlgorithm(nullptr) {} ~MsdpAlgoHandleMsdpAlgoHandle52 ~MsdpAlgoHandle() {} ClearMsdpAlgoHandle53 void Clear() 54 { 55 handle = nullptr; 56 create = nullptr; 57 destroy = nullptr; 58 pAlgorithm = nullptr; 59 } 60 }; 61 } // namespace DeviceStatus 62 } // namespace Msdp 63 } // namespace OHOS 64 #endif // DEVICESTATUS_MSDP_INTERFACE_H 65