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_info_manager.h>
28 sensor_info_manager::sensor_info_manager()
32 sensor_info_manager::~sensor_info_manager()
34 auto it_info = m_sensor_infos.begin();
36 while (it_info != m_sensor_infos.end()) {
37 delete it_info->second;
42 sensor_info_manager& sensor_info_manager::get_instance(void)
44 static sensor_info_manager inst;
48 const sensor_info* sensor_info_manager::get_info(sensor_type_t type)
50 auto it_info = m_sensor_infos.find(type);
52 if (it_info == m_sensor_infos.end())
55 return it_info->second;
58 void sensor_info_manager::add_info(sensor_info* info)
60 m_sensor_infos.insert(make_pair(info->get_type(), info));
61 m_id_to_info_map.insert(make_pair(info->get_id(), info));
62 m_info_set.insert(info);
65 vector<sensor_info *> sensor_info_manager::get_infos(sensor_type_t type)
67 vector<sensor_info *> sensor_infos;
69 pair<sensor_infos::iterator, sensor_infos::iterator> ret;
71 if (type == ALL_SENSOR)
72 ret = std::make_pair(m_sensor_infos.begin(), m_sensor_infos.end());
74 ret = m_sensor_infos.equal_range(type);
76 for (auto it_info = ret.first; it_info != ret.second; ++it_info)
77 sensor_infos.push_back(it_info->second);
82 const sensor_info* sensor_info_manager::get_info(sensor_id_t id)
84 auto it_info = m_id_to_info_map.find(id);
86 if (it_info == m_id_to_info_map.end())
89 return it_info->second;
92 bool sensor_info_manager::is_valid(sensor_info* info)
94 auto it_info = m_info_set.find(info);
96 if (it_info == m_info_set.end())