QAMQP
amqp_exchange.h
1 #ifndef amqp_exchange_h__
2 #define amqp_exchange_h__
3 
4 #include "amqp_channel.h"
5 namespace QAMQP
6 {
7  class Client;
8  class Queue;
9  class ClientPrivate;
10  class ExchangePrivate;
11 
12  using namespace QAMQP::Frame;
13  class Exchange : public Channel
14  {
15  Q_OBJECT;
16  Exchange(int channelNumber = -1, Client * parent = 0);
17 
18  Q_PROPERTY(QString type READ type);
19  Q_PROPERTY(ExchangeOptions option READ option );
20 
21  P_DECLARE_PRIVATE(QAMQP::Exchange)
22  Q_DISABLE_COPY(Exchange);
23  friend class ClientPrivate;
24  protected:
25  void onOpen();
26  void onClose();
27 
28  public:
29 
30  enum ExchangeOption {
31  NoOptions = 0x0,
32  Passive = 0x01,
33  Durable = 0x02,
34  AutoDelete = 0x4,
35  Internal = 0x8,
36  NoWait = 0x10
37  };
38  Q_DECLARE_FLAGS(ExchangeOptions, ExchangeOption)
39 
40  ~Exchange();
41 
42  QString type() const;
43  ExchangeOptions option() const;
44 
45  void declare(const QString &type = QString::fromLatin1("direct"), ExchangeOptions option = NoOptions, const TableField & arg = TableField());
46  void remove(bool ifUnused = true, bool noWait = true);
47 
48  void bind(QAMQP::Queue * queue);
49  void bind(const QString & queueName);
50  void bind(const QString & queueName, const QString &key);
51 
52  void publish(const QString & message, const QString & key);
53  void publish(const QByteArray & message, const QString & key, const QString &mimeType);
54  void publish(const QByteArray & message, const QString & key, const QVariantHash &headers, const QString &mimeType);
55 
56  Q_SIGNALS:
57  void declared();
58  void binded();
59  void removed();
60  };
61 }
62 Q_DECLARE_OPERATORS_FOR_FLAGS(QAMQP::Exchange::ExchangeOptions)
63 #endif // amqp_exchange_h__