Loading...
Searching...
No Matches
Client Class Reference

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

`#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< QRegularExpression > &filePatterns)
int | registerOpenWith (const QString &name, const QString &rpcServer, const QString &rpcMethod, const QList< QRegularExpression > &filePatterns)
int | listOpenWithNames ()
| Request a list of all file handler names.
int | unregisterOpenWith (const QString &handlerName)
| Unregister the indicated file handler from the molequeue server.
void | flush ()
| flush Flush all pending messages to the server.

## 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_=nullptr)
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

JsonRpcClient * | m_jsonRpcClient
QHash< unsigned int, MessageType > | m_requests

## Detailed Description

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

## isConnected()

bool isConnected | ( |  | ) | const

Query if the client is connected to a server.

Returns
  True if connected, false if not.

## connectToServer

bool connectToServer | ( | const QString & | serverName = "MoleQueue" | ) |

slot

Connect to the server.

Parameters

  serverName | Name of the socket to connect to, the default of "MoleQueue" is usually correct when connecting to the running MoleQueue.

## requestQueueList

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.

## submitJob

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

  job | The job specification to be submitted to MoleQueue.

Returns
  The local ID of the job submission request.

## lookupJob

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

  moleQueueId | The MoleQueue ID for the job.

Returns
  The local ID of the job submission request.

## cancelJob

int cancelJob | ( | unsigned int | moleQueueId | ) |

slot

Cancel a job that was submitted.

Parameters

  moleQueueId | The MoleQueue ID for the job.

Returns
  The local ID of the job submission request.

## registerOpenWith [1/2]

int registerOpenWith | ( | const QString & | name,
|  | const QString & | executable,
|  | const QList< QRegularExpression > & | 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 QRegularExpression objects that the handler
     can open. The QRegularExpression objects may only use the new
     QRegularExpression pattern syntax.
     @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

## registerOpenWith [2/2]

int registerOpenWith | ( | const QString & | name,
|  | const QString & | rpcServer,
|  | const QString & | rpcMethod,
|  | const QList< QRegularExpression > & | 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 QRegularExpression objects that the handler
     can open. The QRegularExpression objects may only use the new
     QRegularExpression pattern syntax.
     @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.

## listOpenWithNames

int listOpenWithNames | ( |  | ) |

slot

Returns
  The local ID of the request.

## unregisterOpenWith

int unregisterOpenWith | ( | const QString & | handlerName | ) |

slot

Parameters

  handlerName | Name of the file handler to remove.

Returns
  The local ID of the request.

See also
  listOpenWithNames

## flush

void flush | ( |  | ) |

slot

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.

## connectionStateChanged

void connectionStateChanged | ( |  | ) |

signal

Emitted when the connection state changes.

## queueListReceived

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

  queues | A JSON object containing the names of the queues and the programs each queue have available.

## submitJobResponse

void submitJobResponse | ( | int | localId,
|  | unsigned int | moleQueueId )

signal

Emitted when the job request response is received.

Parameters

  localId | The local ID the job submission response is in reply to.
  moleQueueId | The remote MoleQueue ID for the job submission (can be used to perform further actions on the job).

## lookupJobResponse

void lookupJobResponse | ( | int | localId,
|  | QJsonObject | jobInfo )

signal

Emitted when a job lookup response is received.

Parameters

  localId | The local ID the job submission response is in reply to.
  jobInfo | A Json object containing all available job information.

## cancelJobResponse

void cancelJobResponse | ( | unsigned int | moleQueueId | ) |

signal

Emitted when a job is successfully cancelled.

## jobStateChanged

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

signal

Emitted when the job state changes.

## registerOpenWithResponse

void registerOpenWithResponse | ( | int | localId | ) |

signal

Emitted when a successful registerOpenWith response is received.

## listOpenWithNamesResponse

void listOpenWithNamesResponse | ( | int | localId,
|  | QJsonArray | handlerNames )

signal

Emitted when a successful listOpenWithNames response is received.

## unregisterOpenWithResponse

void unregisterOpenWithResponse | ( | int | localId | ) |

signal

Emitted when a successful unregisterOpenWith response is received.

## errorReceived

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

signal

Emitted when an error response is received.

## processResult

void processResult | ( | const QJsonObject & | response | ) |

protected slot

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

## processNotification

void processNotification | ( | const QJsonObject & | notification | ) |

protected slot

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

## processError

void processError | ( | const QJsonObject & | notification | ) |

protected slot

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

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

- client.h