00001 #ifndef SHUTDOWN_ALERTER_CLASS
00002 #define SHUTDOWN_ALERTER_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "dll_processes.h"
00019
00020 #include <basis/object_base.h>
00021 #include <opsystem/timer_driver.h>
00022
00023
00024 class istring_object;
00025
00027
00035 class PROCESSES_CLASS_STYLE shutdown_alerter
00036 : public virtual object_base, public timed_object
00037 {
00038 public:
00039 shutdown_alerter();
00041
00042 virtual ~shutdown_alerter();
00043
00044 IMPLEMENT_CLASS_NAME("shutdown_alerter");
00045
00046 bool setup(const istring &app_name, int timer_period = 0);
00048
00053 static bool is_defunct() { return _defunct(); }
00055
00057 static void set_defunct();
00059
00062 inline bool saw_interrupt() { return _saw_interrupt(); }
00064
00065
00066
00067
00068
00069
00070 virtual void handle_startup();
00072
00073 virtual void handle_shutdown();
00075
00081 virtual void handle_timer();
00083
00084
00085
00086
00087 static bool launch_console(shutdown_alerter &alert, const istring &app_name,
00088 int timer_period = 0);
00090
00094 #if 0 //not implemented.
00095 #ifdef __WIN32__
00096 static bool launch_event_loop(shutdown_alerter &alert,
00097 const istring &app_name, int timer_period = 0);
00099
00101 #endif
00102 #endif
00103
00104 static void close_this_program();
00106
00110 static bool close_application(const istring &app_name);
00112
00115
00116
00117 static void handle_OS_signal(int sig_id);
00119
00120 private:
00121 static bool &_saw_interrupt();
00122 static istring_object &_app_name();
00123 static bool &_defunct();
00124 static int &_timer_period();
00125
00126 virtual void handle_timer_callback();
00128
00129
00130 shutdown_alerter(const shutdown_alerter &);
00131 shutdown_alerter &operator =(const shutdown_alerter &);
00132 };
00133
00134 #endif // outer guard.
00135