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
30using namespace application;
31using namespace basis;
32using namespace configuration;
33//using namespace mathematics;
34using namespace filesystem;
35using namespace loggers;
36//using namespace processes;
37//using namespace structures;
38//using namespace textual;
39using namespace timely;
40using 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
47const int TIMING_CYCLE = 1408;
48 // how frequently timer should be hit.
49
50class my_anchor : public shutdown_alerter
51{
52public:
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
62int main(int formal(argc), char *formal(argv)[])
63{
64//hmmm: skipping since we crash currently. fix this!
65return 0;
66
67 my_anchor w;
68 BASE_LOG(a_sprintf("timer will hit every %d ms.", TIMING_CYCLE));
71 BASE_LOG("after creating the alerter's console app...");
72BASE_LOG("still here, but about to exit... kaboom?");
73 return 0;
74}
75
#define BASE_LOG(s)
a_sprintf is a specialization of astring that provides printf style support.
Definition astring.h:440
static basis::astring application_name()
returns the full name of the current application.
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.
virtual void handle_timer()
called periodically if a timer period was specified.
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.
virtual void handle_startup()
this function is called once the program has begun operation.
virtual void handle_shutdown()
called during the program's shutdown process.
#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
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
#include <time.h>
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)