From 16da0e0c511c0c1cf4ea592640c522754065200a Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 11 May 2010 14:39:58 +0000 Subject: Support for multiple protocols in qpid::Url. - simplified qpid::Address to hold (protocol,host,port) triples. - protocol plugins call Url:addProtocol to add tags to Url parser. - use Address::protocol when establishing connections. - ssl_test: tests using URL to connect. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@943130 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/include/qpid/Address.h | 62 ++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 46 deletions(-) (limited to 'cpp/include/qpid/Address.h') diff --git a/cpp/include/qpid/Address.h b/cpp/include/qpid/Address.h index fe82b21b9e..71da7b25db 100755 --- a/cpp/include/qpid/Address.h +++ b/cpp/include/qpid/Address.h @@ -21,64 +21,34 @@ #include "qpid/sys/IntegerTypes.h" #include "qpid/CommonImportExport.h" -#include #include #include -#include namespace qpid { +namespace client { class ConnectionSettings; } -/** TCP address of a broker - host:port */ -struct TcpAddress { - static const uint16_t DEFAULT_PORT=5672; - QPID_COMMON_EXTERN explicit TcpAddress(const std::string& host_=std::string(),uint16_t port_=DEFAULT_PORT); - std::string host; - uint16_t port; -}; -bool operator==(const TcpAddress& x, const TcpAddress& y); -QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const TcpAddress& a); - -/**@internal Not a real address type, this is a placeholder to - * demonstrate and validate multi-protocol Urls for unit tests and - * developer education only. An example address holds just a char. - */ -struct ExampleAddress { - explicit ExampleAddress(char data); - char data; -}; -bool operator==(const ExampleAddress& x, const ExampleAddress& y); -std::ostream& operator<<(std::ostream& os, const ExampleAddress& a); /** - * Contains the address of an AMQP broker. Can any supported type of - * broker address. Currently only TcpAddress is supported. + * Contains the protocol address of an AMQP broker. */ struct Address { public: - Address(const Address& a) : value(a.value) {} - Address(const TcpAddress& tcp) : value(tcp) {} - Address(const ExampleAddress& eg) : value(eg) {} ///<@internal - - template Address& operator=(const AddressType& t) { value=t; return *this; } - - /** Get the address of type AddressType. - *@return AddressType* pointing to the contained address or 0 if - *contained address is not of type AddressType. - */ - template AddressType* get() { return boost::get(&value); } - - /** Get the address of type AddressType. - *@return AddressType* pointing to the contained address or 0 if - *contained address is not of type AddressType. - */ - template const AddressType* get() const { return boost::get(&value); } - -private: - boost::variant value; - friend std::ostream& operator<<(std::ostream& os, const Address& addr); + static const std::string TCP; // Default TCP protocol tag. + static const uint16_t AMQP_PORT=5672; // Default AMQP port. + + QPID_COMMON_EXTERN explicit Address( + const std::string& protocol_=std::string(), + const std::string& host_=std::string(), + uint16_t port_=0 + ) : protocol(protocol_), host(host_), port(port_) {} + + std::string protocol; + std::string host; + uint16_t port; }; - +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const Address& addr); +QPID_COMMON_EXTERN bool operator==(const Address& x, const Address& y); } // namespace qpid -- cgit v1.2.1