From be912ded5bc853f917f2135d0fd563988b9c5d5a Mon Sep 17 00:00:00 2001 From: paul-szczepanek-arm <33840200+paul-szczepanek-arm@users.noreply.github.com> Date: Mon, 9 Apr 2018 12:14:52 +0100 Subject: [PATCH] normalised the getters const insanity --- .../targets/TARGET_CORDIO/CordioBLE.h | 6 ++--- .../TARGET_CORDIO/source/CordioBLE.cpp | 24 +++++++------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/CordioBLE.h b/features/FEATURE_BLE/targets/TARGET_CORDIO/CordioBLE.h index cdfc1aee48..e63d62055a 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/CordioBLE.h +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/CordioBLE.h @@ -85,12 +85,12 @@ public: /** * @see BLEInstanceBase::getGap */ - virtual ::Gap& getGap(); + virtual generic::GenericGap& getGap(); /** * @see BLEInstanceBase::getGap */ - virtual const ::Gap& getGap() const; + virtual const generic::GenericGap& getGap() const; /** * @see BLEInstanceBase::getGattServer @@ -105,7 +105,7 @@ public: /** * @see BLEInstanceBase::getGattClient */ - virtual ::GattClient &getGattClient(); + virtual generic::GenericGattClient &getGattClient(); /** * @see BLEInstanceBase::getSecurityManager diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp index e6d01ef6b3..7ab3c61a53 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp @@ -164,19 +164,12 @@ const char* BLE::getVersion() return version; } -::Gap& BLE::getGap() +generic::GenericGap& BLE::getGap() { - typedef ::Gap& return_type; - const BLE* self = this; - return const_cast(self->getGap()); + return const_cast(getGap()); } -const ::Gap& BLE::getGap() const -{ - return getGenericGap(); -}; - -const generic::GenericGap& BLE::getGenericGap() const +const generic::GenericGap& BLE::getGap() const { static pal::vendor::cordio::Gap& cordio_pal_gap = pal::vendor::cordio::Gap::get_gap(); @@ -187,7 +180,7 @@ const generic::GenericGap& BLE::getGenericGap() const cordio_gap_service ); return gap; -} +}; GattServer& BLE::getGattServer() { @@ -199,7 +192,7 @@ const GattServer& BLE::getGattServer() const return cordio::GattServer::getInstance(); } -::GattClient& BLE::getGattClient() +generic::GenericGattClient& BLE::getGattClient() { static pal::AttClientToGattClientAdapter pal_client( pal::vendor::cordio::CordioAttClient::get_client() @@ -211,8 +204,7 @@ const GattServer& BLE::getGattServer() const SecurityManager& BLE::getSecurityManager() { - const BLE* self = this; - return const_cast(self->getSecurityManager()); + return const_cast(getSecurityManager()); } const SecurityManager& BLE::getSecurityManager() const @@ -225,8 +217,8 @@ const SecurityManager& BLE::getSecurityManager() const static generic::GenericSecurityManager m_instance( m_pal, m_db, - const_cast(getGenericGap()), - static_cast(self->getGattClient()) + self->getGap(), + self->getGattClient() ); return m_instance;