00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef qpid_framing_QueueDeclareBody__
00029 #define qpid_framing_QueueDeclareBody__
00030
00031 #include <string>
00032 #include <sstream>
00033
00034 #include <amqp_types.h>
00035 #include <AMQMethodBody.h>
00036 #include <Buffer.h>
00037 #include <FieldTable.h>
00038
00039 namespace qpid
00040 {
00041 namespace framing
00042 {
00043
00044
00045 class QueueDeclareBody : public AMQMethodBody
00046 {
00047
00048
00049 u_int16_t ticket;
00050 string queue;
00051 bool passive;
00052 bool durable;
00053 bool exclusive;
00054 bool autoDelete;
00055 bool nowait;
00056 FieldTable arguments;
00057
00058
00059 public:
00060 typedef boost::shared_ptr<QueueDeclareBody> shared_ptr;
00061
00062
00063
00064 QueueDeclareBody(ProtocolVersion& version,
00065 u_int16_t ticket,
00066 const string& queue,
00067 bool passive,
00068 bool durable,
00069 bool exclusive,
00070 bool autoDelete,
00071 bool nowait,
00072 const FieldTable& arguments
00073 ) :
00074 AMQMethodBody(version),
00075 ticket(ticket),
00076 queue(queue),
00077 passive(passive),
00078 durable(durable),
00079 exclusive(exclusive),
00080 autoDelete(autoDelete),
00081 nowait(nowait),
00082 arguments(arguments)
00083 { }
00084
00085
00086 inline QueueDeclareBody(u_int8_t major, u_int8_t minor): AMQMethodBody(major, minor) {}
00087 inline QueueDeclareBody(ProtocolVersion& version): AMQMethodBody(version) {}
00088 virtual ~QueueDeclareBody() {}
00089
00090
00091
00092 inline u_int16_t getTicket() { return ticket; }
00093 inline const string& getQueue() { return queue; }
00094 inline bool getPassive() { return passive; }
00095 inline bool getDurable() { return durable; }
00096 inline bool getExclusive() { return exclusive; }
00097 inline bool getAutoDelete() { return autoDelete; }
00098 inline bool getNowait() { return nowait; }
00099 inline const FieldTable& getArguments() { return arguments; }
00100
00101
00102
00103 inline void print(std::ostream& out) const
00104 {
00105 out << "QueueDeclare: ";
00106 out << "ticket=" << ticket;
00107 out << "; queue=" << queue;
00108 out << "; passive=" << passive;
00109 out << "; durable=" << durable;
00110 out << "; exclusive=" << exclusive;
00111 out << "; autoDelete=" << autoDelete;
00112 out << "; nowait=" << nowait;
00113 out << "; arguments=" << arguments;
00114 }
00115
00116 inline u_int16_t amqpClassId() const
00117 {
00118 return 50;
00119 }
00120
00121 inline u_int16_t amqpMethodId() const
00122 {
00123 return 10;
00124 }
00125
00126 inline u_int32_t bodySize() const
00127 {
00128 u_int32_t size = 0;
00129 size += 2;
00130 size += 1 + queue.length();
00131 size += 1;
00132 size += arguments.size();
00133 return size;
00134 }
00135
00136 inline void encodeContent(Buffer& buffer) const
00137 {
00138 buffer.putShort(ticket);
00139 buffer.putShortString(queue);
00140 u_int8_t flags_7[1] = {0};
00141 flags_7[0] |= passive << 0;
00142 flags_7[0] |= durable << 1;
00143 flags_7[0] |= exclusive << 2;
00144 flags_7[0] |= autoDelete << 3;
00145 flags_7[0] |= nowait << 4;
00146 buffer.putOctet(flags_7[0]);
00147 buffer.putFieldTable(arguments);
00148 }
00149
00150 inline void decodeContent(Buffer& buffer)
00151 {
00152 ticket = buffer.getShort();
00153 buffer.getShortString(queue);
00154 u_int8_t flags_7[1];
00155 flags_7[0] = buffer.getOctet();
00156 passive = (1 << 0) & flags_7[0];
00157 durable = (1 << 1) & flags_7[0];
00158 exclusive = (1 << 2) & flags_7[0];
00159 autoDelete = (1 << 3) & flags_7[0];
00160 nowait = (1 << 4) & flags_7[0];
00161 buffer.getFieldTable(arguments);
00162 }
00163
00164 inline void invoke(AMQP_ServerOperations& target, u_int16_t channel)
00165 {
00166 target.getQueueHandler()->declare(channel,
00167 ticket,
00168 queue,
00169 passive,
00170 durable,
00171 exclusive,
00172 autoDelete,
00173 nowait,
00174 arguments
00175 );
00176 }
00177
00178
00179 };
00180
00181
00182 }
00183 }
00184
00185 #endif
00186