Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
log_thread.h
1
2
/***************************************************************************
3
* log_thread.h - BB Logger Thread
4
*
5
* Created: Sat Nov 07 23:40:48 2009
6
* Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#ifndef __PLUGINS_BBLOGGER_LOG_THREAD_H_
24
#define __PLUGINS_BBLOGGER_LOG_THREAD_H_
25
26
#include <core/threading/thread.h>
27
#include <aspect/logging.h>
28
#include <aspect/configurable.h>
29
#include <aspect/blackboard.h>
30
#include <aspect/clock.h>
31
#include <blackboard/interface_listener.h>
32
33
#include <core/utils/lock_queue.h>
34
#include <core/threading/thread_list.h>
35
36
#include <cstdio>
37
38
namespace
fawkes {
39
class
BlackBoard;
40
class
Logger;
41
class
Mutex;
42
class
Time;
43
class
SwitchInterface;
44
}
45
46
class
BBLoggerThread
47
:
public
fawkes::Thread
,
48
public
fawkes::LoggingAspect
,
49
public
fawkes::ConfigurableAspect
,
50
public
fawkes::ClockAspect
,
51
public
fawkes::BlackBoardAspect
,
52
public
fawkes::BlackBoardInterfaceListener
53
{
54
public
:
55
BBLoggerThread
(
const
char
*iface_uid,
56
const
char
*logdir,
bool
buffering,
bool
flushing,
57
const
char
*scenario,
fawkes::Time
*start_time);
58
virtual
~BBLoggerThread
();
59
60
const
char
*
get_filename
()
const
;
61
void
set_threadlist
(
fawkes::ThreadList
&thread_list);
62
void
set_enabled
(
bool
enabled);
63
64
virtual
void
init
();
65
virtual
void
finalize
();
66
virtual
void
loop
();
67
68
virtual
bool
bb_interface_message_received
(
fawkes::Interface
*interface,
fawkes::Message
*message)
throw
();
69
virtual
void
bb_interface_data_changed
(
fawkes::Interface
*interface)
throw
();
70
virtual
void
bb_interface_writer_added
(
fawkes::Interface
*interface,
71
unsigned
int
instance_serial)
throw
();
72
virtual
void
bb_interface_writer_removed
(
fawkes::Interface
*interface,
73
unsigned
int
instance_serial)
throw
();
74
75
/** Stub to see name in backtrace for easier debugging. @see Thread::run() */
76
protected
:
virtual
void
run
() {
Thread::run
(); }
77
78
private
:
79
void
write_header();
80
void
update_header();
81
void
write_chunk(
const
void
*chunk);
82
83
84
private
:
85
fawkes::Interface
*__iface;
86
87
unsigned
int
__num_data_items;
88
unsigned
int
__session_start;
89
90
bool
__enabled;
91
bool
__buffering;
92
bool
__flushing;
93
size_t
__data_size;
94
char
*__scenario;
95
char
*__filename;
96
char
*__logdir;
97
char
*__uid;
98
char
*__type;
99
char
*__id;
100
FILE *__f_data;
101
FILE *__f_msgs;
102
103
fawkes::Time
*__start;
104
fawkes::Time
*__now;
105
106
bool
__is_master;
107
fawkes::ThreadList
__threads;
108
fawkes::SwitchInterface
*__switch_if;
109
110
fawkes::Mutex
*__queue_mutex;
111
unsigned
int
__act_queue;
112
fawkes::LockQueue<void *>
__queues[2];
113
};
114
115
116
#endif
src
plugins
bblogger
log_thread.h
Generated by
1.8.1.1