From 5b3efab4782857680de749cf9adfdaa8bd61513d Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Wed, 14 Aug 2013 10:32:06 -0700 Subject: [PATCH] make operators const (fix #10) --- include/actionlib/client/client_goal_handle_imp.h | 4 ++-- include/actionlib/client/client_helpers.h | 4 ++-- include/actionlib/client_goal_status.h | 4 ++-- include/actionlib/managed_list.h | 2 +- include/actionlib/server/server_goal_handle.h | 4 ++-- include/actionlib/server/server_goal_handle_imp.h | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/actionlib/client/client_goal_handle_imp.h b/include/actionlib/client/client_goal_handle_imp.h index a6b4267a..b9465259 100644 --- a/include/actionlib/client/client_goal_handle_imp.h +++ b/include/actionlib/client/client_goal_handle_imp.h @@ -251,7 +251,7 @@ void ClientGoalHandle::cancel() } template -bool ClientGoalHandle::operator==(const ClientGoalHandle& rhs) +bool ClientGoalHandle::operator==(const ClientGoalHandle& rhs) const { // Check if both are inactive if (!active_ && !rhs.active_) @@ -272,7 +272,7 @@ bool ClientGoalHandle::operator==(const ClientGoalHandle } template -bool ClientGoalHandle::operator!=(const ClientGoalHandle& rhs) +bool ClientGoalHandle::operator!=(const ClientGoalHandle& rhs) const { return !(*this==rhs); } diff --git a/include/actionlib/client/client_helpers.h b/include/actionlib/client/client_helpers.h index cfb72ddc..516449ae 100644 --- a/include/actionlib/client/client_helpers.h +++ b/include/actionlib/client/client_helpers.h @@ -191,12 +191,12 @@ class ClientGoalHandle * \brief Check if two goal handles point to the same goal * \return TRUE if both point to the same goal. Also returns TRUE if both handles are inactive. */ - bool operator==(const ClientGoalHandle& rhs); + bool operator==(const ClientGoalHandle& rhs) const; /** * \brief !(operator==()) */ - bool operator!=(const ClientGoalHandle& rhs); + bool operator!=(const ClientGoalHandle& rhs) const; friend class GoalManager; private: diff --git a/include/actionlib/client_goal_status.h b/include/actionlib/client_goal_status.h index 92213157..8d8966e5 100644 --- a/include/actionlib/client_goal_status.h +++ b/include/actionlib/client_goal_status.h @@ -101,7 +101,7 @@ class ClientGoalStatus /** * \brief Straightforward enum equality check */ - inline bool operator==(const ClientGoalStatus& rhs) + inline bool operator==(const ClientGoalStatus& rhs) const { return state_ == rhs.state_; } @@ -109,7 +109,7 @@ class ClientGoalStatus /** * \brief Straightforward enum inequality check */ - inline bool operator!=(const ClientGoalStatus& rhs) + inline bool operator!=(const ClientGoalStatus& rhs) const { return !(state_ == rhs.state_); } diff --git a/include/actionlib/managed_list.h b/include/actionlib/managed_list.h index 6645fda1..b4046a1e 100644 --- a/include/actionlib/managed_list.h +++ b/include/actionlib/managed_list.h @@ -158,7 +158,7 @@ class ManagedList /** * \brief Checks if two handles point to the same list elem */ - bool operator==(const Handle& rhs) + bool operator==(const Handle& rhs) const { assert(valid_); assert(rhs.valid_); diff --git a/include/actionlib/server/server_goal_handle.h b/include/actionlib/server/server_goal_handle.h index de263099..45f2a1e9 100644 --- a/include/actionlib/server/server_goal_handle.h +++ b/include/actionlib/server/server_goal_handle.h @@ -144,14 +144,14 @@ namespace actionlib { * @param other The ServerGoalHandle to compare to * @return True if the ServerGoalHandles refer to the same goal, false otherwise */ - bool operator==(const ServerGoalHandle& other); + bool operator==(const ServerGoalHandle& other) const; /** * @brief != operator for ServerGoalHandles * @param other The ServerGoalHandle to compare to * @return True if the ServerGoalHandles refer to different goals, false otherwise */ - bool operator!=(const ServerGoalHandle& other); + bool operator!=(const ServerGoalHandle& other) const; private: /** diff --git a/include/actionlib/server/server_goal_handle_imp.h b/include/actionlib/server/server_goal_handle_imp.h index 15fcb042..3da06510 100644 --- a/include/actionlib/server/server_goal_handle_imp.h +++ b/include/actionlib/server/server_goal_handle_imp.h @@ -291,7 +291,7 @@ namespace actionlib { } template - bool ServerGoalHandle::operator==(const ServerGoalHandle& other){ + bool ServerGoalHandle::operator==(const ServerGoalHandle& other) const{ if(!goal_ && !other.goal_) return true; @@ -304,7 +304,7 @@ namespace actionlib { } template - bool ServerGoalHandle::operator!=(const ServerGoalHandle& other){ + bool ServerGoalHandle::operator!=(const ServerGoalHandle& other) const{ return !(*this == other); }