4 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include <sensor_common.h>
21 #include <sensor_types.h>
22 #include <sensor_usage.h>
23 #include <sensor_log.h>
25 sensor_usage::sensor_usage()
26 : m_interval(POLL_1HZ_MS)
28 , m_pause_policy(SENSORD_PAUSE_ALL)
33 sensor_usage::~sensor_usage()
38 bool sensor_usage::register_event(unsigned int event_type)
40 auto it_event = find(m_reg_events.begin(), m_reg_events.end(), event_type);
42 if (it_event != m_reg_events.end()) {
43 _E("Event[%#x] is already registered", event_type);
47 m_reg_events.push_back(event_type);
51 bool sensor_usage::unregister_event(unsigned int event_type)
53 auto it_event = find(m_reg_events.begin(), m_reg_events.end(), event_type);
55 if (it_event == m_reg_events.end()) {
56 _E("Event[%#x] is not found", event_type);
60 m_reg_events.erase(it_event);
65 bool sensor_usage::is_event_registered(unsigned int event_type)
67 auto it_event = find(m_reg_events.begin(), m_reg_events.end(), event_type);
69 if (it_event == m_reg_events.end()) {
70 _D("Event[%#x] is not registered", event_type);