diff options
Diffstat (limited to 'cpp/src/qpid/cluster/Event.h')
-rw-r--r-- | cpp/src/qpid/cluster/Event.h | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/cpp/src/qpid/cluster/Event.h b/cpp/src/qpid/cluster/Event.h index 427410923b..c63e09ca46 100644 --- a/cpp/src/qpid/cluster/Event.h +++ b/cpp/src/qpid/cluster/Event.h @@ -36,26 +36,44 @@ namespace cluster { // byte-stream data. // +/** Header data for a multicast event */ +class EventHeader { + public: + EventHeader(EventType t=DATA, const ConnectionId& c=ConnectionId(), size_t size=0); + void decode(const MemberId& m, framing::Buffer&); + void encode(framing::Buffer&) const; + + EventType getType() const { return type; } + ConnectionId getConnectionId() const { return connectionId; } + MemberId getMemberId() const { return connectionId.getMember(); } + size_t getSize() const { return size; } + + bool isCluster() const { return connectionId.getPointer() == 0; } + bool isConnection() const { return connectionId.getPointer() != 0; } + + protected: + static const size_t HEADER_SIZE; + + EventType type; + ConnectionId connectionId; + size_t size; +}; + /** * Events are sent to/received from the cluster. * Refcounted so they can be stored on queues. */ -class Event { +class Event : public EventHeader { public: /** Create an event with a buffer that can hold size bytes plus an event header. */ Event(EventType t=DATA, const ConnectionId& c=ConnectionId(), size_t size=0); /** Create an event copied from delivered data. */ - static Event decode(const MemberId& m, framing::Buffer&); + static Event decodeCopy(const MemberId& m, framing::Buffer&); /** Create an event containing a control */ static Event control(const framing::AMQBody&, const ConnectionId&); - EventType getType() const { return type; } - ConnectionId getConnectionId() const { return connectionId; } - MemberId getMemberId() const { return connectionId.getMember(); } - size_t getSize() const { return size; } - // Data excluding header. char* getData() { return store + HEADER_SIZE; } const char* getData() const { return store + HEADER_SIZE; } @@ -65,19 +83,11 @@ class Event { const char* getStore() const { return store; } size_t getStoreSize() { return size + HEADER_SIZE; } - bool isCluster() const { return connectionId.getPointer() == 0; } - bool isConnection() const { return connectionId.getPointer() != 0; } - operator framing::Buffer() const; private: - static const size_t HEADER_SIZE; - void encodeHeader(); - EventType type; - ConnectionId connectionId; - size_t size; RefCountedBuffer::pointer store; }; |