From f01582c5e213284159042d517f9296c1485f7c46 Mon Sep 17 00:00:00 2001 From: Patrick Roncagliolo Date: Thu, 26 Oct 2023 18:54:40 +0200 Subject: [PATCH] Various fixes --- .../src/rosbag2_storage_sqlite3/sqlite_storage.cpp | 9 +++++---- .../test/rosbag2_storage_sqlite3/test_sqlite_storage.cpp | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rosbag2_storage_sqlite3/src/rosbag2_storage_sqlite3/sqlite_storage.cpp b/rosbag2_storage_sqlite3/src/rosbag2_storage_sqlite3/sqlite_storage.cpp index 5b810c8bd4..d8c48d3c95 100644 --- a/rosbag2_storage_sqlite3/src/rosbag2_storage_sqlite3/sqlite_storage.cpp +++ b/rosbag2_storage_sqlite3/src/rosbag2_storage_sqlite3/sqlite_storage.cpp @@ -604,7 +604,8 @@ void SqliteStorage::fill_topics_and_types() yaml_node, metadata_.version); std::vector offered_qos_profiles; - std::copy(decoded.begin(), decoded.end(), offered_qos_profiles.begin()); + offered_qos_profiles.reserve(decoded.size()); + std::copy(decoded.begin(), decoded.end(), std::back_inserter(offered_qos_profiles)); all_topics_and_types_.push_back( { std::get<0>(result), @@ -625,7 +626,7 @@ void SqliteStorage::fill_topics_and_types() yaml_node, metadata_.version); std::vector offered_qos_profiles; - std::copy(decoded.begin(), decoded.end(), offered_qos_profiles.begin()); + std::copy(decoded.begin(), decoded.end(), std::back_inserter(offered_qos_profiles)); all_topics_and_types_.push_back( {std::get<0>(result), std::get<1>(result), std::get<2>(result), offered_qos_profiles, ""}); @@ -707,7 +708,7 @@ void SqliteStorage::read_metadata() yaml_node, metadata_.version); std::vector offered_qos_profiles; - std::copy(decoded.begin(), decoded.end(), offered_qos_profiles.begin()); + std::copy(decoded.begin(), decoded.end(), std::back_inserter(offered_qos_profiles)); metadata_.topics_with_message_count.push_back( { {std::get<0>(result), std::get<1>(result), std::get<2>( @@ -737,7 +738,7 @@ void SqliteStorage::read_metadata() yaml_node, metadata_.version); std::vector offered_qos_profiles; - std::copy(decoded.begin(), decoded.end(), offered_qos_profiles.begin()); + std::copy(decoded.begin(), decoded.end(), std::back_inserter(offered_qos_profiles)); metadata_.topics_with_message_count.push_back( { {std::get<0>(result), std::get<1>(result), std::get<2>( diff --git a/rosbag2_storage_sqlite3/test/rosbag2_storage_sqlite3/test_sqlite_storage.cpp b/rosbag2_storage_sqlite3/test/rosbag2_storage_sqlite3/test_sqlite_storage.cpp index 4b418992f0..9070d85bae 100644 --- a/rosbag2_storage_sqlite3/test/rosbag2_storage_sqlite3/test_sqlite_storage.cpp +++ b/rosbag2_storage_sqlite3/test/rosbag2_storage_sqlite3/test_sqlite_storage.cpp @@ -191,7 +191,7 @@ TEST_F(StorageTestFixture, get_all_topics_and_types_returns_the_correct_vector) topics_and_types, ElementsAreArray( { rosbag2_storage::TopicMetadata{"topic1", "type1", "rmw1", {rclcpp::QoS(1)}, "type_hash1"}, - rosbag2_storage::TopicMetadata{"topic2", "type2", "rmw2", {rclcpp::QoS(1)}, "type_hash2"} + rosbag2_storage::TopicMetadata{"topic2", "type2", "rmw2", {rclcpp::QoS(2)}, "type_hash2"} })); } @@ -269,7 +269,7 @@ TEST_F(StorageTestFixture, get_metadata_returns_correct_struct) { rosbag2_storage::TopicInformation{rosbag2_storage::TopicMetadata{ "topic1", "type1", "rmw1", {rclcpp::QoS(1)}, "type_hash1"}, 2u}, rosbag2_storage::TopicInformation{rosbag2_storage::TopicMetadata{ - "topic2", "type2", "rmw2", {rclcpp::QoS(1)}, "type_hash2"}, 1u} + "topic2", "type2", "rmw2", {rclcpp::QoS(2)}, "type_hash2"}, 1u} })); EXPECT_THAT(metadata.message_count, Eq(3u)); EXPECT_THAT(