Program Listing for File player_clock.hpp

Return to documentation for file (/tmp/ws/src/rosbag2/rosbag2_cpp/include/rosbag2_cpp/clocks/player_clock.hpp)

// Copyright 2021 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__CLOCKS__PLAYER_CLOCK_HPP_
#define ROSBAG2_CPP__CLOCKS__PLAYER_CLOCK_HPP_

#include <atomic>
#include <chrono>
#include <functional>
#include <memory>

#include "rclcpp/clock.hpp"
#include "rclcpp/time.hpp"
#include "rcutils/time.h"
#include "rosbag2_cpp/visibility_control.hpp"

namespace rosbag2_cpp
{

class PlayerClock
{
public:
  typedef std::function<std::chrono::steady_clock::time_point()> NowFunction;

  ROSBAG2_CPP_PUBLIC
  virtual ~PlayerClock() = default;

  ROSBAG2_CPP_PUBLIC
  virtual rcutils_time_point_value_t now() const = 0;

  ROSBAG2_CPP_PUBLIC
  virtual bool sleep_until(rcutils_time_point_value_t until) = 0;

  ROSBAG2_CPP_PUBLIC
  virtual bool sleep_until(rclcpp::Time time) = 0;

  ROSBAG2_CPP_PUBLIC
  virtual bool set_rate(double rate) = 0;

  ROSBAG2_CPP_PUBLIC
  virtual double get_rate() const = 0;

  ROSBAG2_CPP_PUBLIC
  virtual void pause() = 0;

  ROSBAG2_CPP_PUBLIC
  virtual void resume() = 0;

  ROSBAG2_CPP_PUBLIC
  virtual bool is_paused() const = 0;

  ROSBAG2_CPP_PUBLIC
  virtual void jump(rcutils_time_point_value_t time_point) = 0;

  ROSBAG2_CPP_PUBLIC
  virtual void jump(rclcpp::Time time) = 0;

  ROSBAG2_CPP_PUBLIC
  virtual rclcpp::JumpHandler::SharedPtr create_jump_callback(
    rclcpp::JumpHandler::pre_callback_t pre_callback,
    rclcpp::JumpHandler::post_callback_t post_callback,
    const rcl_jump_threshold_t & threshold) = 0;
};

}  // namespace rosbag2_cpp

#endif  // ROSBAG2_CPP__CLOCKS__PLAYER_CLOCK_HPP_