From 72deef05b91580c69b391b44f752e5de63a8d4ee Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Tue, 26 Nov 2024 16:22:50 -0500 Subject: [PATCH] Move IAP EndpointInfo and ConnectionInfo --- cpp/include/Ice/Connection.h | 62 ++++++++++++++++++++ cpp/include/Ice/Endpoint.h | 59 +++++++++++++++++++ cpp/include/Ice/Ice.h | 5 -- cpp/include/Ice/ios/iAPConnectionInfo.h | 76 ------------------------- cpp/include/Ice/ios/iAPEndpointInfo.h | 74 ------------------------ cpp/src/Ice/Connection.cpp | 1 + cpp/src/Ice/EndpointI.cpp | 2 + cpp/src/Ice/ios/iAPEndpointI.mm | 8 +-- cpp/src/Ice/ios/iAPTransceiver.mm | 4 +- 9 files changed, 127 insertions(+), 164 deletions(-) delete mode 100644 cpp/include/Ice/ios/iAPConnectionInfo.h delete mode 100644 cpp/include/Ice/ios/iAPEndpointInfo.h diff --git a/cpp/include/Ice/Connection.h b/cpp/include/Ice/Connection.h index c11a7a2da59..e6d7b0b2a5b 100644 --- a/cpp/include/Ice/Connection.h +++ b/cpp/include/Ice/Connection.h @@ -431,6 +431,68 @@ namespace Ice { } }; + + /** + * Provides access to the connection details of an IAP connection + * \headerfile Ice/Ice.h + */ + class IAPConnectionInfo final : public ConnectionInfo + { + public: + ~IAPConnectionInfo() final; + IAPConnectionInfo(const IAPConnectionInfo&) = delete; + IAPConnectionInfo& operator=(const IAPConnectionInfo&) = delete; + + /** + * The accessory name. + */ + const std::string name; + + /** + * The accessory manufacturer. + */ + const std::string manufacturer; + + /** + * The accessory model number. + */ + const std::string modelNumber; + + /** + * The accessory firmware revision. + */ + const std::string firmwareRevision; + + /** + * The accessory hardware revision. + */ + const std::string hardwareRevision; + + /** + * The protocol used by the accessory. + */ + const std::string protocol; + + // internal constructor + IAPConnectionInfo( + std::string adapterName, + std::string connectionId, + std::string name, + std::string manufacturer, + std::string modelNumber, + std::string firmwareRevision, + std::string hardwareRevision, + std::string protocol) + : ConnectionInfo{false, std::move(adapterName), std::move(connectionId)}, + name{std::move(name)}, + manufacturer{std::move(manufacturer)}, + modelNumber{std::move(modelNumber)}, + firmwareRevision{std::move(firmwareRevision)}, + hardwareRevision{std::move(hardwareRevision)}, + protocol{std::move(protocol)} + { + } + }; } #if defined(__clang__) diff --git a/cpp/include/Ice/Endpoint.h b/cpp/include/Ice/Endpoint.h index e715706737e..04b7a111584 100644 --- a/cpp/include/Ice/Endpoint.h +++ b/cpp/include/Ice/Endpoint.h @@ -235,6 +235,65 @@ namespace Ice } }; + /** + * Provides access to an IAP endpoint information. + * \headerfile Ice/Ice.h + */ + class IAPEndpointInfo final : public EndpointInfo + { + public: + ~IAPEndpointInfo() final; + IAPEndpointInfo(const IAPEndpointInfo&) = delete; + IAPEndpointInfo& operator=(const IAPEndpointInfo&) = delete; + + std::int16_t type() const noexcept final { return _type; } + bool secure() const noexcept final { return _secure; } + + /** + * The accessory manufacturer or empty to not match against + * a manufacturer. + */ + const std::string manufacturer; + /** + * The accessory model number or empty to not match against + * a model number. + */ + const std::string modelNumber; + /** + * The accessory name or empty to not match against + * the accessory name. + */ + const std::string name; + /** + * The protocol supported by the accessory. + */ + const std::string protocol; + + // internal constructor + IAPEndpointInfo( + int timeout, + bool compress, + std::string manufacturer, + std::string modelNumber, + std::string name, + std::string protocol, + std::int16_t type, + bool secure) + : EndpointInfo{timeout, compress}, + manufacturer{std::move(manufacturer)}, + modelNumber{std::move(modelNumber)}, + name{std::move(name)}, + protocol{std::move(protocol)}, + _type{type}, + _secure{secure} + { + } + + private: + const std::int16_t _type; + const bool _secure; + }; + /** * Provides access to the details of an opaque endpoint. * @see Endpoint diff --git a/cpp/include/Ice/Ice.h b/cpp/include/Ice/Ice.h index 743dec4cb62..bf144b33298 100644 --- a/cpp/include/Ice/Ice.h +++ b/cpp/include/Ice/Ice.h @@ -57,11 +57,6 @@ # include "Ice/RemoteLogger.h" # include "Ice/Router.h" -// Include Apple iAP headers if building for iOS -# if defined(__APPLE__) && TARGET_OS_IPHONE != 0 -# include "ios/iAPConnectionInfo.h" -# include "ios/iAPEndpointInfo.h" -# endif #endif #endif diff --git a/cpp/include/Ice/ios/iAPConnectionInfo.h b/cpp/include/Ice/ios/iAPConnectionInfo.h deleted file mode 100644 index 728a420906f..00000000000 --- a/cpp/include/Ice/ios/iAPConnectionInfo.h +++ /dev/null @@ -1,76 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#ifndef ICE_IAP_CONNECTION_INFO_H -#define ICE_IAP_CONNECTION_INFO_H - -#include "../Connection.h" - -namespace IceIAP -{ - /** - * Provides access to the connection details of an IAP connection - * \headerfile Ice/Ice.h - */ - class ConnectionInfo final : public Ice::ConnectionInfo - { - public: - ~ConnectionInfo() final; - ConnectionInfo(const ConnectionInfo&) = delete; - ConnectionInfo& operator=(const ConnectionInfo&) = delete; - - /** - * The accessory name. - */ - const std::string name; - - /** - * The accessory manufacturer. - */ - const std::string manufacturer; - - /** - * The accessory model number. - */ - const std::string modelNumber; - - /** - * The accessory firmware revision. - */ - const std::string firmwareRevision; - - /** - * The accessory hardware revision. - */ - const std::string hardwareRevision; - - /** - * The protocol used by the accessory. - */ - const std::string protocol; - - // internal constructor - ConnectionInfo( - std::string connectionId, - std::string name, - std::string manufacturer, - std::string modelNumber, - std::string firmwareRevision, - std::string hardwareRevision, - std::string protocol) - : Ice::ConnectionInfo{false, "", std::move(connectionId)}, - name{std::move(name)}, - manufacturer{std::move(manufacturer)}, - modelNumber{std::move(modelNumber)}, - firmwareRevision{std::move(firmwareRevision)}, - hardwareRevision{std::move(hardwareRevision)}, - protocol{std::move(protocol)} - { - } - }; - - using ConnectionInfoPtr = std::shared_ptr; -} - -#endif diff --git a/cpp/include/Ice/ios/iAPEndpointInfo.h b/cpp/include/Ice/ios/iAPEndpointInfo.h deleted file mode 100644 index a7f6b2fe8d9..00000000000 --- a/cpp/include/Ice/ios/iAPEndpointInfo.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#ifndef ICE_IAP_ENDPOINT_INFO_H -#define ICE_IAP_ENDPOINT_INFO_H - -#include "../Endpoint.h" - -namespace IceIAP -{ - /** - * Provides access to an IAP endpoint information. - * \headerfile Ice/Ice.h - */ - class EndpointInfo final : public Ice::EndpointInfo - { - public: - ~EndpointInfo() final; - EndpointInfo(const EndpointInfo&) = delete; - EndpointInfo& operator=(const EndpointInfo&) = delete; - - std::int16_t type() const noexcept final { return _type; } - bool secure() const noexcept final { return _secure; } - - /** - * The accessory manufacturer or empty to not match against - * a manufacturer. - */ - const std::string manufacturer; - /** - * The accessory model number or empty to not match against - * a model number. - */ - const std::string modelNumber; - /** - * The accessory name or empty to not match against - * the accessory name. - */ - const std::string name; - /** - * The protocol supported by the accessory. - */ - const std::string protocol; - - // internal constructor - EndpointInfo( - int timeout, - bool compress, - std::string manufacturer, - std::string modelNumber, - std::string name, - std::string protocol, - std::int16_t type, - bool secure) - : Ice::EndpointInfo{timeout, compress}, - manufacturer{std::move(manufacturer)}, - modelNumber{std::move(modelNumber)}, - name{std::move(name)}, - protocol{std::move(protocol)}, - _type{type}, - _secure{secure} - { - } - - private: - const std::int16_t _type; - const bool _secure; - }; - - using EndpointInfoPtr = std::shared_ptr; -} - -#endif diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index 787bc2a5991..036964b6006 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -12,6 +12,7 @@ Ice::ConnectionInfo::~ConnectionInfo() {} Ice::TCPConnectionInfo::~TCPConnectionInfo() {} Ice::UDPConnectionInfo::~UDPConnectionInfo() {} Ice::WSConnectionInfo::~WSConnectionInfo() {} +Ice::IAPConnectionInfo::~IAPConnectionInfo() {} Ice::Connection::~Connection() {} diff --git a/cpp/src/Ice/EndpointI.cpp b/cpp/src/Ice/EndpointI.cpp index e6c18692a8b..70229a38553 100644 --- a/cpp/src/Ice/EndpointI.cpp +++ b/cpp/src/Ice/EndpointI.cpp @@ -43,6 +43,8 @@ Ice::UDPEndpointInfo::~UDPEndpointInfo() {} Ice::WSEndpointInfo::~WSEndpointInfo() {} +Ice::IAPEndpointInfo::~IAPEndpointInfo() {} + Ice::OpaqueEndpointInfo::~OpaqueEndpointInfo() {} void diff --git a/cpp/src/Ice/ios/iAPEndpointI.mm b/cpp/src/Ice/ios/iAPEndpointI.mm index 203894a824a..b1aeb0a1de9 100644 --- a/cpp/src/Ice/ios/iAPEndpointI.mm +++ b/cpp/src/Ice/ios/iAPEndpointI.mm @@ -18,8 +18,6 @@ # include "Ice/OutputStream.h" # include "Ice/Properties.h" # include "Ice/RegisterPlugins.h" -# include "Ice/ios/iAPConnectionInfo.h" -# include "Ice/ios/iAPEndpointInfo.h" # include "iAPConnector.h" # include "iAPEndpointI.h" @@ -76,10 +74,6 @@ ICEIAP_API void registerIceIAP(bool loadOnInitialize) } } -// Implement virtual destructors out of line to avoid weak vtables. -IceIAP::ConnectionInfo::~ConnectionInfo() {} -IceIAP::EndpointInfo::~EndpointInfo() {} - IceObjC::iAPEndpointI::iAPEndpointI( const ProtocolInstancePtr& instance, const string& m, @@ -135,7 +129,7 @@ ICEIAP_API void registerIceIAP(bool loadOnInitialize) IceObjC::iAPEndpointI::getInfo() const noexcept { return make_shared< - IceIAP::EndpointInfo>(_timeout, _compress, _manufacturer, _modelNumber, _name, protocol(), type(), secure()); + Ice::IAPEndpointInfo>(_timeout, _compress, _manufacturer, _modelNumber, _name, protocol(), type(), secure()); } int16_t diff --git a/cpp/src/Ice/ios/iAPTransceiver.mm b/cpp/src/Ice/ios/iAPTransceiver.mm index b953ed74147..1b4d1a3c4ed 100644 --- a/cpp/src/Ice/ios/iAPTransceiver.mm +++ b/cpp/src/Ice/ios/iAPTransceiver.mm @@ -383,9 +383,9 @@ - (void)stream:(NSStream*)stream handleEvent:(NSStreamEvent)eventCode IceObjC::iAPTransceiver::getInfo(bool incoming, string adapterName, string connectionId) const { assert(!incoming); - assert(adapterName.empty()); - return make_shared( + return make_shared( + std::move(adapterName), std::move(connectionId), [_session.accessory.name UTF8String], [_session.accessory.manufacturer UTF8String],