Fawkes API
Fawkes Development Version
bblogfile.h
1
2
/***************************************************************************
3
* bblogfile.h - BlackBoard log file access convenience class
4
*
5
* Created: Sun Feb 21 11:12:47 2010
6
* Copyright 2006-2010 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_BBLOGFILE_H_
24
#define __PLUGINS_BBLOGGER_BBLOGFILE_H_
25
26
#include "file.h"
27
28
#include <core/exceptions/software.h>
29
#include <utils/time/time.h>
30
31
#include <cstdio>
32
33
namespace
fawkes
{
34
class
Interface;
35
class
BlackBoardInstanceFactory;
36
}
37
38
class
BBLogFile
{
39
public
:
40
BBLogFile
(
const
char
*filename,
bool
do_sanity_check);
41
BBLogFile
(
const
char
*filename,
fawkes::Interface
*interface = NULL,
42
bool
do_sanity_check =
true
);
43
~
BBLogFile
();
44
45
bool
has_next();
46
void
read_next();
47
void
read_index(
unsigned
int
index);
48
const
fawkes::Time
& entry_offset()
const
;
49
void
print_entry(FILE *outf = stdout);
50
51
void
rewind();
52
53
void
set_num_entries(
size_t
num_entries);
54
void
print_info(
const
char
*line_prefix =
""
, FILE *outf = stdout);
55
56
// Header information
57
uint32_t file_version()
const
;
58
bool
is_big_endian()
const
;
59
uint32_t num_data_items()
const
;
60
const
char
* scenario()
const
;
61
const
char
* interface_type()
const
;
62
const
char
* interface_id()
const
;
63
unsigned
char
* interface_hash()
const
;
64
uint32_t data_size();
65
fawkes::Time
& start_time();
66
67
size_t
file_size()
const
;
68
unsigned
int
remaining_entries();
69
70
static
void
repair_file(
const
char
*filename);
71
72
void
set_interface(
fawkes::Interface
*interface);
73
fawkes::Interface
* interface();
74
75
/** Get typed interface.
76
* @param iface will assigned to the interface on success
77
* @return interface of the given type
78
* @exception TypeMismatchException thrown if interface type or ID do not match
79
*/
80
template
<
class
IT>
81
IT *
interface
(IT*& iface = 0)
const
82
{
83
IT *rv =
dynamic_cast<
IT *
>
(__interface);
84
if
(rv) {
85
iface = rv;
86
return
rv;
87
}
else
{
88
throw
fawkes::TypeMismatchException
(
"Interface types do not match."
);
89
}
90
}
91
92
private
:
// methods
93
void
ctor(
const
char
*filename,
bool
do_sanity_check);
94
void
read_file_header();
95
void
sanity_check();
96
void
repair();
97
98
99
private
:
// members
100
FILE *__f;
101
bblog_file_header
*__header;
102
103
void
*__ifdata;
104
105
char
*__filename;
106
char
*__scenario;
107
char
*__interface_type;
108
char
*__interface_id;
109
110
fawkes::Interface
*__interface;
111
fawkes::BlackBoardInstanceFactory
*__instance_factory;
112
fawkes::Time
__start_time;
113
fawkes::Time
__entry_offset;
114
};
115
116
117
#endif
fawkes::TypeMismatchException
Type mismatch.
Definition:
software.h:46
fawkes::BlackBoardInstanceFactory
BlackBoard instance factory.
Definition:
instance_factory.h:36
bblog_file_header
BBLogger file header definition.
Definition:
file.h:53
fawkes
Fawkes library namespace.
BBLogFile::interface
IT * interface(IT *&iface=0) const
Get typed interface.
Definition:
bblogfile.h:81
fawkes::Time
A class for handling time.
Definition:
time.h:91
fawkes::Interface
Base class for all Fawkes BlackBoard interfaces.
Definition:
interface.h:79
BBLogFile
Class to easily access bblogger log files.
Definition:
bblogfile.h:38
src
plugins
bblogger
bblogfile.h
Generated by
1.8.13