Program Listing for File MirrorManager.hpp
↰ Return to documentation for file (include/rmf_traffic_ros2/schedule/MirrorManager.hpp
)
/*
* Copyright (C) 2019 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 RMF_TRAFFIC_ROS2__SCHEDULE__MIRROR_HPP
#define RMF_TRAFFIC_ROS2__SCHEDULE__MIRROR_HPP
#include <rmf_traffic/schedule/Database.hpp>
#include <rmf_traffic/schedule/Mirror.hpp>
#include <rclcpp/node.hpp>
namespace rmf_traffic_ros2 {
namespace schedule {
//==============================================================================
class MirrorManager
{
public:
class Options
{
public:
Options(
std::mutex* update_mutex = nullptr,
bool update_on_wakeup = true);
std::mutex* update_mutex() const;
Options& update_mutex(std::mutex* mutex);
bool update_on_wakeup() const;
Options& update_on_wakeup(bool choice);
class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
};
std::shared_ptr<const rmf_traffic::schedule::Mirror> view() const;
// TODO(MXG): Consider allowing this function to accept a callback that will
// get triggered when the update is complete.
void update();
const Options& get_options() const;
MirrorManager& set_options(Options options);
rmf_traffic::schedule::Database fork() const;
class Implementation;
private:
MirrorManager();
rmf_utils::unique_impl_ptr<Implementation> _pimpl;
};
//==============================================================================
class MirrorManagerFuture
{
public:
void wait() const;
std::future_status wait_for(const rmf_traffic::Duration& timeout) const;
std::future_status wait_until(const rmf_traffic::Time& time) const;
bool valid() const;
MirrorManager get();
class Implementation;
private:
MirrorManagerFuture();
rmf_utils::unique_impl_ptr<Implementation> _pimpl;
};
//==============================================================================
// TODO(MXG): Use std::optional here instead of std::unique_ptr when C++17 can
// be supported.
MirrorManagerFuture make_mirror(
const std::shared_ptr<rclcpp::Node>& node,
rmf_traffic::schedule::Query query,
MirrorManager::Options options = MirrorManager::Options());
} // namespace schedule
} // namespace rmf_traffic_ros2
#endif // RMF_TRAFFIC_ROS2__SCHEDULE__MIRROR_HPP