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_BasicConsumeBody__
00029 #define qpid_framing_BasicConsumeBody__
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 BasicConsumeBody : public AMQMethodBody
00046 {
00047
00048
00049 u_int16_t ticket;
00050 string queue;
00051 string consumerTag;
00052 bool noLocal;
00053 bool noAck;
00054 bool exclusive;
00055 bool nowait;
00056 FieldTable arguments;
00057
00058
00059 public:
00060 typedef boost::shared_ptr<BasicConsumeBody> shared_ptr;
00061
00062
00063
00064 BasicConsumeBody(ProtocolVersion& version,
00065 u_int16_t ticket,
00066 const string& queue,
00067 const string& consumerTag,
00068 bool noLocal,
00069 bool noAck,
00070 bool exclusive,
00071 bool nowait,
00072 const FieldTable& arguments
00073 ) :
00074 AMQMethodBody(version),
00075 ticket(ticket),
00076 queue(queue),
00077 consumerTag(consumerTag),
00078 noLocal(noLocal),
00079 noAck(noAck),
00080 exclusive(exclusive),
00081 nowait(nowait),
00082 arguments(arguments)
00083 { }
00084
00085
00086 inline BasicConsumeBody(u_int8_t major, u_int8_t minor): AMQMethodBody(major, minor) {}
00087 inline BasicConsumeBody(ProtocolVersion& version): AMQMethodBody(version) {}
00088 virtual ~BasicConsumeBody() {}
00089
00090
00091
00092 inline u_int16_t getTicket() { return ticket; }
00093 inline const string& getQueue() { return queue; }
00094 inline const string& getConsumerTag() { return consumerTag; }
00095 inline bool getNoLocal() { return noLocal; }
00096 inline bool getNoAck() { return noAck; }
00097 inline bool getExclusive() { return exclusive; }
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 << "BasicConsume: ";
00106 out << "ticket=" << ticket;
00107 out << "; queue=" << queue;
00108 out << "; consumerTag=" << consumerTag;
00109 out << "; noLocal=" << noLocal;
00110 out << "; noAck=" << noAck;
00111 out << "; exclusive=" << exclusive;
00112 out << "; nowait=" << nowait;
00113 out << "; arguments=" << arguments;
00114 }
00115
00116 inline u_int16_t amqpClassId() const
00117 {
00118 return 60;
00119 }
00120
00121 inline u_int16_t amqpMethodId() const
00122 {
00123 return 20;
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 + consumerTag.length();
00132 size += 1;
00133 size += arguments.size();
00134 return size;
00135 }
00136
00137 inline void encodeContent(Buffer& buffer) const
00138 {
00139 buffer.putShort(ticket);
00140 buffer.putShortString(queue);
00141 buffer.putShortString(consumerTag);
00142 u_int8_t flags_7[1] = {0};
00143 flags_7[0] |= noLocal << 0;
00144 flags_7[0] |= noAck << 1;
00145 flags_7[0] |= exclusive << 2;
00146 flags_7[0] |= nowait << 3;
00147 buffer.putOctet(flags_7[0]);
00148 buffer.putFieldTable(arguments);
00149 }
00150
00151 inline void decodeContent(Buffer& buffer)
00152 {
00153 ticket = buffer.getShort();
00154 buffer.getShortString(queue);
00155 buffer.getShortString(consumerTag);
00156 u_int8_t flags_7[1];
00157 flags_7[0] = buffer.getOctet();
00158 noLocal = (1 << 0) & flags_7[0];
00159 noAck = (1 << 1) & flags_7[0];
00160 exclusive = (1 << 2) & flags_7[0];
00161 nowait = (1 << 3) & flags_7[0];
00162 buffer.getFieldTable(arguments);
00163 }
00164
00165 inline void invoke(AMQP_ServerOperations& target, u_int16_t channel)
00166 {
00167 target.getBasicHandler()->consume(channel,
00168 ticket,
00169 queue,
00170 consumerTag,
00171 noLocal,
00172 noAck,
00173 exclusive,
00174 nowait,
00175 arguments
00176 );
00177 }
00178
00179
00180 };
00181
00182
00183 }
00184 }
00185
00186 #endif
00187