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_QueueBindBody__
00029 #define qpid_framing_QueueBindBody__
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 QueueBindBody : public AMQRequestBody
00047 {
00048
00049
00050
00051 u_int16_t ticket;
00052 string queue;
00053 string exchange;
00054 string routingKey;
00055 bool nowait;
00056 FieldTable arguments;
00057
00058
00059 public:
00060 static const ClassId CLASS_ID= 50;
00061 static const MethodId METHOD_ID = 20;
00062
00063 typedef boost::shared_ptr<QueueBindBody> shared_ptr;
00064
00065
00066
00067 QueueBindBody(ProtocolVersion version,
00068 u_int16_t ticket,
00069 const string& queue,
00070 const string& exchange,
00071 const string& routingKey,
00072 bool nowait,
00073 const FieldTable& arguments
00074 ) : AMQRequestBody(version),
00075 ticket(ticket),
00076 queue(queue),
00077 exchange(exchange),
00078 routingKey(routingKey),
00079 nowait(nowait),
00080 arguments(arguments)
00081 { }
00082
00083
00084 QueueBindBody(ProtocolVersion version): AMQRequestBody(version) {}
00085 virtual ~QueueBindBody() {}
00086
00087
00088
00089 u_int16_t getTicket() { return ticket; }
00090 const string& getQueue() { return queue; }
00091 const string& getExchange() { return exchange; }
00092 const string& getRoutingKey() { return routingKey; }
00093 bool getNowait() { return nowait; }
00094 const FieldTable& getArguments() { return arguments; }
00095
00096
00097
00098 inline void print(std::ostream& out) const
00099 {
00100 printPrefix(out);
00101 out << "QueueBind: ";
00102 out << "ticket=" << ticket;
00103 out << "; queue=" << queue;
00104 out << "; exchange=" << exchange;
00105 out << "; routingKey=" << routingKey;
00106 out << "; nowait=" << nowait;
00107 out << "; arguments=" << arguments;
00108 }
00109
00110 inline ClassId amqpClassId() const { return CLASS_ID; }
00111 inline MethodId amqpMethodId() const { return METHOD_ID; }
00112
00113 u_int32_t size() const
00114 {
00115 u_int32_t sz = baseSize();
00116 sz += 2;
00117 sz += 1 + queue.length();
00118 sz += 1 + exchange.length();
00119 sz += 1 + routingKey.length();
00120 sz += 1;
00121 sz += arguments.size();
00122 return sz;
00123 }
00124
00125 void encodeContent(Buffer& buffer) const
00126 {
00127 buffer.putShort(ticket);
00128 buffer.putShortString(queue);
00129 buffer.putShortString(exchange);
00130 buffer.putShortString(routingKey);
00131 u_int8_t flags_5[1] = {0};
00132 flags_5[0] |= nowait << 0;
00133 buffer.putOctet(flags_5[0]);
00134 buffer.putFieldTable(arguments);
00135 }
00136
00137 inline void decodeContent(Buffer& buffer)
00138 {
00139 ticket = buffer.getShort();
00140 buffer.getShortString(queue);
00141 buffer.getShortString(exchange);
00142 buffer.getShortString(routingKey);
00143 u_int8_t flags_5[1];
00144 flags_5[0] = buffer.getOctet();
00145 nowait = (1 << 0) & flags_5[0];
00146 buffer.getFieldTable(arguments);
00147 }
00148
00149 void invoke(AMQP_ServerOperations& target, const MethodContext& context)
00150 {
00151 target.getQueueHandler()->bind(context,
00152 ticket,
00153 queue,
00154 exchange,
00155 routingKey,
00156 nowait,
00157 arguments
00158 );
00159 }
00160
00161
00162 };
00163
00164
00165 }
00166 }
00167
00168 #endif
00169