• 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_SENSOR_INTERFACE_H
17 #define DEVICESTATUS_SENSOR_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 DevicestatusSensorInterface {
29 public:
DevicestatusSensorInterface()30     DevicestatusSensorInterface() {}
~DevicestatusSensorInterface()31     virtual ~DevicestatusSensorInterface() {}
32     class DevicestatusSensorHdiCallback {
33     public:
34         DevicestatusSensorHdiCallback() = default;
35         virtual ~DevicestatusSensorHdiCallback() = default;
36         virtual void OnSensorHdiResult(const DevicestatusDataUtils::DevicestatusData& data) = 0;
37     };
38 
39     virtual void RegisterCallback(const std::shared_ptr<DevicestatusSensorHdiCallback>& callback) = 0;
40     virtual void UnregisterCallback() = 0;
41     virtual void Enable() = 0;
42     virtual void Disable() = 0;
43 };
44 
45 struct SensorHdiHandle {
46     void* handle;
47     DevicestatusSensorInterface* (*create)();
48     void* (*destroy)(DevicestatusSensorInterface*);
49     DevicestatusSensorInterface* pAlgorithm;
SensorHdiHandleSensorHdiHandle50     SensorHdiHandle() : handle(nullptr), create(nullptr), destroy(nullptr), pAlgorithm(nullptr) {}
~SensorHdiHandleSensorHdiHandle51     ~SensorHdiHandle() {}
ClearSensorHdiHandle52     void Clear()
53     {
54         handle = nullptr;
55         create = nullptr;
56         destroy = nullptr;
57         pAlgorithm = nullptr;
58     }
59 };
60 }
61 }
62 #endif // DEVICESTATUS_SENSOR_INTERFACE_H
63