Fawkes API
Fawkes Development Version
|
Class to easily access bblogger log files. More...
#include "bblogfile.h"
Public Member Functions | |
BBLogFile (const char *filename, bool do_sanity_check) | |
Constructor. More... | |
BBLogFile (const char *filename, fawkes::Interface *interface=NULL, bool do_sanity_check=true) | |
Constructor. More... | |
~BBLogFile () | |
Destructor. More... | |
bool | has_next () |
Check if another entry is available. More... | |
void | read_next () |
Read next entry. More... | |
void | read_index (unsigned int index) |
Read entry at particular index. More... | |
const fawkes::Time & | entry_offset () const |
Get current entry offset. More... | |
void | print_entry (FILE *outf=stdout) |
Print an entry. More... | |
void | rewind () |
Rewind file to start. More... | |
void | set_num_entries (size_t num_entries) |
Set number of entries. More... | |
void | print_info (const char *line_prefix="", FILE *outf=stdout) |
Print file meta info. More... | |
uint32_t | file_version () const |
Get file version. More... | |
bool | is_big_endian () const |
Check if file is big endian. More... | |
uint32_t | num_data_items () const |
Get number of data items in file. More... | |
const char * | scenario () const |
Get scenario identifier. More... | |
const char * | interface_type () const |
Get interface type. More... | |
const char * | interface_id () const |
Get interface ID. More... | |
unsigned char * | interface_hash () const |
Get interface hash. More... | |
uint32_t | data_size () |
Get data size. More... | |
fawkes::Time & | start_time () |
Get start time. More... | |
size_t | file_size () const |
Get file size. More... | |
unsigned int | remaining_entries () |
Get number of remaining entries. More... | |
void | set_interface (fawkes::Interface *interface) |
Set the internal interface. More... | |
fawkes::Interface * | interface () |
Get interface instance. More... | |
template<class IT > | |
IT * | interface (IT *&iface=0) const |
Get typed interface. More... | |
Static Public Member Functions | |
static void | repair_file (const char *filename) |
Repair file. More... | |
Class to easily access bblogger log files.
This class provides an easy way to interact with bblogger log files.
Definition at line 38 of file bblogfile.h.
BBLogFile::BBLogFile | ( | const char * | filename, |
bool | do_sanity_check | ||
) |
Constructor.
Opens the given file and performs basic sanity checks. No internal interface is created. You must take care to set it using set_interface() before any reading is done.
filename | log file to open |
do_sanity_check | true to perform a sanity check on the file on opening. Turn this off only if you know what you are doing. |
CouldNotOpenFileException | thrown if file cannot be opened |
FileReadException | some error occured while reading data from |
Definition at line 101 of file bblogfile.cpp.
BBLogFile::BBLogFile | ( | const char * | filename, |
fawkes::Interface * | interface = NULL , |
||
bool | do_sanity_check = true |
||
) |
Constructor.
Opens the given file and performs basic sanity checks.
filename | log file to open |
interface | optional interface instance which must match the data from the log file. Read methods will store read data in this interface instance. If no interface is given an instance is created that is not tied to a blackboard. |
do_sanity_check | true to perform a sanity check on the file on opening. Turn this off only if you know what you are doing. |
CouldNotOpenFileException | thrown if file cannot be opened |
FileReadException | some error occured while reading data from |
Definition at line 65 of file bblogfile.cpp.
BBLogFile::~BBLogFile | ( | ) |
Destructor.
Definition at line 137 of file bblogfile.cpp.
References fawkes::Exception::set_type_id().
uint32_t BBLogFile::data_size | ( | ) |
Get data size.
Definition at line 594 of file bblogfile.cpp.
const fawkes::Time & BBLogFile::entry_offset | ( | ) | const |
Get current entry offset.
Definition at line 514 of file bblogfile.cpp.
Referenced by BBLogReplayThread::loop(), and BBLogReplayThread::once().
size_t BBLogFile::file_size | ( | ) | const |
Get file size.
Definition at line 633 of file bblogfile.cpp.
References fawkes::Exception::set_type_id().
uint32_t BBLogFile::file_version | ( | ) | const |
bool BBLogFile::has_next | ( | ) |
Check if another entry is available.
Definition at line 267 of file bblogfile.cpp.
Referenced by BBLogReplayThread::init(), BBLogReplayThread::loop(), and BBLogReplayThread::once().
fawkes::Interface * BBLogFile::interface | ( | ) |
Get interface instance.
Definition at line 480 of file bblogfile.cpp.
|
inline |
Get typed interface.
iface | will assigned to the interface on success |
TypeMismatchException | thrown if interface type or ID do not match |
Definition at line 81 of file bblogfile.h.
unsigned char * BBLogFile::interface_hash | ( | ) | const |
Get interface hash.
Hash of logged interface.
Definition at line 584 of file bblogfile.cpp.
const char * BBLogFile::interface_id | ( | ) | const |
Get interface ID.
Definition at line 573 of file bblogfile.cpp.
Referenced by BBLogReplayThread::init().
const char * BBLogFile::interface_type | ( | ) | const |
Get interface type.
Definition at line 563 of file bblogfile.cpp.
Referenced by BBLogReplayThread::init().
bool BBLogFile::is_big_endian | ( | ) | const |
Check if file is big endian.
Definition at line 534 of file bblogfile.cpp.
uint32_t BBLogFile::num_data_items | ( | ) | const |
Get number of data items in file.
Definition at line 543 of file bblogfile.cpp.
void BBLogFile::print_entry | ( | FILE * | outf = stdout | ) |
Print an entry.
Verbose print of a single entry.
outf | file handle to print to |
Definition at line 453 of file bblogfile.cpp.
void BBLogFile::print_info | ( | const char * | line_prefix = "" , |
FILE * | outf = stdout |
||
) |
Print file meta info.
line_prefix | a prefix printed before each line |
outf | file handle to print to |
Definition at line 415 of file bblogfile.cpp.
void BBLogFile::read_index | ( | unsigned int | index | ) |
Read entry at particular index.
index | index of entry, 0-based |
Definition at line 237 of file bblogfile.cpp.
void BBLogFile::read_next | ( | ) |
Read next entry.
Exception | thrown if reading fails, for example because no more entries are left. |
Definition at line 284 of file bblogfile.cpp.
References bblog_entry_header::rel_time_sec, and bblog_entry_header::rel_time_usec.
Referenced by BBLogReplayThread::loop(), and BBLogReplayThread::once().
unsigned int BBLogFile::remaining_entries | ( | ) |
Get number of remaining entries.
Definition at line 614 of file bblogfile.cpp.
|
static |
Repair file.
filename | file to repair |
Definition at line 327 of file bblogfile.cpp.
References fawkes::Exception::append(), and fawkes::Exception::set_type_id().
void BBLogFile::rewind | ( | ) |
Rewind file to start.
This moves the file cursor immediately before the first entry.
Definition at line 254 of file bblogfile.cpp.
Referenced by BBLogReplayThread::loop().
const char * BBLogFile::scenario | ( | ) | const |
void BBLogFile::set_interface | ( | fawkes::Interface * | interface | ) |
Set the internal interface.
interface | an interface matching the type and ID given in the log file. |
Definition at line 491 of file bblogfile.cpp.
References fawkes::Interface::hash(), fawkes::Interface::id(), and fawkes::Interface::type().
Referenced by BBLogReplayThread::init().
void BBLogFile::set_num_entries | ( | size_t | num_entries | ) |
Set number of entries.
Set the number of entries in the file. Attention, this is only to be used by the repair() method.
num_entries | number of entries |
Definition at line 304 of file bblogfile.cpp.
References bblog_file_header::num_data_items.
fawkes::Time & BBLogFile::start_time | ( | ) |