sensorfw
|
Helper class for reading socket datachannel from sensord. More...
#include <socketreader.h>
Public Member Functions | |
SocketReader (QObject *parent=0) | |
Constructor. More... | |
~SocketReader () | |
Destructor. More... | |
bool | initiateConnection (int sessionId) |
Initiates new data socket connection. More... | |
bool | dropConnection () |
Drops socket connection. More... | |
QLocalSocket * | socket () |
Provides access to the internal QLocalSocket for direct reading. More... | |
bool | read (void *buffer, int size) |
Attempt to read given number of bytes from the socket. More... | |
template<typename T > | |
bool | read (QVector< T > &values) |
Attempt to read objects from the sockets. More... | |
bool | isConnected () |
Returns whether the socket is currently connected. More... | |
Helper class for reading socket datachannel from sensord.
SocketReader provides common handler for all sensors using socket data channel. It is used by AbstractSensorChannelInterface to maintain the socket connection to the server.
Definition at line 41 of file socketreader.h.
SocketReader::SocketReader | ( | QObject * | parent = 0 | ) |
Constructor.
parent | Parent QObject. |
SocketReader::~SocketReader | ( | ) |
Destructor.
bool SocketReader::dropConnection | ( | ) |
Drops socket connection.
bool SocketReader::initiateConnection | ( | int | sessionId | ) |
Initiates new data socket connection.
sessionId | ID for the current session. |
bool SocketReader::isConnected | ( | ) |
Returns whether the socket is currently connected.
bool SocketReader::read | ( | QVector< T > & | values | ) |
Attempt to read objects from the sockets.
The call blocks until there are minimum amount of expected bytes availabled in the socket.
values | Vector to which objects will be appended. |
T | type of expected object in the stream. |
Definition at line 129 of file socketreader.h.
bool SocketReader::read | ( | void * | buffer, |
int | size | ||
) |
Attempt to read given number of bytes from the socket.
As QLocalSocket is used, we are guaranteed that any number of bytes written in single operation are available for immediate reading with a single operation.
size | Number of bytes to read. |
buffer | Location for storing the data. |
QLocalSocket * SocketReader::socket | ( | ) |
Provides access to the internal QLocalSocket for direct reading.
NULL
if initiateConnection()
has not been called successfully.