myxlib/src/myx/redis/request.hpp

65 lines
1.1 KiB
C++

#ifndef MYX_REDIS_REQUEST_HPP_
#define MYX_REDIS_REQUEST_HPP_
#pragma once
#include <myx/base/config.hpp>
#include <myx/redis/reply.hpp>
#include <QObject>
#include <QScopedPointer>
namespace myx {
namespace redis {
QT_FORWARD_DECLARE_CLASS( RequestPrivate );
/**
* @brief Represents a Redis command and its response
*/
class Request : public QObject
{
Q_OBJECT
public:
/**
* @brief Initializes the request
* @param parent the parent QObject
*/
explicit Request( QObject* parent = nullptr );
/**
* @brief Destroys the request
*/
~Request() override = default;
/**
* @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
*/
bool waitForReply( int msecs = 10000 );
/**
* @brief Emitted when a reply is received
* @param reply the reply received
*/
Q_SIGNAL void reply( const myx::redis::Reply& reply );
private:
const QScopedPointer< RequestPrivate > d;
}; // class Request
} // namespace redis
} // namespace myx
#ifdef MYXLIB_HEADER_ONLY
#include "request-inl.hpp"
#endif
#endif // MYX_REDIS_REQUEST_HPP_