Read and write LCM log files.
More...
#include <lcm/lcm-cpp.hpp>
Read and write LCM log files.
This class is the C++ counterpart for lcm_eventlog_t.
- See also
- lcm_eventlog_t
◆ LogFile()
lcm::LogFile::LogFile |
( |
const std::string & |
path, |
|
|
const std::string & |
mode |
|
) |
| |
|
inline |
Constructor. Opens the specified log file for reading or writing.
- Parameters
-
path | the file to open |
mode | "r" (read mode) or "w" (write mode) |
- See also
- lcm_eventlog_create()
◆ ~LogFile()
lcm::LogFile::~LogFile |
( |
| ) |
|
|
inline |
Destructor. Closes the log file.
◆ getFilePtr()
FILE* lcm::LogFile::getFilePtr |
( |
| ) |
|
|
inline |
retrives the underlying FILE* wrapped by this class.
This method should be used carefully and sparingly. An example use-case is borrowing to tweak the behavior of the I/O. Calls of interest include fflush(), fileno(), setvbuf(), etc It is a bad idea to attempt reading or writing on the raw FILE*
- Returns
- the FILE* wrapped by this object.
◆ good()
bool lcm::LogFile::good |
( |
| ) |
const |
|
inline |
- Returns
- true if the log file is ready for reading/writing.
◆ readNextEvent()
const LogEvent* lcm::LogFile::readNextEvent |
( |
| ) |
|
|
inline |
Reads the next event in the log file. Valid in read mode only.
The LogFile class manages the memory of the read event. The returned event is valid until the next call to this method.
- Returns
- the next event, or NULL if the end of the log file has been reached.
◆ seekToTimestamp()
int lcm::LogFile::seekToTimestamp |
( |
int64_t |
timestamp | ) |
|
|
inline |
Seek close to the specified timestamp in the log file. Valid in read mode only.
- Parameters
-
timestamp | the desired seek point in the log file. |
- Returns
- 0 on success, -1 on error.
- See also
- lcm_eventlog_seek_to_timestamp()
◆ writeEvent()
int lcm::LogFile::writeEvent |
( |
LogEvent * |
event | ) |
|
|
inline |
Writes an event to the log file. Valid in write mode only.
- Parameters
-
event | the event to write. The timestamp, channel, datalen, and data fields should be filled in. The eventnum field will be automatically filled in. |
- Returns
- 0 on success, -1 on error.
- See also
- lcm_eventlog_write_event()
The documentation for this class was generated from the following file: