diff options
| author | Alan Conway <aconway@apache.org> | 2008-12-12 15:23:39 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-12-12 15:23:39 +0000 |
| commit | c3a95e5db514598ecf0a543ceccd4e4a4084ca39 (patch) | |
| tree | 6cf3b6bfcd5f60760098424c9782fe6bd680a287 /cpp/src/qpid/cluster/Event.h | |
| parent | 3ff85ea13d228f4f548c98d0c72219ec5faff552 (diff) | |
| download | qpid-python-c3a95e5db514598ecf0a543ceccd4e4a4084ca39.tar.gz | |
cluster/Event: store event header in the same buffer as data to simplify encoding.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@726043 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/cluster/Event.h')
| -rw-r--r-- | cpp/src/qpid/cluster/Event.h | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/cpp/src/qpid/cluster/Event.h b/cpp/src/qpid/cluster/Event.h index e046990747..427410923b 100644 --- a/cpp/src/qpid/cluster/Event.h +++ b/cpp/src/qpid/cluster/Event.h @@ -42,36 +42,43 @@ namespace cluster { */ class Event { public: - /** Create an event to mcast with a buffer of size bytes. */ - Event(EventType t=DATA, const ConnectionId& c=ConnectionId(), size_t size=0, uint32_t id=0); + /** 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&); /** Create an event containing a control */ - static Event control(const framing::AMQBody&, const ConnectionId&, uint32_t id=0); - - bool mcast(Cpg& cpg) const; + 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; } - char* getData() { return data; } - const char* getData() const { return data; } - size_t getId() const { return id; } + + // Data excluding header. + char* getData() { return store + HEADER_SIZE; } + const char* getData() const { return store + HEADER_SIZE; } + + // Store including header + char* getStore() { return store; } + 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 OVERHEAD; + static const size_t HEADER_SIZE; + + void encodeHeader(); + EventType type; ConnectionId connectionId; size_t size; - RefCountedBuffer::pointer data; - uint32_t id; + RefCountedBuffer::pointer store; }; std::ostream& operator << (std::ostream&, const Event&); |
