From 808fb2f640f773968e174acf6f5473d8e9dd83a2 Mon Sep 17 00:00:00 2001 From: Albert Huang Date: Wed, 28 Oct 2015 09:15:06 -0700 Subject: [PATCH] void LCM::unsubscribe() -> int LCM::unsubscribe() --- lcm/lcm-cpp-impl.hpp | 9 +++++---- lcm/lcm-cpp.hpp | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lcm/lcm-cpp-impl.hpp b/lcm/lcm-cpp-impl.hpp index 021f9963a..8e2faf5c5 100644 --- a/lcm/lcm-cpp-impl.hpp +++ b/lcm/lcm-cpp-impl.hpp @@ -160,23 +160,24 @@ LCM::publish(const std::string& channel, const MessageType *msg) { return status; } -inline void +inline int LCM::unsubscribe(Subscription *subscription) { if(!this->lcm) { fprintf(stderr, "LCM instance not initialized. Ignoring call to unsubscribe()\n"); - return; + return -1; } std::vector::iterator iter; std::vector::iterator eiter = subscriptions.end(); for(iter=subscriptions.begin(); iter!= eiter; ++iter) { if(*iter == subscription) { - lcm_unsubscribe(lcm, subscription->c_subs); + int status = lcm_unsubscribe(lcm, subscription->c_subs); subscriptions.erase(iter); delete subscription; - break; + return status; } } + return -1; } inline int diff --git a/lcm/lcm-cpp.hpp b/lcm/lcm-cpp.hpp index 8379c16c1..d4fb6f85c 100644 --- a/lcm/lcm-cpp.hpp +++ b/lcm/lcm-cpp.hpp @@ -363,8 +363,11 @@ class LCM { * * @param subscription a Subscription object previously returned by a * call to subscribe() or subscribeFunction(). + * + * @return 0 on success, -1 if @p subscription is not a valid + * subscription. */ - inline void unsubscribe(Subscription* subscription); + inline int unsubscribe(Subscription* subscription); /** * @brief retrives the lcm_t C data structure wrapped by this class.