t_shutdown_alerter.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : t_shutdown_alerter                                                *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *  Purpose:                                                                   *
00007 *                                                                             *
00008 *    An example of using the shutdown_alerter object to manage the runtime    *
00009 *  of a program.                                                              *
00010 *                                                                             *
00011 *******************************************************************************
00012 * Copyright (c) 2005-$now By Author.  This program is free software; you can  *
00013 * redistribute it and/or modify it under the terms of the GNU General Public  *
00014 * License as published by the Free Software Foundation; either version 2 of   *
00015 * the License or (at your option) any later version.  This is online at:      *
00016 *     http://www.fsf.org/copyleft/gpl.html                                    *
00017 * Please send any updates to: fred@gruntose.com                               *
00018 \*****************************************************************************/
00019 
00020 #include <basis/istring.h>
00021 #include <basis/log_base.h>
00022 #include <opsystem/filename.h>
00023 #include <data_struct/static_memory_gremlin.h>
00024 #include <processes/shutdown_alerter.h>
00025 
00026 HOOPLE_STARTUP_CODE;
00027 
00028 #define BASE_LOG(s) STAMPED_EMERGENCY_LOG(program_wide_logger(), s)
00029 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger(), s)
00030 
00031 const int TIMING_CYCLE = 1408;
00032   // how frequently timer should be hit.
00033 
00034 class my_anchor : public shutdown_alerter
00035 {
00036 public:
00037   virtual void handle_startup() { BASE_LOG("into startup..."); }
00038   virtual void handle_shutdown() { BASE_LOG("into shutdown..."); }
00039   virtual void handle_timer() { BASE_LOG("into timer..."); }
00040 };
00041 
00042 int main(int formal(argc), char *formal(argv)[])
00043 {
00044   my_anchor w;
00045   BASE_LOG(isprintf("timer will hit every %d ms.", TIMING_CYCLE));
00046   shutdown_alerter::launch_console(w,
00047       filename(portable::application_name()).basename(), TIMING_CYCLE);
00048   return 0;
00049 }
00050 

Generated on Fri Nov 21 04:30:15 2008 for HOOPLE Libraries by  doxygen 1.5.1