MoleQueue  0.8.0
 All Classes Functions Variables Enumerations Enumerator Pages
Public Slots | Signals | Public Member Functions | Protected Types | Protected Slots | Protected Attributes | List of all members
Client Class Reference

#include <molequeue/client/client.h>

Inheritance diagram for Client:

Public Slots

bool connectToServer (const QString &serverName="MoleQueue")
 
int requestQueueList ()
 
int submitJob (const JobObject &job)
 
int lookupJob (unsigned int moleQueueId)
 
int cancelJob (unsigned int moleQueueId)
 
int registerOpenWith (const QString &name, const QString &executable, const QList< QRegExp > &filePatterns)
 
int registerOpenWith (const QString &name, const QString &rpcServer, const QString &rpcMethod, const QList< QRegExp > &filePatterns)
 
int listOpenWithNames ()
 
int unregisterOpenWith (const QString &handlerName)
 
void flush ()
 

Signals

void connectionStateChanged ()
 
void queueListReceived (QJsonObject queues)
 
void submitJobResponse (int localId, unsigned int moleQueueId)
 
void lookupJobResponse (int localId, QJsonObject jobInfo)
 
void cancelJobResponse (unsigned int moleQueueId)
 
void jobStateChanged (unsigned int moleQueueId, QString oldState, QString newState)
 
void registerOpenWithResponse (int localId)
 
void listOpenWithNamesResponse (int localId, QJsonArray handlerNames)
 
void unregisterOpenWithResponse (int localId)
 
void errorReceived (int localId, int errorCode, QString errorMessage, QJsonValue errorData)
 

Public Member Functions

 Client (QObject *parent_=0)
 
bool isConnected () const
 

Protected Types

enum  MessageType {
  Invalid = -1,
  ListQueues,
  SubmitJob,
  CancelJob,
  LookupJob,
  RegisterOpenWith,
  ListOpenWithNames,
  UnregisterOpenWith
}
 

Protected Slots

void processResult (const QJsonObject &response)
 
void processNotification (const QJsonObject &notification)
 
void processError (const QJsonObject &notification)
 

Protected Attributes

JsonRpcClientm_jsonRpcClient
 
QHash< unsigned int, MessageType > m_requests
 

Detailed Description

The Client class is used by clients to submit jobs to a running MoleQueue server.

Author
Marcus D. Hanwell

Provides a simple Qt C++ API to use the MoleQueue JSON-RPC calls to submit and query the state of submitted jobs.

Member Function Documentation

bool isConnected ( ) const

Query if the client is connected to a server.

Returns
True if connected, false if not.
bool connectToServer ( const QString &  serverName = "MoleQueue")
slot

Connect to the server.

Parameters
serverNameName of the socket to connect to, the default of "MoleQueue" is usually correct when connecting to the running MoleQueue.
int requestQueueList ( )
slot

Request the list of queues and programs from the server. The signal queueListReceived() will be emitted once this has been received.

Returns
The local ID of the job submission request.
int submitJob ( const JobObject job)
slot

Submit a job to MoleQueue. If the returned local ID is retained the signal for a job submission will provide the MoleQueue ID along with the local ID.

Parameters
jobThe job specification to be submitted to MoleQueue.
Returns
The local ID of the job submission request.
int lookupJob ( unsigned int  moleQueueId)
slot

Request information about a job. You should supply the MoleQueue ID that was received in response to a job submission.

Parameters
moleQueueIdThe MoleQueue ID for the job.
Returns
The local ID of the job submission request.
int cancelJob ( unsigned int  moleQueueId)
slot

Cancel a job that was submitted.

Parameters
moleQueueIdThe MoleQueue ID for the job.
Returns
The local ID of the job submission request.
int registerOpenWith ( const QString &  name,
const QString &  executable,
const QList< QRegExp > &  filePatterns 
)
slot
 Register an executable file handler with MoleQueue.
 @param name GUI name of the file handler.
 @param executable Executable to call with the filename as the first
 argument. If the full path to the exectuble is not specified, it must be
 in the user's $PATH.
 @param filePatterns A list of QRegExp objects that the handler can open.
 The QRegExp objects must use RegExp, RegExp2, WildCard, or WildCardUnix
 pattern syntax, else they will be ignored.
 @return The local ID of the request.
 @note The executable is expected to use the following calling convention
 to open files:
executable /absolute/path/to/selected/fileName
int registerOpenWith ( const QString &  name,
const QString &  rpcServer,
const QString &  rpcMethod,
const QList< QRegExp > &  filePatterns 
)
slot
 Register a JSON-RPC 2.0 local socket file handler with MoleQueue.
 @param name GUI name of the file handler.
 @param rpcServer Name of the local socket that the server is listening on.
 @param rpcMethod JSON-RPC 2.0 request method to use.
 @param filePatterns A list of QRegExp objects that the handler can open.
 The QRegExp objects must use RegExp, RegExp2, WildCard, or WildCardUnix
 pattern syntax, else they will be ignored.
 @return The local ID of the request.
 @note The following JSON-RPC 2.0 request is sent to the server when the
 handler is activated:
{
"jsonrpc": "2.0",
"method": "<rpcMethod>",
"params": {
"fileName": "/absolute/path/to/selected/fileName"
}
},
"id": "XXX"
}

where <rpcMethod> is replaced by the rpcMethod argument.

int listOpenWithNames ( )
slot

Request a list of all file handler names.

Returns
The local ID of the request.
int unregisterOpenWith ( const QString &  handlerName)
slot

Unregister the indicated file handler from the molequeue server.

Parameters
handlerNameName of the file handler to remove.
Returns
The local ID of the request.
See Also
listOpenWithNames
void flush ( )
slot

flush Flush all pending messages to the server.

Warning
This should not need to be called if used in an event loop, as Qt will start writing to the socket as soon as control returns to the event loop.
void connectionStateChanged ( )
signal

Emitted when the connection state changes.

void queueListReceived ( QJsonObject  queues)
signal

Emitted when the remote queue list is received. This gives a list of lists, the primary key is the queue name, and that contains a list of available programs for each queue.

Parameters
queuesA JSON object containing the names of the queues and the programs each queue have available.
void submitJobResponse ( int  localId,
unsigned int  moleQueueId 
)
signal

Emitted when the job request response is received.

Parameters
localIdThe local ID the job submission response is in reply to.
moleQueueIdThe remote MoleQueue ID for the job submission (can be used to perform further actions on the job).
void lookupJobResponse ( int  localId,
QJsonObject  jobInfo 
)
signal

Emitted when a job lookup response is received.

Parameters
localIdThe local ID the job submission response is in reply to.
jobInfoA Json object containing all available job information.
void cancelJobResponse ( unsigned int  moleQueueId)
signal

Emitted when a job is successfully cancelled.

void jobStateChanged ( unsigned int  moleQueueId,
QString  oldState,
QString  newState 
)
signal

Emitted when the job state changes.

void registerOpenWithResponse ( int  localId)
signal

Emitted when a successful registerOpenWith response is received.

void listOpenWithNamesResponse ( int  localId,
QJsonArray  handlerNames 
)
signal

Emitted when a successful listOpenWithNames response is received.

void unregisterOpenWithResponse ( int  localId)
signal

Emitted when a successful unregisterOpenWith response is received.

void errorReceived ( int  localId,
int  errorCode,
QString  errorMessage,
QJsonValue  errorData 
)
signal

Emitted when an error response is received.

void processResult ( const QJsonObject &  response)
protectedslot

Parse the response object and emit the appropriate signal(s).

void processNotification ( const QJsonObject &  notification)
protectedslot

Parse a notification object and emit the appropriate signal(s).

void processError ( const QJsonObject &  notification)
protectedslot

Parse an error object and emit the appropriate signal(s).


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