summaryrefslogtreecommitdiff
path: root/cpp/include/qpid/Address.h
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2010-05-11 14:39:58 +0000
committerAlan Conway <aconway@apache.org>2010-05-11 14:39:58 +0000
commit16da0e0c511c0c1cf4ea592640c522754065200a (patch)
tree59fb80994db731fabe19897c95a6912e68716360 /cpp/include/qpid/Address.h
parentbe8e1bf6b6a0d760bddbbe6642d477a95f36ab42 (diff)
downloadqpid-python-16da0e0c511c0c1cf4ea592640c522754065200a.tar.gz
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
Diffstat (limited to 'cpp/include/qpid/Address.h')
-rwxr-xr-xcpp/include/qpid/Address.h62
1 files changed, 16 insertions, 46 deletions
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 <boost/variant.hpp>
#include <iosfwd>
#include <string>
-#include <vector>
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 <class AddressType> 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 <class AddressType> AddressType* get() { return boost::get<AddressType>(&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 <class AddressType> const AddressType* get() const { return boost::get<AddressType>(&value); }
-
-private:
- boost::variant<TcpAddress,ExampleAddress> 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