00001 #ifndef QPID_FRAMING_EXCHANGEDECLAREBODY_H
00002 #define QPID_FRAMING_EXCHANGEDECLAREBODY_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028
00029
00030 #include "qpid/framing/AMQMethodBody.h"
00031 #include "qpid/framing/AMQP_ServerOperations.h"
00032 #include "qpid/framing/MethodBodyConstVisitor.h"
00033 #include "qpid/framing/ModelMethod.h"
00034
00035 #include <ostream>
00036 #include "qpid/framing/amqp_types_full.h"
00037
00038 namespace qpid {
00039 namespace framing {
00040
00041 class ExchangeDeclareBody : public ModelMethod {
00042 string exchange;
00043 string type;
00044 string alternateExchange;
00045 FieldTable arguments;
00046 uint16_t flags;
00047 public:
00048 static const ClassId CLASS_ID = 0x7;
00049 static const MethodId METHOD_ID = 0x1;
00050 ExchangeDeclareBody(
00051 ProtocolVersion, const string& _exchange,
00052 const string& _type,
00053 const string& _alternateExchange,
00054 bool _passive,
00055 bool _durable,
00056 bool _autoDelete,
00057 const FieldTable& _arguments) :
00058 exchange(_exchange),
00059 type(_type),
00060 alternateExchange(_alternateExchange),
00061 arguments(_arguments),
00062 flags(0){
00063 setPassive(_passive);
00064 setDurable(_durable);
00065 setAutoDelete(_autoDelete);
00066 flags |= (1 << 8);
00067 flags |= (1 << 9);
00068 flags |= (1 << 10);
00069 flags |= (1 << 14);
00070 }
00071 ExchangeDeclareBody(ProtocolVersion=ProtocolVersion()) : flags(0) {}
00072
00073 void setExchange(const string& _exchange);
00074 const string& getExchange() const;
00075 bool hasExchange() const;
00076 void clearExchangeFlag();
00077 void setType(const string& _type);
00078 const string& getType() const;
00079 bool hasType() const;
00080 void clearTypeFlag();
00081 void setAlternateExchange(const string& _alternateExchange);
00082 const string& getAlternateExchange() const;
00083 bool hasAlternateExchange() const;
00084 void clearAlternateExchangeFlag();
00085 void setPassive(bool _passive);
00086 bool getPassive() const;
00087 void setDurable(bool _durable);
00088 bool getDurable() const;
00089 void setAutoDelete(bool _autoDelete);
00090 bool getAutoDelete() const;
00091 void setArguments(const FieldTable& _arguments);
00092 const FieldTable& getArguments() const;
00093 FieldTable& getArguments();
00094 bool hasArguments() const;
00095 void clearArgumentsFlag();
00096 typedef void ResultType;
00097
00098 template <class T> ResultType invoke(T& invocable) const {
00099 return invocable.declare(getExchange(), getType(), getAlternateExchange(), getPassive(), getDurable(), getAutoDelete(), getArguments());
00100 }
00101
00102 using AMQMethodBody::accept;
00103 void accept(MethodBodyConstVisitor& v) const { v.visit(*this); }
00104
00105 ClassId amqpClassId() const { return CLASS_ID; }
00106 MethodId amqpMethodId() const { return METHOD_ID; }
00107 bool isContentBearing() const { return false; }
00108 bool resultExpected() const { return false; }
00109 bool responseExpected() const { return false; }
00110 void encode(Buffer&) const;
00111 void decode(Buffer&, uint32_t=0);
00112 void encodeStructBody(Buffer&) const;
00113 void decodeStructBody(Buffer&, uint32_t=0);
00114 uint32_t size() const;
00115 uint32_t bodySize() const;
00116 void print(std::ostream& out) const;
00117 };
00118
00119 }}
00120 #endif