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.
16 #ifndef WRTDEVICEAPIS_POWER_BATTERY_H_
17 #define WRTDEVICEAPIS_POWER_BATTERY_H_
21 #include <dpl/mutex.h>
22 #include <Power/IBattery.h>
23 #include <VConf/Key.h>
25 namespace WrtDeviceApis {
28 class Battery : public Api::IBattery
37 * @see Api::Power::IBattery::isCharging()
39 bool isCharging() const;
42 * @see Api::Power::IBattery::getRemaining()
44 unsigned int getRemaining() const;
47 * @see Api::Power::IBattery::addOnCharging()
49 void addOnCharging(const Api::EventChargingEmitterPtr& emitter);
52 * @see Api::Power::IBattery::removeOnCharing()
54 void removeOnCharging(Api::EventChargingEmitter::IdType id);
57 * @see Api::Power::IBattery::addOnRemaining()
59 void addOnRemaining(const Api::EventRemainingEmitterPtr& emitter);
62 * @see Api::Power::IBattery::removeOnRemaining()
64 void removeOnRemaining(Api::EventRemainingEmitter::IdType id);
67 * @see Api::Power::IBattery::addOnLow()
69 void addOnLow(const Api::EventLowEmitterPtr& emitter);
72 * @see Api::Power::IBattery::removeOnRemaining()
74 void removeOnLow(Api::EventLowEmitter::IdType id);
77 typedef std::map<Api::EventChargingEmitter::IdType,
78 Api::EventChargingEmitterPtr> ChargingEventEmitters;
80 typedef std::map<Api::EventRemainingEmitter::IdType,
81 Api::EventRemainingEmitterPtr>
82 RemainingEventEmitters;
84 typedef std::map<Api::EventLowEmitter::IdType,
85 Api::EventLowEmitterPtr> LowEventEmitters;
87 explicit Battery(std::size_t index);
90 * Callback method called by platform when battery charging state changes.
91 * @param key Vconf key object.
92 * @param data User data.
94 static void onCharging(const VConf::Node* node,
98 * Callback method called by platform when battery power level changes.
99 * @param key Vconf key object.
100 * @param data User data.
102 static void onRemaining(const VConf::Node* key,
106 * Callback method called by platform when battery power level gets low.
107 * @param key Vconf key object.
108 * @param data User data.
110 static void onLow(const VConf::Node* key,
114 std::size_t m_index; ///< Index of battery this interface represents.
115 VConf::Key m_onChargingKey; ///< Wrapper for vconf on battery charging key.
116 VConf::Key m_onRemainingKey; ///< Wrapper for vconf on battery level key.
117 VConf::Key m_onLowKey; ///< Wrapper for vconf on battery low level state key.
118 ChargingEventEmitters m_onCharging; ///< Charging event emitters.
119 RemainingEventEmitters m_onRemaining; ///< Remaining event emitters.
120 LowEventEmitters m_onLow; ///< Low level event emitters.
121 DPL::Mutex m_onChargingMtx; ///< Mutex synchronizing operations on m_onCharging object.
122 DPL::Mutex m_onRemainingMtx; ///< Mutex synchronizing operations on m_onRemaining object.
123 DPL::Mutex m_onLowMtx; ///< Mutex synchronizing operations on m_onLow object.
129 #endif /* WRTDEVICEAPIS_POWER_BATTERY_H_ */