4 * Copyright (c) 2014 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.
21 #include <csensor_usage.h>
24 csensor_usage::csensor_usage()
25 : m_interval(POLL_MAX_HZ_MS)
26 , m_option(SENSOR_OPTION_DEFAULT)
31 csensor_usage::~csensor_usage()
36 bool csensor_usage::register_event(const unsigned int event_type)
38 reg_event_vector::iterator it_event;
39 it_event = find(m_reg_events.begin(), m_reg_events.end(), event_type);
41 if (it_event != m_reg_events.end()) {
42 ERR("Event[0x%x] is already registered", event_type);
46 m_reg_events.push_back(event_type);
50 bool csensor_usage::unregister_event(const unsigned int event_type)
52 reg_event_vector::iterator it_event;
53 it_event = find(m_reg_events.begin(), m_reg_events.end(), event_type);
55 if (it_event == m_reg_events.end()) {
56 ERR("Event[0x%x] is not found", event_type);
60 m_reg_events.erase(it_event);
64 bool csensor_usage::is_event_registered(const unsigned int event_type)
66 reg_event_vector::iterator it_event;
67 it_event = find (m_reg_events.begin(), m_reg_events.end(), event_type);
69 if (it_event == m_reg_events.end()) {
70 DBG("Event[0x%x] is not registered", event_type);