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 "qpid/framing/amqp_types.h"
00035 #include "qpid/framing/AMQRequestBody.h"
00036 #include "qpid/framing/Buffer.h"
00037 #include "qpid/framing/FieldTable.h"
00038 #include "qpid/framing/FramingContent.h"
00039
00040 namespace qpid
00041 {
00042 namespace framing
00043 {
00044
00045
00046 class QueueDeclareBody : public AMQRequestBody
00047 {
00048
00049
00050
00051 u_int16_t ticket;
00052 string queue;
00053 bool passive;
00054 bool durable;
00055 bool exclusive;
00056 bool autoDelete;
00057 bool nowait;
00058 FieldTable arguments;
00059
00060
00061 public:
00062 static const ClassId CLASS_ID= 50;
00063 static const MethodId METHOD_ID = 10;
00064
00065 typedef boost::shared_ptr<QueueDeclareBody> shared_ptr;
00066
00067
00068
00069 QueueDeclareBody(ProtocolVersion version,
00070 u_int16_t ticket,
00071 const string& queue,
00072 bool passive,
00073 bool durable,
00074 bool exclusive,
00075 bool autoDelete,
00076 bool nowait,
00077 const FieldTable& arguments
00078 ) : AMQRequestBody(version),
00079 ticket(ticket),
00080 queue(queue),
00081 passive(passive),
00082 durable(durable),
00083 exclusive(exclusive),
00084 autoDelete(autoDelete),
00085 nowait(nowait),
00086 arguments(arguments)
00087 { }
00088
00089
00090 QueueDeclareBody(ProtocolVersion version): AMQRequestBody(version) {}
00091 virtual ~QueueDeclareBody() {}
00092
00093
00094
00095 u_int16_t getTicket() { return ticket; }
00096 const string& getQueue() { return queue; }
00097 bool getPassive() { return passive; }
00098 bool getDurable() { return durable; }
00099 bool getExclusive() { return exclusive; }
00100 bool getAutoDelete() { return autoDelete; }
00101 bool getNowait() { return nowait; }
00102 const FieldTable& getArguments() { return arguments; }
00103
00104
00105
00106 inline void print(std::ostream& out) const
00107 {
00108 printPrefix(out);
00109 out << "QueueDeclare: ";
00110 out << "ticket=" << ticket;
00111 out << "; queue=" << queue;
00112 out << "; passive=" << passive;
00113 out << "; durable=" << durable;
00114 out << "; exclusive=" << exclusive;
00115 out << "; autoDelete=" << autoDelete;
00116 out << "; nowait=" << nowait;
00117 out << "; arguments=" << arguments;
00118 }
00119
00120 inline ClassId amqpClassId() const { return CLASS_ID; }
00121 inline MethodId amqpMethodId() const { return METHOD_ID; }
00122
00123 u_int32_t size() const
00124 {
00125 u_int32_t sz = baseSize();
00126 sz += 2;
00127 sz += 1 + queue.length();
00128 sz += 1;
00129 sz += arguments.size();
00130 return sz;
00131 }
00132
00133 void encodeContent(Buffer& buffer) const
00134 {
00135 buffer.putShort(ticket);
00136 buffer.putShortString(queue);
00137 u_int8_t flags_7[1] = {0};
00138 flags_7[0] |= passive << 0;
00139 flags_7[0] |= durable << 1;
00140 flags_7[0] |= exclusive << 2;
00141 flags_7[0] |= autoDelete << 3;
00142 flags_7[0] |= nowait << 4;
00143 buffer.putOctet(flags_7[0]);
00144 buffer.putFieldTable(arguments);
00145 }
00146
00147 inline void decodeContent(Buffer& buffer)
00148 {
00149 ticket = buffer.getShort();
00150 buffer.getShortString(queue);
00151 u_int8_t flags_7[1];
00152 flags_7[0] = buffer.getOctet();
00153 passive = (1 << 0) & flags_7[0];
00154 durable = (1 << 1) & flags_7[0];
00155 exclusive = (1 << 2) & flags_7[0];
00156 autoDelete = (1 << 3) & flags_7[0];
00157 nowait = (1 << 4) & flags_7[0];
00158 buffer.getFieldTable(arguments);
00159 }
00160
00161 void invoke(AMQP_ServerOperations& target, const MethodContext& context)
00162 {
00163 target.getQueueHandler()->declare(context,
00164 ticket,
00165 queue,
00166 passive,
00167 durable,
00168 exclusive,
00169 autoDelete,
00170 nowait,
00171 arguments
00172 );
00173 }
00174
00175
00176 };
00177
00178
00179 }
00180 }
00181
00182 #endif
00183