Public Member Functions

SocketReader Class Reference

Helper class for reading socket datachannel from sensord. More...

#include <socketreader.h>

List of all members.

Public Member Functions

 SocketReader (QObject *parent=0)
 Constructor.
 ~SocketReader ()
 Destructor.
bool initiateConnection (int sessionId)
 Initiates new data socket connection.
bool dropConnection ()
 Drops socket connection.
QLocalSocket * socket ()
 Provides access to the internal QLocalSocket for direct reading.
bool read (void *buffer, int size)
 Attempt to read given number of bytes from the socket.
template<typename T >
bool read (QVector< T > &values)
 Attempt to read objects from the sockets.
bool isConnected ()
 Returns whether the socket is currently connected.

Detailed Description

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.


Constructor & Destructor Documentation

SocketReader::SocketReader ( QObject *  parent = 0  ) 

Constructor.

Parameters:
parent Parent QObject.
SocketReader::~SocketReader (  ) 

Destructor.


Member Function Documentation

bool SocketReader::dropConnection (  ) 

Drops socket connection.

Returns:
was the connection successfully closed.
bool SocketReader::initiateConnection ( int  sessionId  ) 

Initiates new data socket connection.

Parameters:
sessionId ID for the current session.
Returns:
was the connection established successfully.
bool SocketReader::isConnected (  ) 

Returns whether the socket is currently connected.

Returns:
is socket connected.
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.

Parameters:
size Number of bytes to read.
buffer Location for storing the data.
Returns:
was given amount of bytes read succesfully.
template<typename T >
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.

Parameters:
values Vector to which objects will be appended.
Template Parameters:
T type of expected object in the stream.
Returns:
true if atleast one object was read.

Definition at line 129 of file socketreader.h.

QLocalSocket* SocketReader::socket (  ) 

Provides access to the internal QLocalSocket for direct reading.

Returns:
Pointer to the internal QLocalSocket. Pointer can be NULL if initiateConnection() has not been called successfully.

The documentation for this class was generated from the following file: