.. _program_listing_file__tmp_ws_src_rmf_traffic_rmf_traffic_include_rmf_traffic_agv_RouteValidator.hpp: Program Listing for File RouteValidator.hpp =========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/rmf_traffic/rmf_traffic/include/rmf_traffic/agv/RouteValidator.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * Copyright (C) 2020 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__AGV__ROUTEVALIDATOR_HPP #define RMF_TRAFFIC__AGV__ROUTEVALIDATOR_HPP #include #include #include namespace rmf_traffic { namespace agv { //============================================================================== class RouteValidator { public: using ParticipantId = schedule::ParticipantId; using Route = rmf_traffic::Route; struct Conflict { Dependency dependency; Time time; std::shared_ptr route; }; // // TODO(MXG): It would be better to implement this as a coroutine generator so // that clients of this interface can decide whether they only care about the // first conflict or if they want to know all of the conflicts. This is not a // high priority because in the vast majority of cases when a conflict happens // it will only be with one participant. And since this is only meant to // provide a hint about which participant is causing conflicts, it is okay if // other participants are ignored. virtual std::optional find_conflict( const Route& route) const = 0; virtual std::unique_ptr clone() const = 0; virtual ~RouteValidator() = default; }; //============================================================================== class ScheduleRouteValidator : public RouteValidator { public: ScheduleRouteValidator( const schedule::Viewer& viewer, schedule::ParticipantId participant_id, Profile profile); ScheduleRouteValidator( std::shared_ptr viewer, schedule::ParticipantId participant_id, Profile profile); template static rmf_utils::clone_ptr make(Args&& ... args) { return rmf_utils::make_clone( std::forward(args)...); } ScheduleRouteValidator& schedule_viewer(const schedule::Viewer& viewer); const schedule::Viewer& schedule_viewer() const; ScheduleRouteValidator& participant(schedule::ParticipantId p); schedule::ParticipantId participant() const; // TODO(MXG): Make profile setters and getters // Documentation inherited std::optional find_conflict(const Route& route) const final; // Documentation inherited std::unique_ptr clone() const final; class Implementation; private: rmf_utils::impl_ptr _pimpl; }; //============================================================================== class NegotiatingRouteValidator : public RouteValidator { public: class Generator { public: Generator( schedule::Negotiation::Table::ViewerPtr viewer, rmf_traffic::Profile profile); Generator(schedule::Negotiation::Table::ViewerPtr viewer); Generator& ignore_unresponsive(bool val = true); Generator& ignore_bystanders(bool val = true); NegotiatingRouteValidator begin() const; std::vector> all() const; const std::vector& alternative_sets() const; std::size_t alternative_count(schedule::ParticipantId participant) const; class Implementation; private: rmf_utils::impl_ptr _pimpl; }; NegotiatingRouteValidator& mask(schedule::ParticipantId id); NegotiatingRouteValidator& remove_mask(); NegotiatingRouteValidator next(schedule::ParticipantId id) const; const schedule::Negotiation::VersionedKeySequence& alternatives() const; operator bool() const; bool end() const; // Documentation inherited rmf_utils::optional find_conflict(const Route& route) const final; // Documentation inherited std::unique_ptr clone() const final; class Implementation; private: NegotiatingRouteValidator(); rmf_utils::impl_ptr _pimpl; }; } // namespace agv } // namespace rmf_traffic #endif // RMF_TRAFFIC__AGV__ROUTEVALIDATOR_HPP