Apollo  6.0
Open source self driving car software
Public Types | Public Member Functions | List of all members
apollo::cyber::record::RecordWriter Class Reference

The record writer. More...

#include <record_writer.h>

Inheritance diagram for apollo::cyber::record::RecordWriter:
Inheritance graph
Collaboration diagram for apollo::cyber::record::RecordWriter:
Collaboration graph

Public Types

using MessageNumberMap = std::unordered_map< std::string, uint64_t >
 
using MessageTypeMap = std::unordered_map< std::string, std::string >
 
using MessageProtoDescMap = std::unordered_map< std::string, std::string >
 
using FileWriterPtr = std::unique_ptr< RecordFileWriter >
 

Public Member Functions

 RecordWriter ()
 The default constructor. More...
 
 RecordWriter (const proto::Header &header)
 The constructor with record header as parameter. More...
 
virtual ~RecordWriter ()
 Virtual Destructor. More...
 
bool Open (const std::string &file)
 Open a record to write. More...
 
void Close ()
 Clean the record. More...
 
bool WriteChannel (const std::string &channel_name, const std::string &message_type, const std::string &proto_desc)
 Write a channel to record. More...
 
template<typename MessageT >
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. More...
 
bool SetSizeOfFileSegmentation (uint64_t size_kilobytes)
 Set max size (KB) to segment record file. More...
 
bool SetIntervalOfFileSegmentation (uint64_t time_sec)
 Set max interval (Second) to segment record file. More...
 
uint64_t GetMessageNumber (const std::string &channel_name) const override
 Get message number by channel name. More...
 
const std::string & GetMessageType (const std::string &channel_name) const override
 Get message type by channel name. More...
 
const std::string & GetProtoDesc (const std::string &channel_name) const override
 Get proto descriptor string by channel name. More...
 
std::set< std::string > GetChannelList () const override
 Get channel list. More...
 
bool IsNewChannel (const std::string &channel_name) const
 Is a new channel recording or not. More...
 
template<>
bool WriteMessage (const std::string &channel_name, const std::string &message, const uint64_t time_nanosec, const std::string &proto_desc)
 
template<>
bool WriteMessage (const std::string &channel_name, const std::shared_ptr< message::RawMessage > &message, const uint64_t time_nanosec, const std::string &proto_desc)
 
- Public Member Functions inherited from apollo::cyber::record::RecordBase
virtual ~RecordBase ()=default
 Destructor. More...
 
const proto::Header & GetHeader () const
 Get record header. More...
 
const std::string GetFile () const
 Get record file path. More...
 

Additional Inherited Members

- Protected Attributes inherited from apollo::cyber::record::RecordBase
std::string file_
 
proto::Header header_
 
bool is_opened_ = false
 

Detailed Description

The record writer.

Member Typedef Documentation

◆ FileWriterPtr

◆ MessageNumberMap

using apollo::cyber::record::RecordWriter::MessageNumberMap = std::unordered_map<std::string, uint64_t>

◆ MessageProtoDescMap

using apollo::cyber::record::RecordWriter::MessageProtoDescMap = std::unordered_map<std::string, std::string>

◆ MessageTypeMap

using apollo::cyber::record::RecordWriter::MessageTypeMap = std::unordered_map<std::string, std::string>

Constructor & Destructor Documentation

◆ RecordWriter() [1/2]

apollo::cyber::record::RecordWriter::RecordWriter ( )

The default constructor.

◆ RecordWriter() [2/2]

apollo::cyber::record::RecordWriter::RecordWriter ( const proto::Header &  header)
explicit

The constructor with record header as parameter.

Parameters
header

◆ ~RecordWriter()

virtual apollo::cyber::record::RecordWriter::~RecordWriter ( )
virtual

Virtual Destructor.

Member Function Documentation

◆ Close()

void apollo::cyber::record::RecordWriter::Close ( )

Clean the record.

◆ GetChannelList()

std::set<std::string> apollo::cyber::record::RecordWriter::GetChannelList ( ) const
overridevirtual

Get channel list.

Returns
List container with all channel name string.

Implements apollo::cyber::record::RecordBase.

◆ GetMessageNumber()

uint64_t apollo::cyber::record::RecordWriter::GetMessageNumber ( const std::string &  channel_name) const
overridevirtual

Get message number by channel name.

Parameters
channel_name
Returns
Message number.

Implements apollo::cyber::record::RecordBase.

◆ GetMessageType()

const std::string& apollo::cyber::record::RecordWriter::GetMessageType ( const std::string &  channel_name) const
overridevirtual

Get message type by channel name.

Parameters
channel_name
Returns
Message type.

Implements apollo::cyber::record::RecordBase.

◆ GetProtoDesc()

const std::string& apollo::cyber::record::RecordWriter::GetProtoDesc ( const std::string &  channel_name) const
overridevirtual

Get proto descriptor string by channel name.

Parameters
channel_name
Returns
Proto descriptor string by channel name.

Implements apollo::cyber::record::RecordBase.

◆ IsNewChannel()

bool apollo::cyber::record::RecordWriter::IsNewChannel ( const std::string &  channel_name) const

Is a new channel recording or not.

Returns
True for yes, false for no.

◆ Open()

bool apollo::cyber::record::RecordWriter::Open ( const std::string &  file)

Open a record to write.

Parameters
file
Returns
True for success, false for fail.

◆ SetIntervalOfFileSegmentation()

bool apollo::cyber::record::RecordWriter::SetIntervalOfFileSegmentation ( uint64_t  time_sec)

Set max interval (Second) to segment record file.

Parameters
time_sec
Returns
True for success, false for fail.

◆ SetSizeOfFileSegmentation()

bool apollo::cyber::record::RecordWriter::SetSizeOfFileSegmentation ( uint64_t  size_kilobytes)

Set max size (KB) to segment record file.

Parameters
size_kilobytes
Returns
True for success, false for fail.

◆ WriteChannel()

bool apollo::cyber::record::RecordWriter::WriteChannel ( const std::string &  channel_name,
const std::string &  message_type,
const std::string &  proto_desc 
)

Write a channel to record.

Parameters
channel_name
message_type
proto_desc
Returns
True for success, false for fail.

◆ WriteMessage() [1/3]

template<typename MessageT >
bool apollo::cyber::record::RecordWriter::WriteMessage ( const std::string &  channel_name,
const MessageT &  message,
const uint64_t  time_nanosec,
const std::string &  proto_desc = "" 
)

Write a message to record.

Template Parameters
MessageT
Parameters
channel_name
message
time_nanosec
proto_desc
Returns
True for success, false for fail.

◆ WriteMessage() [2/3]

template<>
bool apollo::cyber::record::RecordWriter::WriteMessage ( const std::string &  channel_name,
const std::string &  message,
const uint64_t  time_nanosec,
const std::string &  proto_desc 
)
inline

◆ WriteMessage() [3/3]

template<>
bool apollo::cyber::record::RecordWriter::WriteMessage ( const std::string &  channel_name,
const std::shared_ptr< message::RawMessage > &  message,
const uint64_t  time_nanosec,
const std::string &  proto_desc 
)
inline

The documentation for this class was generated from the following file: