Class Mirror

Inheritance Relationships

Base Types

Class Documentation

class Mirror : public rmf_traffic::schedule::ItineraryViewer, public rmf_traffic::schedule::Snappable

A class that maintains a mirror of a Database of scheduled Trajectories. This class is intended to provide a cache of the scheduled Trajectories to processes or threads that do not contain the original upstream copy of the rmf_traffic::schedule::Database.

The Mirror is designed to mirror a relevant subset of the schedule database.

Public Functions

virtual View query(const Query &parameters) const final

Query this Viewer to get a View of the Trajectories inside of it that match the Query parameters.

virtual View query(const Query::Spacetime &spacetime, const Query::Participants &participants) const final

Alternative signature for query()

virtual const std::unordered_set<ParticipantId> &participant_ids() const final

Get the set of active participant IDs.

std::shared_ptr<const ParticipantDescription> get_participant(std::size_t participant_id) const final
std::optional<ItineraryView> get_itinerary(std::size_t participant_id) const final
std::optional<Version> latest_version() const
virtual std::optional<PlanId> get_current_plan_id(ParticipantId participant_id) const final

Get the current plan ID of a specific participant if it is available. If a participant with the specified ID is not registered with the schedule, then this will return a nullopt.

virtual const std::vector<CheckpointId> *get_current_progress(ParticipantId participant_id) const final

Get the current progress of a specific participant. If a participant with the specified ID is not registered with the schedule or has never made progress, then this will return a nullptr.

virtual ProgressVersion get_current_progress_version(ParticipantId participant_id) const final

Get the current known progress of a specific participant along its current plan. If no progress has been made, this will have a value of 0.

virtual DependencySubscription watch_dependency(Dependency dependency, std::function<void()> on_reached, std::function<void()> on_deprecated) const final

Watch a traffic dependency. When a relevant event happens for the dependency, the on_reached or on_deprecated will be triggered. If the event had already come to pass before this function is called, then the relevant callback will be triggered right away, within the scope of this function.

Only one of the callbacks will ever be triggered, and it will only be triggered at most once.

Parameters:
  • on_reached[in] If the dependency is reached, this will be triggered. on_changed will never be triggered afterwards.

  • on_deprecated[in] If the plan of the participant changed before it reached this dependency then the dependency is deprecated and this callback will be triggered. on_reached will never be triggered afterwards.

Returns:

an object that maintains the dependency for the viewer.

virtual std::shared_ptr<const Snapshot> snapshot() const final

Get a snapshot of the schedule.

Mirror()

Create a database mirror.

void update_participants_info(const ParticipantDescriptionsMap &participants)

Update the known participants and their descriptions.

bool update(const Patch &patch)

Update this mirror.

Returns:

true if this update is okay. false if the base version of the patch does not match

void reset()

Tell this mirror that the upstream database is reseting its version number. The next patch that this mirror receives will need to provide a full update.

Database fork() const

Fork a new database off of this Mirror. The state of the new database will match the last state of the upstream database that this Mirror knows about.