From f64eef876ab1591ee057aaab138fd99b3c24b044 Mon Sep 17 00:00:00 2001 From: gaschler Date: Tue, 16 Jan 2018 16:21:22 +0100 Subject: [PATCH] Optional GetBlockingTrajectoryId (#820) [RFC=0008](https://github.com/googlecartographer/rfcs/blob/master/text/0008-collator-interface.md) --- cartographer/sensor/collator.cc | 4 ++-- cartographer/sensor/collator.h | 2 +- cartographer/sensor/collator_interface.h | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cartographer/sensor/collator.cc b/cartographer/sensor/collator.cc index 3b18e33..2fbcfb2 100644 --- a/cartographer/sensor/collator.cc +++ b/cartographer/sensor/collator.cc @@ -47,8 +47,8 @@ void Collator::AddSensorData(const int trajectory_id, void Collator::Flush() { queue_.Flush(); } -int Collator::GetBlockingTrajectoryId() const { - return queue_.GetBlocker().trajectory_id; +common::optional Collator::GetBlockingTrajectoryId() const { + return common::optional(queue_.GetBlocker().trajectory_id); } } // namespace sensor diff --git a/cartographer/sensor/collator.h b/cartographer/sensor/collator.h index abf0e8c..c696613 100644 --- a/cartographer/sensor/collator.h +++ b/cartographer/sensor/collator.h @@ -47,7 +47,7 @@ class Collator : public CollatorInterface { void Flush() override; - int GetBlockingTrajectoryId() const override; + common::optional GetBlockingTrajectoryId() const override; private: // Queue keys are a pair of trajectory ID and sensor identifier. diff --git a/cartographer/sensor/collator_interface.h b/cartographer/sensor/collator_interface.h index 2183a08..eb1d787 100644 --- a/cartographer/sensor/collator_interface.h +++ b/cartographer/sensor/collator_interface.h @@ -22,6 +22,7 @@ #include #include +#include "cartographer/common/optional.h" #include "cartographer/sensor/data.h" namespace cartographer { @@ -57,9 +58,10 @@ class CollatorInterface { virtual void Flush() = 0; // Must only be called if at least one unfinished trajectory exists. Returns - // the ID of the trajectory that needs more data before the Collator is - // unblocked. - virtual int GetBlockingTrajectoryId() const = 0; + // the ID of the trajectory that needs more data before CollatorInterface is + // unblocked. Returns 'nullopt' for implementations that do not wait for a + // particular trajectory. + virtual common::optional GetBlockingTrajectoryId() const = 0; }; } // namespace sensor