event.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *                         Powersave Daemon                                *
00004  *                                                                         *
00005  *          Copyright (C) 2004,2005 SUSE Linux Products GmbH               *
00006  *                                                                         *
00007  *               Author(s): Holger Macht <hmacht@suse.de>                  *
00008  *                                                                         *
00009  * This program is free software; you can redistribute it and/or modify it *
00010  * under the terms of the GNU General Public License as published by the   *
00011  * Free Software Foundation; either version 2 of the License, or (at you   *
00012  * option) any later version.                                              *
00013  *                                                                         *
00014  * This program is distributed in the hope that it will be useful, but     *
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of              *
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
00017  * General Public License for more details.                                *
00018  *                                                                         *
00019  * You should have received a copy of the GNU General Public License along *
00020  * with this program; if not, write to the Free Software Foundation, Inc., *
00021  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA                  *
00022  *                                                                         *
00023  ***************************************************************************/
00024 
00025 #ifndef POWERSAVE_EVENT_H
00026 #define POWERSAVE_EVENT_H
00027 
00028 #include <list>
00029 #include <string>
00030 #include <ext/slist>
00031 
00032 #include "config_pm.h"
00033 
00034 using namespace std;
00035 
00037 class Event {
00038 public:
00040          Event();
00041 
00043          Event(const string &n);
00044 
00046          Event(const Event &);
00047 
00049          Event & operator=(Event &);
00050 
00052         ~Event();
00053 
00060         bool execute_program(string acpi_event_line = "");
00061 
00068         void setActions2Execute(std::list< std::string > actions);
00069 
00074         void setActions2Execute(const string &action);
00075 
00082         bool isInternalAction();
00083 
00084         // the following is needed for managing events--------------------
00085 
00086         // all the following functions are for setting and getting the different
00087         // properties
00088 
00090         void setTimeout(unsigned long);
00091 
00093         unsigned long getTimeout();
00094 
00096         void start();
00097 
00099         void increaseSleeptime(unsigned long time);
00100 
00102         void setID(int id);
00103 
00105         int ID();
00106 
00111         string name();
00112 
00114         unsigned long timeElapsed();
00115 
00117         void setupInternalActions();
00118 
00119         list < string >::iterator end();
00120 
00129         void insertAction(std::list< std::string > &actions, bool before,
00130                           const std::string &match, const std::string &action);
00131 
00133         std::list< string >::iterator _current_program_2_execute;
00134 
00141         static const int _proxy_nice_factor = -20;
00142 
00143         std::string currentAction();
00144 
00149         std::list< string > _programs_2_execute;
00150 
00151 #ifdef CREATE_DEBUG_OUTPUT
00152         friend ostream & operator<<(ostream &, const Event &);
00153 #endif
00154 
00155 private:
00157         string _name;
00158 
00160         int _id;
00161 
00163         time_t _timeout;
00164 
00166         long _starttime;
00167 
00169         unsigned long _sleep_time;
00170 
00172         std::list < string > _internalActions;
00173 };
00174 
00175 #endif // POWERSAVE_EVENT_H

Generated on Mon Mar 27 09:27:19 2006 for Powersave Daemon by  doxygen 1.4.6