Class BaseWriteInterface
Defined in File base_write_interface.hpp
Inheritance Relationships
Derived Type
public rosbag2_storage::storage_interfaces::ReadWriteInterface(Class ReadWriteInterface)
Class Documentation
-
class BaseWriteInterface
The base interface for writing messages to storage.
Subclassed by rosbag2_storage::storage_interfaces::ReadWriteInterface
Public Functions
-
virtual ~BaseWriteInterface() = default
Default destructor.
Writes one serialized message to the storage.
- Throws:
std::runtime_error – if the storage is not open, or if create_topic(..) was not called previously for the topic associated with the message being written.
Writes one serialized message to the storage.
- Parameters:
msg – - The serialized message to write.
- Throws:
std::runtime_error – if the storage is not open, or if create_topic(..) was not called previously for the topic associated with the message being written.
- Returns:
Returns true if the message was written successfully, false otherwise.
-
virtual std::vector<size_t> write_messages(const SerializedBagMessages &messages) = 0
Write a batch of messages to the storage.
- Parameters:
messages – - List of serialized messages to write.
- Throws:
std::runtime_error – if the storage is not open or if create_topic(..) has not been called for all topics in the messages list.
- Returns:
Returns a vector of indexes pointing to the messages from the input list that were not written. If all messages were written successfully, the vector will be empty.
-
virtual void update_metadata(const BagMetadata &bag_metadata) = 0
Writes provided metadata to the storage i.e. bag file.
- Parameters:
bag_metadata – - Metadata to be written to the storage.
-
virtual void create_topic(const TopicMetadata &topic, const rosbag2_storage::MessageDefinition &message_definition) = 0
Creates a new topic in the storage. Needs to be called for every topic used within a.
message which is passed to write_message(…) or write_messages(…).
- Parameters:
topic – - Metadata of the topic to create.
message_definition – - rosbag2_storage::MessageDefinition containing the full encoded message definition for this type and the type hash.
- Throws:
std::runtime_error – if the storage is not open.
-
virtual void remove_topic(const TopicMetadata &topic) = 0
Removes a topic from the internal storage references. This does not remove the topic from the bag file, but removes it from the internal references so that it is not written to the bag file in the future. This is an opposite to create_topic, which adds a topic to the internal storage references.
- Parameters:
topic – - Metadata of the topic to remove.
-
virtual ~BaseWriteInterface() = default