2013-07-02 00:00:58 +08:00
|
|
|
#ifndef QREDIS_REQUEST_H
|
|
|
|
|
#define QREDIS_REQUEST_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QScopedPointer>
|
2013-07-05 00:25:46 +08:00
|
|
|
#include <QVariantList>
|
2013-07-02 00:00:58 +08:00
|
|
|
|
|
|
|
|
#include "qredis_export.h"
|
|
|
|
|
|
|
|
|
|
namespace QRedis
|
|
|
|
|
{
|
|
|
|
|
class QREDIS_EXPORT RequestPrivate;
|
|
|
|
|
|
|
|
|
|
/**
|
2013-07-03 06:26:19 +08:00
|
|
|
* @brief Represents a request and its reply
|
2013-07-02 00:00:58 +08:00
|
|
|
*/
|
|
|
|
|
class QREDIS_EXPORT Request : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Creates a request
|
|
|
|
|
* @param parent
|
|
|
|
|
*/
|
2013-07-03 06:26:19 +08:00
|
|
|
explicit Request(QObject * parent = 0);
|
2013-07-02 00:00:58 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Destroys the request
|
|
|
|
|
*/
|
|
|
|
|
virtual ~Request();
|
|
|
|
|
|
|
|
|
|
/**
|
2013-07-03 06:26:19 +08:00
|
|
|
* @brief Waits for the reply to be received
|
|
|
|
|
* @param msecs the amount of time in milliseconds to wait
|
|
|
|
|
* @return true if the reply was received
|
2013-07-02 00:00:58 +08:00
|
|
|
*/
|
2013-07-03 06:26:19 +08:00
|
|
|
bool waitForReply(int msecs = 30000);
|
2013-07-02 00:00:58 +08:00
|
|
|
|
2013-07-03 06:26:19 +08:00
|
|
|
Q_SIGNALS:
|
2013-07-02 00:00:58 +08:00
|
|
|
|
|
|
|
|
/**
|
2013-07-16 13:19:40 +08:00
|
|
|
* @brief Emitted when a status reply is received
|
|
|
|
|
* @param message a descriptive status message
|
2013-07-05 00:25:46 +08:00
|
|
|
*/
|
2013-07-16 13:19:40 +08:00
|
|
|
void status(const QString & message);
|
2013-07-05 00:25:46 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Emitted when an error reply is received
|
2013-07-16 13:19:40 +08:00
|
|
|
* @param generic a generic error identifer
|
|
|
|
|
* @param specific a more specific error message
|
2013-07-05 00:25:46 +08:00
|
|
|
*/
|
2013-07-16 13:19:40 +08:00
|
|
|
void error(const QString & generic, const QString & specific);
|
2013-07-05 00:25:46 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Emitted when an integer reply is received
|
|
|
|
|
* @param value the integer value
|
|
|
|
|
*/
|
|
|
|
|
void integer(qlonglong value);
|
|
|
|
|
|
2013-07-16 13:19:40 +08:00
|
|
|
/**
|
|
|
|
|
* @brief Emitted when a bulk reply is received
|
|
|
|
|
* @param value the value as a byte array
|
|
|
|
|
*/
|
|
|
|
|
void bulk(const QByteArray & value);
|
|
|
|
|
|
2013-07-05 00:25:46 +08:00
|
|
|
/**
|
|
|
|
|
* @brief Emitted when a multi-bulk reply is received
|
|
|
|
|
* @param a list of bulk values
|
|
|
|
|
*/
|
|
|
|
|
void multiBulk(const QVariantList & values);
|
|
|
|
|
|
2013-07-05 05:14:53 +08:00
|
|
|
/**
|
|
|
|
|
* @brief Emitted when any reply is received
|
|
|
|
|
*/
|
|
|
|
|
void reply();
|
|
|
|
|
|
2013-07-02 00:00:58 +08:00
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
const QScopedPointer<RequestPrivate> d;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // QREDIS_REQUEST_H
|