Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage interfaces #19

Merged
merged 8 commits into from
Aug 17, 2018
Merged

storage interfaces #19

merged 8 commits into from
Aug 17, 2018

Conversation

Karsten1987
Copy link
Collaborator

proposal for new storage interfaces

Copy link
Contributor

@anhosi anhosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the naming of the storage_interface:: classes: for me using e.g. 'storage_interface::ReadOnlyinstead ofstorage_interface::ReadOnlyInterface` would also be fine.

We will also need a function StorageFactory::open_for_reading(uri, io_flags) that does not require to specify the storage plugin. But this should be left for a followup pr.

public:
virtual ~BaseIOInterface() = default;
virtual void open(const std::string & uri, IOFlag io_flag) = 0;
virtual bool is_open() const = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for is_open and close when we do the closing in the destructor (more RAII style, we need the open due to pluginlib limitations. Ideally we would also do the opening in the constructor but we cannot have constructor arguments)

{
public:
virtual ~BaseReadInterface() = default;
virtual std::shared_ptr<SerializedBagMessage> read_next() = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need a virtual bool has_next() to go with read_next.

template<>
struct StorageTraits<storage_interfaces::ReadWriteInterface>
{
static constexpr storage_interfaces::IOFlag io_flag = storage_interfaces::IOFlag::READ_WRITE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see no reason for having the io_flag member of StorageTraits. Same applies the the ReadOnlyInterface below.

}

try {
instance->open(uri, flag);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opening of the storage should not happen int get_interface_instance but in the factory below. This also removes the need to have the uri argument.

{
public:
virtual ~ReadWriteInterface() = default;
void open(const std::string & uri, IOFlag io_flag = IOFlag::READ_WRITE) override = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to have no default arguments here (also for open in ReadOnlyInterface) as the value for virtual functions can be surprising (static type is relevant). There is also no real advantage as open will only be called by the storage factory where we can handle all complexities of calling open.

std::shared_ptr<ReadableStorage> get_read_only_storage(
~StorageFactoryImpl() = default;

std::shared_ptr<ReadWriteInterface> get_read_write_storage(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer open_for_writing as method name to emphasize that the factory returns an already opened storage. Regarding the arguments we should add an io_flags argument (possible with the appropriate default).
The call to open should happen here (see also above comment).

private:
bool storage_id_is_present(
std::vector<std::string> registered_classes, const std::string & storage_id)
std::shared_ptr<ReadOnlyInterface> get_read_only_storage(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the above comment I would prefer open_for_reading as method name and an additional argument io_flags.
Method body: the io_flag and uri would be used in the open call instead of the get_interface_instance (see also my above comment).


StorageFactory::~StorageFactory()
{
delete impl_;
}

std::shared_ptr<ReadWriteStorage> StorageFactory::get_read_write_storage(
ReadWriteStorageSharedPtr StorageFactory::get_read_write_storage(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My above comment regarding the names open_for_reading/writing also applies here.

@@ -25,21 +25,20 @@ namespace rosbag2_storage

StorageFactory::StorageFactory()
: impl_(new StorageFactoryImpl())
{
}
{}

StorageFactory::~StorageFactory()
{
delete impl_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer having the pimpl using an unique_ptr instead of a raw pointer.

@Karsten1987 Karsten1987 merged commit f3d6f44 into storage_interface Aug 17, 2018
@Karsten1987 Karsten1987 deleted the read_write_interfaces branch August 17, 2018 22:15
james-rms pushed a commit to james-rms/rosbag2 that referenced this pull request Nov 17, 2022
* docs: add changelog

Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp>

* 0.1.0
james-rms pushed a commit to james-rms/rosbag2 that referenced this pull request Nov 17, 2022
* docs: add changelog

Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp>

* 0.1.0

Signed-off-by: James Smith <james@foxglove.dev>
emersonknapp added a commit that referenced this pull request May 14, 2024
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants