diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h index 55b354b7776a14909df1d38731bfd1f391a25e7a..5a46681d09c4feb03ebc98aa0f0cbd6368a325db 100644 --- a/include/core/processor/processor_base.h +++ b/include/core/processor/processor_base.h @@ -126,7 +126,7 @@ public: /**\brief Add a element to the buffer * */ - void add(const TimeStamp& _time_stamp, const T& _element); //const double& _time_tolerance); + void emplace(const TimeStamp& _time_stamp, const T& _element); //const double& _time_tolerance); /** \brief returns the container with elements of the buffer * @@ -558,7 +558,7 @@ T Buffer<T>::selectLast() } template <typename T> -void Buffer<T>::add(const TimeStamp& _time_stamp, const T& _element) +void Buffer<T>::emplace(const TimeStamp& _time_stamp, const T& _element) { container_.emplace(_time_stamp, _element); } diff --git a/src/processor/processor_base.cpp b/src/processor/processor_base.cpp index f6806ab4d8d6d2dbd6056575a096a74a4af121af..61f145811aabebbbdeaaba70b87f0ac5602e80f3 100644 --- a/src/processor/processor_base.cpp +++ b/src/processor/processor_base.cpp @@ -67,7 +67,7 @@ void ProcessorBase::keyFrameCallback(FrameBasePtr _keyframe, const double& _time // asking if frame should be stored if (storeKeyFrame(_keyframe)) - buffer_frame_.add(_keyframe->getTimeStamp(), _keyframe); + buffer_frame_.emplace(_keyframe->getTimeStamp(), _keyframe); // asking if frame should be processed if (triggerInKeyFrame(_keyframe, _time_tol_other)) @@ -92,7 +92,7 @@ void ProcessorBase::captureCallback(CaptureBasePtr _capture) // asking if capture should be stored if (storeCapture(_capture)) - buffer_capture_.add(_capture->getTimeStamp(), _capture); + buffer_capture_.emplace(_capture->getTimeStamp(), _capture); // asking if capture should be processed if (triggerInCapture(_capture)) diff --git a/src/processor/processor_loop_closure.cpp b/src/processor/processor_loop_closure.cpp index 777dddcacbc072c53396a7e5c1f83bc7d4f8d6a5..8b39b0230e3834df0957f005e0aa59ba59e29ad4 100644 --- a/src/processor/processor_loop_closure.cpp +++ b/src/processor/processor_loop_closure.cpp @@ -75,7 +75,7 @@ void ProcessorLoopClosure::processCapture(CaptureBasePtr _capture) } // CASE 3: WOLF_DEBUG("CASE 3"); - buffer_capture_.add(_capture->getTimeStamp(), _capture); + buffer_capture_.emplace(_capture->getTimeStamp(), _capture); } void ProcessorLoopClosure::processKeyFrame(FrameBasePtr _keyframe, const double& _time_tolerance) @@ -129,7 +129,7 @@ void ProcessorLoopClosure::processKeyFrame(FrameBasePtr _keyframe, const double& WOLF_DEBUG("CASE 3"); // store frame - buffer_frame_.add(_keyframe->getTimeStamp(), _keyframe); + buffer_frame_.emplace(_keyframe->getTimeStamp(), _keyframe); return; } diff --git a/test/gtest_buffer_frame.cpp b/test/gtest_buffer_frame.cpp index a6b63cf2b677f58d5051936cc7b247211f5a3ef2..2f94d78e36f2771b0a4eae0979c6b3d58c5b2ed5 100644 --- a/test/gtest_buffer_frame.cpp +++ b/test/gtest_buffer_frame.cpp @@ -77,18 +77,18 @@ TEST_F(BufferFrameTest, empty) ASSERT_TRUE(buffer_kf.empty()); } -TEST_F(BufferFrameTest, add) +TEST_F(BufferFrameTest, emplace) { - buffer_kf.add(10, f10); + buffer_kf.emplace(10, f10); ASSERT_EQ(buffer_kf.size(), (unsigned int) 1); - buffer_kf.add(20, f20); + buffer_kf.emplace(20, f20); ASSERT_EQ(buffer_kf.size(), (unsigned int) 2); } TEST_F(BufferFrameTest, clear) { - buffer_kf.add(10, f10); - buffer_kf.add(20, f20); + buffer_kf.emplace(10, f10); + buffer_kf.emplace(20, f20); ASSERT_EQ(buffer_kf.size(), (unsigned int) 2); buffer_kf.clear(); ASSERT_TRUE(buffer_kf.empty()); @@ -97,16 +97,16 @@ TEST_F(BufferFrameTest, clear) //TEST_F(BufferFrameTest, print) //{ // kfpackbuffer.clear(); -// kfpackbuffer.add(f10, tt10); -// kfpackbuffer.add(f20, tt20); +// kfpackbuffer.emplace(f10, tt10); +// kfpackbuffer.emplace(f20, tt20); // kfpackbuffer.print(); //} TEST_F(BufferFrameTest, doubleCheckTimeTolerance) { buffer_kf.clear(); - buffer_kf.add(10, f10); - buffer_kf.add(20, f20); + buffer_kf.emplace(10, f10); + buffer_kf.emplace(20, f20); // min time tolerance > diff between time stamps. It should return true ASSERT_TRUE(buffer_kf.doubleCheckTimeTolerance(10, 20, 20, 20)); // min time tolerance < diff between time stamps. It should return true @@ -157,8 +157,8 @@ TEST_F(BufferFrameTest, doubleCheckTimeTolerance) // { // for (unsigned int ip2=0;ip2<p2.size();++ip2) // { -// buffer_kf.add(f10, p1[ip1]); -// buffer_kf.add(f20, p2[ip2]); +// buffer_kf.emplace(f10, p1[ip1]); +// buffer_kf.emplace(f20, p2[ip2]); // for (unsigned int iq=0;iq<q.size();++iq) // { // PackKeyFramePtr packQ = buffer_kf.selectPack(16, q[iq]); @@ -176,9 +176,9 @@ TEST_F(BufferFrameTest, doubleCheckTimeTolerance) //{ // buffer_kf.clear(); // -// buffer_kf.add(10, f10); -// buffer_kf.add(20, f20); -// buffer_kf.add(21, f21); +// buffer_kf.emplace(10, f10); +// buffer_kf.emplace(20, f20); +// buffer_kf.emplace(21, f21); // // // input time stamps // std::vector<TimeStamp> q_ts = {9.5, 9.995, 10.005, 19.5, 20.5, 21.5}; @@ -239,9 +239,9 @@ TEST_F(BufferFrameTest, removeUpTo) // Small time tolerance for all test asserts double tt = 0.1; buffer_kf.clear(); - buffer_kf.add(10, f10); - buffer_kf.add(20, f20); - buffer_kf.add(21, f21); + buffer_kf.emplace(10, f10); + buffer_kf.emplace(20, f20); + buffer_kf.emplace(21, f21); // it should remove f20 and f10, thus size should be 1 after removal // Specifically, only f21 should remain @@ -253,7 +253,7 @@ TEST_F(BufferFrameTest, removeUpTo) // Chech removal of an imprecise time stamp // Specifically, only f28 should remain - buffer_kf.add(28, f28); + buffer_kf.emplace(28, f28); ASSERT_EQ(buffer_kf.size(), (unsigned int) 2); FrameBasePtr f22 = std::make_shared<FrameBase>(TimeStamp(22),nullptr,nullptr,nullptr); f22->setTimeTolerance(5.0);