Skip to content

Commit

Permalink
Move IAP EndpointInfo and ConnectionInfo (#3199)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Nov 27, 2024
1 parent e063552 commit 75f1462
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 164 deletions.
62 changes: 62 additions & 0 deletions cpp/include/Ice/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
59 changes: 59 additions & 0 deletions cpp/include/Ice/Endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions cpp/include/Ice/Ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
76 changes: 0 additions & 76 deletions cpp/include/Ice/ios/iAPConnectionInfo.h

This file was deleted.

74 changes: 0 additions & 74 deletions cpp/include/Ice/ios/iAPEndpointInfo.h

This file was deleted.

1 change: 1 addition & 0 deletions cpp/src/Ice/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Ice::ConnectionInfo::~ConnectionInfo() {}
Ice::TCPConnectionInfo::~TCPConnectionInfo() {}
Ice::UDPConnectionInfo::~UDPConnectionInfo() {}
Ice::WSConnectionInfo::~WSConnectionInfo() {}
Ice::IAPConnectionInfo::~IAPConnectionInfo() {}

Ice::Connection::~Connection() {}

Expand Down
2 changes: 2 additions & 0 deletions cpp/src/Ice/EndpointI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Ice::UDPEndpointInfo::~UDPEndpointInfo() {}

Ice::WSEndpointInfo::~WSEndpointInfo() {}

Ice::IAPEndpointInfo::~IAPEndpointInfo() {}

Ice::OpaqueEndpointInfo::~OpaqueEndpointInfo() {}

void
Expand Down
8 changes: 1 addition & 7 deletions cpp/src/Ice/ios/iAPEndpointI.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/Ice/ios/iAPTransceiver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<IceIAP::ConnectionInfo>(
return make_shared<Ice::IAPConnectionInfo>(
std::move(adapterName),
std::move(connectionId),
[_session.accessory.name UTF8String],
[_session.accessory.manufacturer UTF8String],
Expand Down

0 comments on commit 75f1462

Please sign in to comment.