forked from ros2/rclcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use serialized message directly (ros2#24)
* Adapt new interface * Try to write and read rcutils_char_array_t BLOBs in sqlite * Add simple test for arbitrary char ptr * Refactor SqliteWrapper and add tests * Write and read actual timestamp from serialized message and add relative tests * Add SqliteStatementWrapper class and refactor SqliteStorage and SqliteWrapper * Refactor test fixture * ros2GH-50 Assert message content in write_integration_test, and remove TODOs * ros2GH-50 Remove sqlite_storage_plugin unit tests * ros2GH-50 Refactor SqliteStatements and SqliteStorage * ros2GH-50 Fix build after rebase * ros2GH-50 Make has_next() method no more const * ros2GH-52 Extend statement wrapper with a generic bind * ros2GH-50 Refactor after rebase * ros2GH-59 cleanup db interface - Remove virtual on methods as this was added only for unit tests. We decided to use only integration tests for the sqlite plugins. - Changes semantics of SqliteStatement: represents always a prepared statement if not null. - Ensures that a SqliteStatementWrapper cannot be copied and does not publicly expose its sqlite_stmt as this would cause memory corruption. * ros2GH-59 Introduce general read interface for sqlite statements - Uses a std::tuple for row data - Exposes an iterator interface for the query result * ros2GH-59 Cleanup: remove unused files * ros2GH-59 make sqlite interface fluent * ros2GH-59 move creation of serialized message to rosbag2_storage This is not storage plugin specific but will be needed by most (if not all) plugins. * Change rcutil_char_array_t to rmw_serialized_message_t in subscriber * Remove debugging output in test
- Loading branch information
1 parent
fb3c664
commit 3f77b33
Showing
25 changed files
with
940 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2018 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef ROSBAG2_STORAGE__ROS_HELPER_HPP_ | ||
#define ROSBAG2_STORAGE__ROS_HELPER_HPP_ | ||
|
||
#include <memory> | ||
|
||
#include "rcutils/types.h" | ||
|
||
#include "rosbag2_storage/visibility_control.hpp" | ||
|
||
namespace rosbag2_storage | ||
{ | ||
|
||
ROSBAG2_STORAGE_PUBLIC | ||
std::shared_ptr<rcutils_char_array_t> | ||
make_serialized_message(const void * data, size_t size); | ||
|
||
} // namespace rosbag2_storage | ||
|
||
#endif // ROSBAG2_STORAGE__ROS_HELPER_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2018 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "rosbag2_storage/ros_helper.hpp" | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "rcutils/logging_macros.h" | ||
#include "rcutils/types.h" | ||
|
||
namespace rosbag2_storage | ||
{ | ||
|
||
std::shared_ptr<rcutils_char_array_t> | ||
make_serialized_message(const void * data, size_t size) | ||
{ | ||
auto rcutils_allocator = new rcutils_allocator_t; | ||
*rcutils_allocator = rcutils_get_default_allocator(); | ||
auto msg = new rcutils_char_array_t; | ||
*msg = rcutils_get_zero_initialized_char_array(); | ||
auto ret = rcutils_char_array_init(msg, size, rcutils_allocator); | ||
if (ret != RCUTILS_RET_OK) { | ||
throw std::runtime_error("Error allocating resources for serialized message: " + | ||
std::string(rcutils_get_error_string_safe())); | ||
} | ||
|
||
auto serialized_message = std::shared_ptr<rcutils_char_array_t>(msg, | ||
[](rcutils_char_array_t * msg) { | ||
int error = rcutils_char_array_fini(msg); | ||
delete msg; | ||
if (error != RCUTILS_RET_OK) { | ||
RCUTILS_LOG_ERROR_NAMED( | ||
"rosbag2_storage", | ||
"Leaking memory. Error: %s", rcutils_get_error_string_safe()); | ||
} | ||
}); | ||
|
||
memcpy(serialized_message->buffer, data, size); | ||
serialized_message->buffer_length = size; | ||
|
||
return serialized_message; | ||
} | ||
|
||
} // namespace rosbag2_storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.