2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <Commons/Exception.h>
21 const std::size_t NUMBER_OF_AVAILABLE_BATTERIES = 1;
22 const std::size_t NUMBER_OF_AVAILABLE_BACKLIGHT = 1;
25 namespace WrtDeviceApis {
28 Manager& Manager::getInstance()
30 static Manager instance;
36 //m_backlight = new Backlight();
43 void Manager::Release()
46 Batteries::iterator it = m_batteries.begin();
47 for (; it != m_batteries.end(); ++it) {
50 if (m_batteries.size() > 0) {
54 if (NULL != m_backlight) {
60 Battery* Manager::getBattery(std::size_t index) const
62 if (index > NUMBER_OF_AVAILABLE_BATTERIES) {
63 ThrowMsg(Commons::OutOfRangeException, "Battery not available.");
66 Batteries::iterator it = m_batteries.find(index);
67 if (it == m_batteries.end()) {
68 Battery* battery = new Battery(index);
69 m_batteries.insert(Batteries::value_type(index, battery));
75 std::size_t Manager::getBatteriesCount() const
77 return NUMBER_OF_AVAILABLE_BATTERIES;
80 Api::IBacklightPtr Manager::getBacklight(void)
82 if (NULL == m_backlight) {
83 m_backlight = Api::IBacklightPtr(new Backlight());
88 std::size_t Manager::getBacklightCount() const
90 return NUMBER_OF_AVAILABLE_BACKLIGHT;