diff options
Diffstat (limited to 'cpp/src/qpid/cluster/Cpg.h')
| -rw-r--r-- | cpp/src/qpid/cluster/Cpg.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/cpp/src/qpid/cluster/Cpg.h b/cpp/src/qpid/cluster/Cpg.h index 1ed362f94e..a918fb0cbf 100644 --- a/cpp/src/qpid/cluster/Cpg.h +++ b/cpp/src/qpid/cluster/Cpg.h @@ -22,6 +22,8 @@ #include "qpid/Exception.h" #include "qpid/cluster/Dispatchable.h" +#include <boost/tuple/tuple.hpp> +#include <boost/tuple/tuple_comparison.hpp> #include <cassert> #include <string.h> @@ -55,16 +57,14 @@ class Cpg : public Dispatchable { std::string str() const { return std::string(value, length); } }; - - struct Id { - uint64_t id; - Id(uint64_t n=0) : id(n) {} - Id(uint32_t nodeid, uint32_t pid) { id=(uint64_t(nodeid)<<32)+ pid; } - Id(const cpg_address& addr) : id(Id(addr.nodeid, addr.pid)) {} - - operator uint64_t() const { return id; } - uint32_t nodeId() const { return id >> 32; } - pid_t pid() const { return id & 0xFFFF; } + + + // boost::tuple gives us == and < for free. + struct Id : public boost::tuple<uint32_t, uint32_t> { + Id(uint32_t n=0, uint32_t p=0) : boost::tuple<uint32_t, uint32_t>(n, p) {} + Id(const cpg_address& addr) : boost::tuple<uint32_t, uint32_t>(addr.nodeid, addr.pid) {} + uint32_t getNodeId() const { return boost::get<0>(*this); } + uint32_t getPid() const { return boost::get<1>(*this); } }; static std::string str(const cpg_name& n) { @@ -131,6 +131,8 @@ class Cpg : public Dispatchable { cpg_handle_t getHandle() const { return handle; } + Id self() const; + private: class Handles; struct ClearHandleOnExit; |
