1 /*
2  * Copyright (c) 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 HDI_SENSOR_CLIENT_H
17 #define HDI_SENSOR_CLIENT_H
18 
19 #include <mutex>
20 #include <unordered_map>
21 #include "v2_0/isensor_interface.h"
22 #include "isensor_interface_vdi.h"
23 
24 namespace OHOS {
25 namespace HDI {
26 namespace Sensor {
27 namespace V2_0 {
28 
29 class SensorClientInfo {
30 public:
31     SensorClientInfo();
32     ~SensorClientInfo();
SensorClientInfo(const sptr<ISensorCallback> & callbackObj)33     explicit SensorClientInfo(const sptr<ISensorCallback> &callbackObj)
34         : pollCallback_(callbackObj) {};
35     void SetReportDataCb(const sptr<ISensorCallback> &callbackObj);
36     const sptr<ISensorCallback> GetReportDataCb();
37     std::unordered_map<int32_t, struct SensorConfig> sensorConfigMap_;
38     std::unordered_map<int32_t, int32_t> periodCountMap_;
39     std::unordered_map<int32_t, int32_t> curCountMap_;
40     void PrintClientMapInfo(int32_t serviceId, int32_t sensorId);
41 private:
42     sptr<ISensorCallback> pollCallback_;
43 };
44 
45 struct SensorConfig {
46     int32_t samplingInterval;
47     int32_t reportInterval;
48 };
49 
50 } // V2_0
51 } // Sensor
52 } // HDI
53 } // OHOS
54 
55 #endif // HDI_SENSOR_CLIENT_H