17#ifndef PYTHON_WRAPPER_PY_RECORD_H_
18#define PYTHON_WRAPPER_PY_RECORD_H_
33#include "cyber/proto/record.pb.h"
57 uint64_t begin_time = 0,
58 uint64_t end_time = std::numeric_limits<uint64_t>::max()) {
61 if (!record_reader_->ReadMessage(&record_message, begin_time, end_time)) {
71 record_reader_->GetMessageType(record_message.
channel_name);
76 return record_reader_->GetMessageNumber(channel_name);
80 return record_reader_->GetMessageType(channel_name);
84 return record_reader_->GetProtoDesc(channel_name);
89 record_reader_->GetHeader().SerializeToString(&org_data);
93 void Reset() { record_reader_->Reset(); }
96 return record_reader_->GetChannelList();
100 std::unique_ptr<RecordReader> record_reader_;
105 bool Open(
const std::string& path) {
return record_writer_.
Open(path); }
109 bool WriteChannel(
const std::string& channel_str,
const std::string& type,
110 const std::string& proto_desc) {
111 return record_writer_.
WriteChannel(channel_str, type, proto_desc);
115 const std::string& rawmessage, uint64_t time,
116 const std::string& proto_desc =
"") {
118 channel_name, std::make_shared<message::RawMessage>(rawmessage), time,
138 const std::string&
GetProtoDesc(
const std::string& channel_name)
const {
std::string GetProtoDesc(const std::string &channel_name)
std::string GetMessageType(const std::string &channel_name)
PyRecordReader(const std::string &file)
std::string GetHeaderString()
std::set< std::string > GetChannelList() const
BagMessage ReadMessage(uint64_t begin_time=0, uint64_t end_time=std::numeric_limits< uint64_t >::max())
uint64_t GetMessageNumber(const std::string &channel_name)
bool WriteChannel(const std::string &channel_str, const std::string &type, const std::string &proto_desc)
const std::string & GetProtoDesc(const std::string &channel_name) const
bool WriteMessage(const std::string &channel_name, const std::string &rawmessage, uint64_t time, const std::string &proto_desc="")
uint64_t GetMessageNumber(const std::string &channel_name) const
bool Open(const std::string &path)
bool SetSizeOfFileSegmentation(uint64_t size_kilobytes)
const std::string & GetMessageType(const std::string &channel_name) const
bool SetIntervalOfFileSegmentation(uint64_t time_sec)
uint64_t GetMessageNumber(const std::string &channel_name) const override
Get message number by channel name.
const std::string & GetProtoDesc(const std::string &channel_name) const override
Get proto descriptor string by channel name.
bool SetIntervalOfFileSegmentation(uint64_t time_sec)
Set max interval (Second) to segment record file.
bool SetSizeOfFileSegmentation(uint64_t size_kilobytes)
Set max size (KB) to segment record file
bool Open(const std::string &file)
Open a record to write.
bool WriteMessage(const std::string &channel_name, const MessageT &message, const uint64_t time_nanosec, const std::string &proto_desc="")
Write a message to record.
const std::string & GetMessageType(const std::string &channel_name) const override
Get message type by channel name.
void Close()
Clean the record.
bool WriteChannel(const std::string &channel_name, const std::string &message_type, const std::string &proto_desc)
Write a channel to record.
Basic data struct of record message.
std::string content
The content of the message.
uint64_t time
The time (nanosecond) of the message.
std::string channel_name
The channel name of the message.