Program Listing for File Stopwatch.hpp

Return to documentation for file (/tmp/ws/src/ros_gz/ros_gz_sim/include/ros_gz_sim/Stopwatch.hpp)

// Copyright 2022 Open Source Robotics Foundation
//
// 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 ROS_GZ_SIM__STOPWATCH_HPP_
#define ROS_GZ_SIM__STOPWATCH_HPP_

#include <chrono>
#include <memory>

#include <rclcpp/clock.hpp>

namespace ros_gz_sim
{
// Forward declarations.
class StopwatchPrivate;

class Stopwatch
{

public:
  Stopwatch();


public:
  Stopwatch(const Stopwatch & _watch);


public:
  Stopwatch(Stopwatch && _watch) noexcept;


public:
  virtual ~Stopwatch();

public:
  void SetClock(rclcpp::Clock::SharedPtr _clock);


public:
  bool Start(const bool _reset = false);


public:
  const rclcpp::Time & StartTime() const;


public:
  bool Stop();


public:
  const rclcpp::Time & StopTime() const;


public:
  bool Running() const;


public:
  void Reset();


public:
  rclcpp::Duration ElapsedRunTime() const;


public:
  rclcpp::Duration ElapsedStopTime() const;


public:
  bool operator==(const Stopwatch & _watch) const;


public:
  bool operator!=(const Stopwatch & _watch) const;


public:
  Stopwatch & operator=(const Stopwatch & _watch);


public:
  Stopwatch & operator=(Stopwatch && _watch);

#ifdef _WIN32
// Disable warning C4251 which is triggered by
// std::unique_ptr
#pragma warning(push)
#pragma warning(disable: 4251)
#endif

private:
  std::unique_ptr<StopwatchPrivate> dataPtr;
#ifdef _WIN32
#pragma warning(pop)
#endif
};
}  // namespace ros_gz_sim
#endif  // ROS_GZ_SIM__STOPWATCH_HPP_