diff options
author | Sven Gothel <[email protected]> | 2022-05-09 01:50:30 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-05-09 01:50:30 +0200 |
commit | 57c8e5916dd8b83fc4fb720aee417a138a0d9e19 (patch) | |
tree | 0c2f828f65ac74ee6ce4c2f5ef0a2ef89ae249ba /api | |
parent | 9c5f25ccd1637728d6e79592279e4b38ecd32f59 (diff) |
Use typedef of shared_pre<T> 'TRef' and pass `const shared_pre<T>&` where possible
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/BTDevice.hpp | 6 | ||||
-rw-r--r-- | api/direct_bt/BTGattChar.hpp | 1 | ||||
-rw-r--r-- | api/direct_bt/BTGattHandler.hpp | 27 |
3 files changed, 18 insertions, 16 deletions
diff --git a/api/direct_bt/BTDevice.hpp b/api/direct_bt/BTDevice.hpp index d9e1a2cf..bf2f5266 100644 --- a/api/direct_bt/BTDevice.hpp +++ b/api/direct_bt/BTDevice.hpp @@ -339,7 +339,7 @@ namespace direct_bt { * The EInfoReport is updated by new scan-reports (update) and when disconnected (empty). * @since 2.5.3 */ - std::shared_ptr<EInfoReport> getEIR() noexcept; + EInfoReportRef getEIR() noexcept; /** * Return the latest advertised EInfoReport AD_IND variant for this remote device. @@ -347,7 +347,7 @@ namespace direct_bt { * The EInfoReport is replaced by new scan-reports only. * @since 2.6.6 */ - std::shared_ptr<EInfoReport> getEIRInd() noexcept; + EInfoReportRef getEIRInd() noexcept; /** * Return the latest advertised EInfoReport AD_SCAN_RSP for this remote device. @@ -355,7 +355,7 @@ namespace direct_bt { * The EInfoReport is replaced by new scan-reports only. * @since 2.6.6 */ - std::shared_ptr<EInfoReport> getEIRScanRsp() noexcept; + EInfoReportRef getEIRScanRsp() noexcept; std::string toString() const noexcept override { return toString(false); } diff --git a/api/direct_bt/BTGattChar.hpp b/api/direct_bt/BTGattChar.hpp index c500ffc2..8882778a 100644 --- a/api/direct_bt/BTGattChar.hpp +++ b/api/direct_bt/BTGattChar.hpp @@ -556,6 +556,7 @@ namespace direct_bt { bool operator!=(const BTGattCharListener& rhs) const noexcept { return !(*this == rhs); } }; + typedef std::shared_ptr<BTGattCharListener> BTGattCharListenerRef; class AssociatedBTGattCharListener : public BTGattCharListener { private: diff --git a/api/direct_bt/BTGattHandler.hpp b/api/direct_bt/BTGattHandler.hpp index e51d5fc9..549ff5d3 100644 --- a/api/direct_bt/BTGattHandler.hpp +++ b/api/direct_bt/BTGattHandler.hpp @@ -434,10 +434,11 @@ namespace direct_bt { bool operator!=(const NativeGattCharListener& rhs) const noexcept { return !(*this == rhs); } }; - typedef jau::cow_darray<std::shared_ptr<NativeGattCharListener>> NativeGattCharListenerList_t; + typedef std::shared_ptr<NativeGattCharListener> NativeGattCharListenerRef; + typedef jau::cow_darray<NativeGattCharListenerRef> NativeGattCharListenerList_t; typedef jau::darray<NativeGattCharListener::Section> NativeGattCharSections_t; - typedef jau::cow_darray<std::shared_ptr<BTGattCharListener>> BTGattCharListenerList_t; + typedef jau::cow_darray<BTGattCharListenerRef> BTGattCharListenerList_t; private: /** BTGattHandler's device weak back-reference */ @@ -807,7 +808,7 @@ namespace direct_bt { * otherwise false. * </p> */ - bool addCharListener(std::shared_ptr<BTGattCharListener> l) noexcept; + bool addCharListener(const BTGattCharListenerRef& l) noexcept; /** * Remove the given listener from the list. @@ -816,7 +817,7 @@ namespace direct_bt { * otherwise false. * </p> */ - bool removeCharListener(std::shared_ptr<BTGattCharListener> l) noexcept; + bool removeCharListener(const BTGattCharListenerRef& l) noexcept; /** * Remove the given listener from the list. @@ -836,7 +837,7 @@ namespace direct_bt { * @param associatedCharacteristic the match criteria to remove any BTGattCharListener from the list * @return number of removed listener. */ - int removeAllAssociatedCharListener(std::shared_ptr<BTGattChar> associatedChar) noexcept; + int removeAllAssociatedCharListener(const BTGattCharRef& associatedChar) noexcept; int removeAllAssociatedCharListener(const BTGattChar * associatedChar) noexcept; @@ -847,7 +848,7 @@ namespace direct_bt { * otherwise false. * </p> */ - bool addCharListener(std::shared_ptr<NativeGattCharListener> l) noexcept; + bool addCharListener(const NativeGattCharListenerRef& l) noexcept; /** * Remove the given listener from the list. @@ -856,7 +857,7 @@ namespace direct_bt { * otherwise false. * </p> */ - bool removeCharListener(std::shared_ptr<NativeGattCharListener> l) noexcept; + bool removeCharListener(const NativeGattCharListenerRef& l) noexcept; /** * Remove all event listener from the list. @@ -896,7 +897,7 @@ namespace direct_bt { * @param pduRequest the request * @param clientSource the GATTRole::Client source device, only known and not nullptr for DBGattServer::Mode:FWD GattServerHandler */ - void notifyNativeRequestSent(const AttPDUMsg& pduRequest, BTDeviceRef clientSource) noexcept; + void notifyNativeRequestSent(const AttPDUMsg& pduRequest, const BTDeviceRef& clientSource) noexcept; /** * Notify all NativeGattCharListener about a low-level AttPDUMsg reply being received from this GATTRole::Server. @@ -904,7 +905,7 @@ namespace direct_bt { * @param pduReply the response * @param clientDest the GATTRole::Client receiver device, only known and not nullptr for DBGattServer::Mode:FWD GattServerHandler */ - void notifyNativeReplyReceived(const AttPDUMsg& pduReply, BTDeviceRef clientDest) noexcept; + void notifyNativeReplyReceived(const AttPDUMsg& pduReply, const BTDeviceRef& clientDest) noexcept; /** * Notify all NativeGattCharListener about a completed MTU exchange request and response to and from this GATTRole::Server. @@ -921,7 +922,7 @@ namespace direct_bt { void notifyNativeMTUResponse(const uint16_t clientMTU, const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_reply, const uint16_t serverMTU, const uint16_t usedMTU, - BTDeviceRef clientRequester) noexcept; + const BTDeviceRef& clientRequester) noexcept; /** * Notify all NativeGattCharListener about a completed write request sent to this GATTRole::Server. @@ -934,7 +935,7 @@ namespace direct_bt { * @param with_response true if the write requests expects a response, i.e. via AttPDUMsg::Opcode::WRITE_REQ or AttPDUMsg::Opcode::EXECUTE_WRITE_REQ * @param clientSource the GATTRole::Client source device, only known and not nullptr for DBGattServer::Mode:FWD GattServerHandler */ - void notifyNativeWriteRequest(const uint16_t handle, const jau::TROOctets& data, const NativeGattCharSections_t& sections, const bool with_response, BTDeviceRef clientSource) noexcept; + void notifyNativeWriteRequest(const uint16_t handle, const jau::TROOctets& data, const NativeGattCharSections_t& sections, const bool with_response, const BTDeviceRef& clientSource) noexcept; /** * Notify all NativeGattCharListener about a write response received from this GATTRole::Server. @@ -945,7 +946,7 @@ namespace direct_bt { * @param error_code in case of an AttErrorRsp reply, the AttErrorRsp::ErrorCode is passed for convenience, otherwise AttErrorRsp::ErrorCode::NO_ERROR. * @param clientDest the GATTRole::Client receiver device, only known and not nullptr for DBGattServer::Mode:FWD GattServerHandler */ - void notifyNativeWriteResponse(const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_code, BTDeviceRef clientDest) noexcept; + void notifyNativeWriteResponse(const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_code, const BTDeviceRef& clientDest) noexcept; /** * Notify all NativeGattCharListener about a completed read request and response to and from this GATTRole::Server. @@ -961,7 +962,7 @@ namespace direct_bt { */ void notifyNativeReadResponse(const uint16_t handle, const uint16_t value_offset, const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_reply, const jau::TROOctets& data_reply, - BTDeviceRef clientRequester) noexcept; + const BTDeviceRef& clientRequester) noexcept; /** * Enable or disable sending an immediate confirmation for received indication events from the device. |