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_FilePublishBody__
00029 #define qpid_framing_FilePublishBody__
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 FilePublishBody : public AMQRequestBody
00047 {
00048
00049
00050
00051 u_int16_t ticket;
00052 string exchange;
00053 string routingKey;
00054 bool mandatory;
00055 bool immediate;
00056 string identifier;
00057
00058
00059 public:
00060 static const ClassId CLASS_ID= 70;
00061 static const MethodId METHOD_ID = 60;
00062
00063 typedef boost::shared_ptr<FilePublishBody> shared_ptr;
00064
00065
00066
00067 FilePublishBody(ProtocolVersion version,
00068 u_int16_t ticket,
00069 const string& exchange,
00070 const string& routingKey,
00071 bool mandatory,
00072 bool immediate,
00073 const string& identifier
00074 ) : AMQRequestBody(version),
00075 ticket(ticket),
00076 exchange(exchange),
00077 routingKey(routingKey),
00078 mandatory(mandatory),
00079 immediate(immediate),
00080 identifier(identifier)
00081 { }
00082
00083
00084 FilePublishBody(ProtocolVersion version): AMQRequestBody(version) {}
00085 virtual ~FilePublishBody() {}
00086
00087
00088
00089 u_int16_t getTicket() { return ticket; }
00090 const string& getExchange() { return exchange; }
00091 const string& getRoutingKey() { return routingKey; }
00092 bool getMandatory() { return mandatory; }
00093 bool getImmediate() { return immediate; }
00094 const string& getIdentifier() { return identifier; }
00095
00096
00097
00098 inline void print(std::ostream& out) const
00099 {
00100 printPrefix(out);
00101 out << "FilePublish: ";
00102 out << "ticket=" << ticket;
00103 out << "; exchange=" << exchange;
00104 out << "; routingKey=" << routingKey;
00105 out << "; mandatory=" << mandatory;
00106 out << "; immediate=" << immediate;
00107 out << "; identifier=" << identifier;
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 + exchange.length();
00118 sz += 1 + routingKey.length();
00119 sz += 1;
00120 sz += 1 + identifier.length();
00121 return sz;
00122 }
00123
00124 void encodeContent(Buffer& buffer) const
00125 {
00126 buffer.putShort(ticket);
00127 buffer.putShortString(exchange);
00128 buffer.putShortString(routingKey);
00129 u_int8_t flags_5[1] = {0};
00130 flags_5[0] |= mandatory << 0;
00131 flags_5[0] |= immediate << 1;
00132 buffer.putOctet(flags_5[0]);
00133 buffer.putShortString(identifier);
00134 }
00135
00136 inline void decodeContent(Buffer& buffer)
00137 {
00138 ticket = buffer.getShort();
00139 buffer.getShortString(exchange);
00140 buffer.getShortString(routingKey);
00141 u_int8_t flags_5[1];
00142 flags_5[0] = buffer.getOctet();
00143 mandatory = (1 << 0) & flags_5[0];
00144 immediate = (1 << 1) & flags_5[0];
00145 buffer.getShortString(identifier);
00146 }
00147
00148 void invoke(AMQP_ServerOperations& target, const MethodContext& context)
00149 {
00150 target.getFileHandler()->publish(context,
00151 ticket,
00152 exchange,
00153 routingKey,
00154 mandatory,
00155 immediate,
00156 identifier
00157 );
00158 }
00159
00160
00161 };
00162
00163
00164 }
00165 }
00166
00167 #endif
00168