From b5ed78b9825b731e708dcf1b3f6ece4894521913 Mon Sep 17 00:00:00 2001 From: Joan Sola <jsola@iri.upc.edu> Date: Tue, 22 Jan 2019 18:42:05 +0100 Subject: [PATCH] Add method process() to capture --- src/capture_base.h | 10 ++++++++++ src/test/gtest_capture_base.cpp | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/capture_base.h b/src/capture_base.h index 06e8541ba..d705be376 100644 --- a/src/capture_base.h +++ b/src/capture_base.h @@ -50,6 +50,8 @@ class CaptureBase : public NodeBase, public std::enable_shared_from_this<Capture // Type virtual bool isMotion() const { return false; } + bool process(); + unsigned int id(); TimeStamp getTimeStamp() const; void setTimeStamp(const TimeStamp& _ts); @@ -220,6 +222,14 @@ inline void CaptureBase::setTimeStampToNow() time_stamp_.setToNow(); } +inline bool CaptureBase::process() +{ + assert (getSensorPtr() != nullptr && "Attempting to process a capture with no associated sensor. Either set the capture's sensor or call sensor->process(capture) instead."); + + return getSensorPtr()->process(shared_from_this()); +} + + } // namespace wolf #endif diff --git a/src/test/gtest_capture_base.cpp b/src/test/gtest_capture_base.cpp index e888d2d67..00fdf8883 100644 --- a/src/test/gtest_capture_base.cpp +++ b/src/test/gtest_capture_base.cpp @@ -103,6 +103,15 @@ TEST(CaptureBase, addFeatureList) ASSERT_EQ(C->getFeatureList().back(), f_last); } +TEST(CaptureBase, process) +{ + SensorBasePtr S(std::make_shared<SensorBase>("DUMMY", nullptr, nullptr, nullptr, 2)); + CaptureBasePtr C(std::make_shared<CaptureBase>("DUMMY", 1.5, nullptr)); + ASSERT_DEATH({C->process();},""); // No sensor in the capture should fail + C->setSensorPtr(S); + ASSERT_TRUE(C->process()); // This should not fail (although it does nothing) +} + int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); -- GitLab