1eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu/*
2eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu * Copyright (C) 2010 The Android Open Source Project
3eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu *
4eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu * Licensed under the Apache License, Version 2.0 (the "License");
5eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu * you may not use this file except in compliance with the License.
6eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu * You may obtain a copy of the License at
7eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu *
8eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu *      http://www.apache.org/licenses/LICENSE-2.0
9eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu *
10eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu * Unless required by applicable law or agreed to in writing, software
11eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu * distributed under the License is distributed on an "AS IS" BASIS,
12eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu * See the License for the specific language governing permissions and
14eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu * limitations under the License.
15eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu */
16eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu
17eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu#ifndef ANDROID_SENSOR_RECORD_H
18eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu#define ANDROID_SENSOR_RECORD_H
19eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu
20eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu#include "SensorService.h"
21eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu
22eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xunamespace android {
23eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu
24eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xuclass SensorService;
25eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu
26eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xuclass SensorService::SensorRecord {
27eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xupublic:
28ded526e8c3539b5986b46dffc1ff8ab15d7da570Peng Xu    SensorRecord(const sp<const SensorEventConnection>& connection);
29ded526e8c3539b5986b46dffc1ff8ab15d7da570Peng Xu    bool addConnection(const sp<const SensorEventConnection>& connection);
30ded526e8c3539b5986b46dffc1ff8ab15d7da570Peng Xu    bool removeConnection(const wp<const SensorEventConnection>& connection);
31eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu    size_t getNumConnections() const { return mConnections.size(); }
32eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu
33ded526e8c3539b5986b46dffc1ff8ab15d7da570Peng Xu    void addPendingFlushConnection(const sp<const SensorEventConnection>& connection);
34eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu    void removeFirstPendingFlushConnection();
35ded526e8c3539b5986b46dffc1ff8ab15d7da570Peng Xu    wp<const SensorEventConnection> getFirstPendingFlushConnection();
36eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu    void clearAllPendingFlushConnections();
37eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xuprivate:
38ded526e8c3539b5986b46dffc1ff8ab15d7da570Peng Xu    SortedVector< wp<const SensorEventConnection> > mConnections;
39eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu    // A queue of all flush() calls made on this sensor. Flush complete events
40eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu    // will be sent in this order.
41ded526e8c3539b5986b46dffc1ff8ab15d7da570Peng Xu    Vector< wp<const SensorEventConnection> > mPendingFlushConnections;
42eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu};
43eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu
44eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu}
45eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu
46eb4d628b69831d533f14c09fd63400f75e69ba76Peng Xu#endif // ANDROID_SENSOR_RECORD_H
47