Scarab
v2.4.9
Project 8 C++ Utility Library
library
test
test_app_with_callback.cc
Go to the documentation of this file.
1
/*
2
* test_app_with_callback.cc
3
*
4
* Created on: Jul 24, 2018
5
* Author: N.S. Oblath
6
* Output examples:
7
*
8
> bin/test_app_with_callback
9
2018-07-24 11:40:07 [ PROG] (tid 0x7fff9c9dc380) i/application.cc(92): Final configuration:
10
11
{
12
}
13
14
2018-07-24 11:40:07 [ PROG] (tid 0x7fff9c9dc380) i/application.cc(93): Ordered args:
15
16
[
17
]
18
19
2018-07-24 11:40:07 [ PROG] (tid 0x7fff9c9dc380) with_callback.cc(27): My value is: 5
20
21
22
> bin/test_app_with_callback value=10
23
24
2018-07-24 11:40:49 [ PROG] (tid 0x7fff9c9dc380) i/application.cc(92): Final configuration:
25
26
{
27
value : 10
28
}
29
30
2018-07-24 11:40:49 [ PROG] (tid 0x7fff9c9dc380) i/application.cc(93): Ordered args:
31
32
[
33
]
34
35
2018-07-24 11:40:49 [ PROG] (tid 0x7fff9c9dc380) with_callback.cc(27): My value is: 10
36
*
37
*/
38
39
#include "
application.hh
"
40
41
#include "
logger.hh
"
42
43
LOGGER
( testlog,
"test_app_with_callback"
);
44
45
namespace
scarab
46
{
47
struct
do_a_thing
48
{
49
do_a_thing
() :
f_value
( 5 ) {}
50
51
void
execute
(
const
main_app
& an_app )
52
{
53
// configure to run
54
f_value
= an_app.master_config().get_value(
"value"
,
f_value
);
55
56
// do a thing!
57
LPROG
( testlog,
"My value is: "
<<
f_value
);
58
59
return
;
60
}
61
62
int
f_value
;
63
};
64
}
65
66
67
using namespace
scarab
;
68
69
int
main
(
int
argc,
char
**argv )
70
{
71
main_app
the_main;
72
73
auto
t_dat_callback = [&](){
74
do_a_thing
t_dat;
75
t_dat.
execute
( the_main );
76
};
77
78
the_main.callback( t_dat_callback );
79
80
CLI11_PARSE( the_main, argc, argv );
81
82
return
0;
83
}
84
85
scarab::do_a_thing
Definition:
test_app_with_callback.cc:47
scarab::do_a_thing::execute
void execute(const main_app &an_app)
Definition:
test_app_with_callback.cc:51
main
int main(int argc, char **argv)
Definition:
test_app_with_callback.cc:69
LPROG
#define LPROG(...)
Definition:
logger.hh:368
scarab::do_a_thing::do_a_thing
do_a_thing()
Definition:
test_app_with_callback.cc:49
scarab
Definition:
authentication.cc:18
LOGGER
LOGGER(testlog, "test_app_with_callback")
logger.hh
Contains the logger class and macros, based on Kasper's KLogger class.
scarab::do_a_thing::f_value
int f_value
Definition:
test_app_with_callback.cc:62
application.hh
scarab::main_app
Primary application class.
Definition:
application.hh:252
Generated by
1.8.13