feisty meow concerns codebase  2.140
test_shutdown_alerter.cpp
Go to the documentation of this file.
1 /*****************************************************************************\
2 * *
3 * Name : t_shutdown_alerter *
4 * Author : Chris Koeritz *
5 * *
6 * Purpose: *
7 * *
8 * An example of using the shutdown_alerter object to manage the runtime *
9 * of a program. *
10 * *
11 *******************************************************************************
12 * Copyright (c) 2005-$now By Author. This program is free software; you can *
13 * redistribute it and/or modify it under the terms of the GNU General Public *
14 * License as published by the Free Software Foundation; either version 2 of *
15 * the License or (at your option) any later version. This is online at: *
16 * http://www.fsf.org/copyleft/gpl.html *
17 * Please send any updates to: fred@gruntose.com *
18 \*****************************************************************************/
19 
20 #include <basis/astring.h>
22 #include <filesystem/filename.h>
26 #include <unit_test/unit_base.h>
27 
28 //hmmm: make this use the unit_base so its a real test app.
29 
30 using namespace application;
31 using namespace basis;
32 using namespace configuration;
33 //using namespace mathematics;
34 using namespace filesystem;
35 using namespace loggers;
36 //using namespace processes;
37 //using namespace structures;
38 //using namespace textual;
39 using namespace timely;
40 using namespace unit_test;
41 
43 
44 #define BASE_LOG(s) STAMPED_EMERGENCY_LOG(program_wide_logger::get(), s)
45 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
46 
47 const int TIMING_CYCLE = 1408;
48  // how frequently timer should be hit.
49 
50 class my_anchor : public shutdown_alerter
51 {
52 public:
53  virtual void handle_startup() { BASE_LOG("into startup..."); }
54  virtual void handle_shutdown() { BASE_LOG("into shutdown..."); }
55  virtual void handle_timer() { BASE_LOG("into timer..."); }
56 };
57 
58 //hmmm: what is this test intended to actually do, or test?
59 // all it does right now is created the shutdown alerter object...
60 // and then it never seems to try to shut it down!???
61 
62 int main(int formal(argc), char *formal(argv)[])
63 {
64 //hmmm: skipping since we crash currently. fix this!
65 return 0;
66 
67  my_anchor w;
68  BASE_LOG(a_sprintf("timer will hit every %d ms.", TIMING_CYCLE));
70  filename(application_configuration::application_name()).basename(), TIMING_CYCLE);
71  BASE_LOG("after creating the alerter's console app...");
72 BASE_LOG("still here, but about to exit... kaboom?");
73  return 0;
74 }
75 
a_sprintf is a specialization of astring that provides printf style support.
Definition: astring.h:440
Provides operations commonly needed on file names.
Definition: filename.h:64
A platform-independent way to alert a program that it should shut down immediately.
static bool launch_console(shutdown_alerter &alert, const basis::astring &app_name, int timer_period=0)
this is used to begin execution of a console mode application.
#define formal(parameter)
This macro just eats what it's passed; it marks unused formal parameters.
Definition: definitions.h:48
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
str basename(str pathname)
A platform independent way to obtain the timestamp of a file.
Definition: byte_filer.cpp:37
A logger that sends to the console screen using the standard output device.
#include <time.h>
Definition: earth_time.cpp:37
Useful support functions for unit testing, especially within hoople.
Definition: unit_base.cpp:35
const int TIMING_CYCLE
int main(int formal(argc), char *formal(argv)[])
#define BASE_LOG(s)