.. _program_listing_file_include_rosbag2_cpp_reader.hpp: Program Listing for File reader.hpp =================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/rosbag2_cpp/reader.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2018, Bosch Software Innovations GmbH. // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // 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_CPP__READER_HPP_ #define ROSBAG2_CPP__READER_HPP_ #include #include #include #include "rclcpp/serialization.hpp" #include "rclcpp/serialized_message.hpp" #include "rosbag2_cpp/bag_events.hpp" #include "rosbag2_cpp/converter_options.hpp" #include "rosbag2_cpp/readers/sequential_reader.hpp" #include "rosbag2_cpp/visibility_control.hpp" #include "rosbag2_storage/bag_metadata.hpp" #include "rosbag2_storage/serialized_bag_message.hpp" #include "rosbag2_storage/storage_filter.hpp" #include "rosbag2_storage/storage_options.hpp" #include "rosbag2_storage/topic_metadata.hpp" // This is necessary because of using stl types here. It is completely safe, because // a) the member is not accessible from the outside // b) there are no inline functions. #ifdef _WIN32 # pragma warning(push) # pragma warning(disable:4251) #endif namespace rosbag2_cpp { namespace reader_interfaces { class BaseReaderInterface; } // namespace reader_interfaces class ROSBAG2_CPP_PUBLIC Reader { public: explicit Reader( std::unique_ptr reader_impl = std::make_unique()); ~Reader(); void open(const std::string & uri); void open( const rosbag2_storage::StorageOptions & storage_options, const ConverterOptions & converter_options = ConverterOptions()); void close(); bool set_read_order(const rosbag2_storage::ReadOrder & read_order); bool has_next(); std::shared_ptr read_next(); template MessageT read_next() { MessageT msg; auto bag_message = read_next(); rclcpp::SerializedMessage extracted_serialized_msg(*bag_message->serialized_data); rclcpp::Serialization serialization; serialization.deserialize_message(&extracted_serialized_msg, &msg); return msg; } const rosbag2_storage::BagMetadata & get_metadata() const; std::vector get_all_topics_and_types() const; void get_all_message_definitions(std::vector & definitions); void set_filter(const rosbag2_storage::StorageFilter & storage_filter); void reset_filter(); void seek(const rcutils_time_point_value_t & timestamp); reader_interfaces::BaseReaderInterface & get_implementation_handle() const { return *reader_impl_; } void add_event_callbacks(bag_events::ReaderEventCallbacks & callbacks); [[nodiscard]] bool has_callback_for_event(bag_events::BagEvent event) const; private: std::unique_ptr reader_impl_; }; } // namespace rosbag2_cpp #ifdef _WIN32 # pragma warning(pop) #endif #endif // ROSBAG2_CPP__READER_HPP_