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