• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 void RegisterCallback(const std::shared_ptr<MsdpAlgorithmCallback>& callback) = 0;
40     virtual void UnregisterCallback() = 0;
41     virtual void Enable() = 0;
42     virtual void Disable() = 0;
43 };
44 
45 struct MsdpAlgorithmHandle {
46     void* handle;
47     DevicestatusMsdpInterface* (*create)();
48     void* (*destroy)(DevicestatusMsdpInterface*);
49     DevicestatusMsdpInterface* pAlgorithm;
MsdpAlgorithmHandleMsdpAlgorithmHandle50     MsdpAlgorithmHandle() : handle(nullptr), create(nullptr), destroy(nullptr), pAlgorithm(nullptr) {}
~MsdpAlgorithmHandleMsdpAlgorithmHandle51     ~MsdpAlgorithmHandle() {}
ClearMsdpAlgorithmHandle52     void Clear()
53     {
54         handle = nullptr;
55         create = nullptr;
56         destroy = nullptr;
57         pAlgorithm = nullptr;
58     }
59 };
60 }
61 }
62 #endif // DEVICESTATUS_MSDP_INTERFACE_H
63