Added requirements to README and started implementing some of the Client methods.

This commit is contained in:
Nathan Osman 2013-06-29 12:34:22 -07:00
parent 1a9f124d42
commit 12272de5d7
3 changed files with 48 additions and 5 deletions

View File

@ -2,6 +2,15 @@
QRedis provides a modern Qt client library for communicating with a [Redis server](http://redis.io/). The code uses many new constructs introduced in [C++11](https://en.wikipedia.org/wiki/C%2B%2B11) and compiles exclusively with Qt 5, ensuring years of compatibility down the road.
### Requirements
To compile QRedis, the following requirements must be met:
* GCC 4.6+ or Microsoft Visual C++ 2010+
* Qt 5+
*It is not necessary to have Redis installed in order to build the client library. However, you will be unable to run the test suite.*
### Building QRedis
QRedis uses [CMake](http://www.cmake.org/) for building the client library, which simplifies the necessary steps across all supported platforms. Assuming you have Qt 5 installed in a location that CMake can find, the client library can be built with the following steps:

View File

@ -1,6 +1,7 @@
#ifndef QREDIS_CLIENT_H
#define QREDIS_CLIENT_H
#include <QHostAddress>
#include <QObject>
#include <QScopedPointer>
@ -12,7 +13,7 @@ namespace QRedis
class QREDIS_EXPORT ClientPrivate;
/**
* @brief Provides access to a Redis server.
* @brief Provides access to a Redis server
*/
class QREDIS_EXPORT Client : public QObject
{
@ -21,24 +22,48 @@ namespace QRedis
public:
/**
* @brief Connects to a Redis server.
* @brief Connects to a Redis server
*/
Client();
/**
* @brief Disconnects from the Redis server.
* @brief Disconnects from the Redis server
*/
virtual ~Client();
void connectToHost();
/**
* @brief Attempts to connect to the specified Redis server
* @param address the address of the Redis server
* @param port the port that the Redis server is listening on
*
* If the connection was successful, the connected() signal will be
* emitted.
*/
void connectToHost(const QHostAddress & address, quint16 port = 6379);
/**
* @brief Disconnects from the Redis server
*/
void disconnectFromHost();
/**
* @brief Sends the specified command to the Redis server.
* @return an object that may be used for obtaining the response
*/
Command * sendCommand();
signals:
/**
* @brief Emitted when the client establishes a connection with the Redis server
*/
void connected();
/**
* @brief Emitted when the client disconnects from the Redis server
*/
void disconnected();
private:
const QScopedPointer<ClientPrivate> d;

View File

@ -6,16 +6,25 @@ using namespace QRedis;
Client::Client()
: d(new ClientPrivate)
{
connect(d->socket, &QTcpSocket::connected, this, &Client::connected);
connect(d->socket, &QTcpSocket::disconnected, this, &Client::disconnected);
}
Client::~Client()
{
}
void Client::connectToHost()
void Client::connectToHost(const QHostAddress & address, quint16 port)
{
d->socket.connectToHost(address, port);
}
void Client::disconnectFromHost()
{
d->socket.disconnectFromHost();
}
Command * Client::sendCommand()
{
return nullptr;
}