/*
 * This file is part of DesktopBSD, see the README file.
 *
 * Author: Peter Hofer <ph@desktopbsd.net>
 *         (C) 2004, 2005
 *
 * Copyright: BSD, see the COPYING file included in this distribution
 *
 */

#ifndef __BATTERY_H
#define __BATTERY_H

#include <sysctl.h>

/** @brief Monitor battery status.
  *
  * This class provides information about batteries
  * of mobile devices.
  *
  * All these methods use the hw.acpi.battery sysctls
  * so most of these functions simply return -1 when
  * an error occured.
  */
class  Battery {
public:
   enum PowerSource {
      PS_Battery = 0,
      PS_ACLine = 1
   };

   /** @return The battery's life (percent). */
   static  int  getLife() {
      return  SysCtl::getIntCtl("hw.acpi.battery.life");
   }

   /** @return Remaining time until the battery is empty. */
   static  int  getTime() {
      return  SysCtl::getIntCtl("hw.acpi.battery.time");
   }

   /** @return The interval in which these values are
     *         updated internally (by the operating system).
     */
   static  int  infoExpires() {
      return  SysCtl::getIntCtl("hw.acpi.battery.info_expire");
   };

   /** @return Battery::PS_Battery or Battery::PS_ACLine */
   static  int  powerSource() {
      return  SysCtl::getIntCtl("hw.acpi.acline");
   };

	/** Returns TRUE when battery information is available or
	  * FALSE if not, e.g. when this is not a mobile device
	  * or ACPI doesn't work.
	  */
	static  bool  informationAvailable() {
		return  SysCtl::ctlExists("hw.acpi.battery.life");
	}
};

#endif /* __BATTERY_H */
