QAMQP
amqp_queue.h
1 #ifndef amqp_queue_h__
2 #define amqp_queue_h__
3 
4 #include "amqp_channel.h"
5 #include "amqp_message.h"
6 
7 namespace QAMQP
8 {
9  class Client;
10  class ClientPrivate;
11  class Exchange;
12  class QueuePrivate;
13  class Queue : public Channel
14  {
15  Q_OBJECT
16  Queue(int channelNumber = -1, Client * parent = 0);
17 
18  Q_PROPERTY(QueueOptions option READ option );
19  Q_PROPERTY(QString consumerTag READ consumerTag WRITE setConsumerTag)
20  Q_PROPERTY(bool noAck READ noAck WRITE setNoAck)
21 
22  P_DECLARE_PRIVATE(QAMQP::Queue)
23  Q_DISABLE_COPY(Queue);
24  friend class ClientPrivate;
25 
26  protected:
27  void onOpen();
28  void onClose();
29 
30  public:
31  enum QueueOption {
32  NoOptions = 0x0,
33  Passive = 0x01,
34  Durable = 0x02,
35  Exclusive = 0x4,
36  AutoDelete = 0x8,
37  NoWait = 0x10
38  };
39  Q_DECLARE_FLAGS(QueueOptions, QueueOption)
40 
41  enum ConsumeOption {
42  coNoLocal = 0x1,
43  coNoAck = 0x02,
44  coExclusive = 0x04,
45  coNoWait = 0x8
46  };
47  Q_DECLARE_FLAGS(ConsumeOptions, ConsumeOption)
48 
49  ~Queue();
50 
51  QueueOptions option() const;
52 
53  void declare();
54  void declare(const QString &name, QueueOptions options);
55  void remove(bool ifUnused = true, bool ifEmpty = true, bool noWait = true);
56 
57  void purge();
58 
59  void bind(const QString & exchangeName, const QString & key);
60  void bind(Exchange * exchange, const QString & key);
61 
62  void unbind(const QString & exchangeName, const QString & key);
63  void unbind(Exchange * exchange, const QString & key);
64 
65  MessagePtr getMessage();
66  void get();
67  void ack(const MessagePtr & message);
68  bool hasMessage() const;
69  void consume(ConsumeOptions options = ConsumeOptions(NoOptions));
70  void setConsumerTag(const QString &consumerTag);
71  QString consumerTag() const;
72 
73  void setNoAck(bool noAck);
74  bool noAck() const;
75 
76  Q_SIGNALS:
77  void declared();
78  void binded(bool);
79  void removed();
80  void messageRecieved();
81  void empty();
82 
83  private:
84  Q_PRIVATE_SLOT(pd_func(), void _q_content(const QAMQP::Frame::Content & frame))
85  Q_PRIVATE_SLOT(pd_func(), void _q_body(int channeNumber, const QByteArray & body))
86  };
87 }
88 #ifdef QAMQP_P_INCLUDE
89 # include "amqp_queue_p.h"
90 #endif
91 #endif // amqp_queue_h__