feisty meow concerns codebase
2.140
test_safe_callback.cpp
Go to the documentation of this file.
1
/*****************************************************************************\
2
* *
3
* Name : test_safe_callback *
4
* Author : Chris Koeritz *
5
* *
6
* Purpose: *
7
* *
8
* Tests the safe callback object slightly. Mainly this is to ensure that *
9
* no memory leaks are being caused by the object and that minimal support is *
10
* provided by the object. *
11
* *
12
*******************************************************************************
13
* Copyright (c) 1998-$now By Author. This program is free software; you can *
14
* redistribute it and/or modify it under the terms of the GNU General Public *
15
* License as published by the Free Software Foundation; either version 2 of *
16
* the License or (at your option) any later version. This is online at: *
17
* http://www.fsf.org/copyleft/gpl.html *
18
* Please send any updates to: fred@gruntose.com *
19
\*****************************************************************************/
20
21
#include <
application/hoople_main.h
>
22
#include <
basis/astring.h
>
23
#include <
basis/guards.h
>
24
#include <
configuration/application_configuration.h
>
25
#include <
loggers/critical_events.h
>
26
#include <
loggers/program_wide_logger.h
>
27
//#include <loggers/file_logger.h>
28
#include <
processes/safe_callback.h
>
29
#include <
structures/static_memory_gremlin.h
>
30
#include <
unit_test/unit_base.h
>
31
32
using namespace
application
;
33
using namespace
basis
;
34
using namespace
configuration
;
35
//using namespace mathematics;
36
//using namespace filesystem;
37
using namespace
loggers
;
38
using namespace
processes
;
39
//using namespace structures;
40
//using namespace textual;
41
using namespace
timely
;
42
using namespace
unit_test
;
43
44
#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
45
47
48
const
astring
LOGFILE_NAME
=
application_configuration::make_logfile_name
49
(
"t_safe_callback.log"
);
50
// where our debugging output goes by default.
51
53
// our macro for logging with a timestamp.
54
55
//hmmm: this tester doesn't really do very much at all.
56
// how about a more aggressive test, which has a bunch of threads using
57
// safe callback?
58
59
class
cb_tester :
public
safe_callback
60
{
61
public
:
62
cb_tester() :
safe_callback
() {}
63
~cb_tester() {
end_availability
(); }
64
65
virtual
void
real_callback
(
callback_data_block
&)
66
{
/* do nothing. */
}
67
};
68
69
//hmmm: move this to using a class based approach, based on unit_test and application_shell.
70
71
int
main
(
int
formal
(argc),
char
*
formal
(argv)[])
72
{
74
75
cb_tester testing;
76
77
critical_events::alert_message
(
"safe_callback:: works for all functions tested."
);
78
return
0;
79
}
80
application_configuration.h
astring.h
basis::astring
Provides a dynamically resizable ASCII character string.
Definition
astring.h:35
configuration::application_configuration::make_logfile_name
static basis::astring make_logfile_name(const basis::astring &base_name)
generates an installation appropriate log file name from "base_name".
Definition
application_configuration.cpp:389
loggers::critical_events::alert_message
static void alert_message(const char *info, const char *title="Alert Message")
shows the message in "info", with an optional "title" on the message.
Definition
critical_events.cpp:125
processes::callback_data_block
a simple place-holder that anonymizes the type passed to the callback.
Definition
safe_callback.h:142
processes::safe_callback
A reasonably easy way to make callbacks safe from shutdown ordering issues.
Definition
safe_callback.h:68
processes::safe_callback::real_callback
virtual void real_callback(callback_data_block &new_data)=0
derived classes implement this to provide their callback functionality.
processes::safe_callback::end_availability
void end_availability()
prepares to shut down this object.
Definition
safe_callback.cpp:136
critical_events.h
formal
#define formal(parameter)
This macro just eats what it's passed; it marks unused formal parameters.
Definition
definitions.h:48
guards.h
hoople_main.h
Provides macros that implement the 'main' program of an application.
application
Implements an application lock to ensure only one is running at once.
Definition
application_shell.cpp:40
basis
The guards collection helps in testing preconditions and reporting errors.
Definition
array.h:30
configuration
Definition
registry_config.cpp:45
loggers
A logger that sends to the console screen using the standard output device.
Definition
combo_logger.cpp:36
processes
Definition
configured_applications.cpp:33
timely
#include <time.h>
Definition
earth_time.cpp:37
unit_test
Useful support functions for unit testing, especially within hoople.
Definition
unit_base.cpp:35
program_wide_logger.h
safe_callback.h
static_memory_gremlin.h
LOGFILE_NAME
const astring LOGFILE_NAME
Definition
test_safe_callback.cpp:48
main
int main(int formal(argc), char *formal(argv)[])
Definition
test_safe_callback.cpp:71
unit_base.h
nucleus
library
tests_processes
test_safe_callback.cpp
Generated by
1.9.8