00001 #ifndef QPID_CLUSTER_EVENT_H
00002 #define QPID_CLUSTER_EVENT_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "types.h"
00026 #include "Cpg.h"
00027 #include "Connection.h"
00028 #include "qpid/RefCountedBuffer.h"
00029 #include "qpid/framing/Buffer.h"
00030 #include <iosfwd>
00031
00032 namespace qpid {
00033 namespace cluster {
00034
00035
00036
00037
00038
00043 class Event {
00044 public:
00046 Event(EventType t=DATA, const ConnectionId& c=ConnectionId(), size_t size=0, uint32_t id=0);
00047
00049 static Event delivered(const MemberId& m, void* data, size_t size);
00050
00052 static Event control(const framing::AMQBody&, const ConnectionId&, uint32_t id=0);
00053
00054 void mcast(const Cpg::Name& name, Cpg& cpg) const;
00055
00056 EventType getType() const { return type; }
00057 ConnectionId getConnectionId() const { return connectionId; }
00058 MemberId getMemberId() const { return connectionId.getMember(); }
00059 size_t getSize() const { return size; }
00060 char* getData() { return data; }
00061 const char* getData() const { return data; }
00062 size_t getId() const { return id; }
00063 bool isCluster() const { return connectionId.getPointer() == 0; }
00064 bool isConnection() const { return connectionId.getPointer() != 0; }
00065
00066 operator framing::Buffer() const;
00067
00068 private:
00069 static const size_t OVERHEAD;
00070 EventType type;
00071 ConnectionId connectionId;
00072 size_t size;
00073 RefCountedBuffer::pointer data;
00074 uint32_t id;
00075 };
00076
00077 std::ostream& operator << (std::ostream&, const Event&);
00078 }}
00079
00080 #endif