From 7ba369b479d612f1aad2723d5a9c273bdb3b8dc0 Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Fri, 28 May 2021 14:04:12 -0400 Subject: [PATCH 1/4] Added the MoleQueue client code to Avogadro This removes the optional dependency on the MoleQueue client library. This was always a weak point of the MoleQueue design, and I was never happy with the hard dependency on MoleQueue for a tiny client library. It just uses Qt's Network module with some JSON for coordinating job submission. Build this unconditionally when Qt is enabled, leave the directory naming alone. Signed-off-by: Marcus D. Hanwell --- avogadro/CMakeLists.txt | 7 +- avogadro/molequeue/CMakeLists.txt | 9 +- avogadro/molequeue/batchjob.h | 2 +- avogadro/molequeue/client/client.cpp | 310 ++++++++++++++++++++ avogadro/molequeue/client/client.h | 260 ++++++++++++++++ avogadro/molequeue/client/jobobject.cpp | 142 +++++++++ avogadro/molequeue/client/jobobject.h | 174 +++++++++++ avogadro/molequeue/client/jsonrpcclient.cpp | 157 ++++++++++ avogadro/molequeue/client/jsonrpcclient.h | 153 ++++++++++ avogadro/molequeue/inputgeneratorwidget.cpp | 2 - avogadro/molequeue/molequeuedialog.cpp | 2 - avogadro/molequeue/molequeuemanager.h | 2 +- avogadro/molequeue/molequeuewidget.h | 2 +- 13 files changed, 1206 insertions(+), 16 deletions(-) create mode 100644 avogadro/molequeue/client/client.cpp create mode 100644 avogadro/molequeue/client/client.h create mode 100644 avogadro/molequeue/client/jobobject.cpp create mode 100644 avogadro/molequeue/client/jobobject.h create mode 100644 avogadro/molequeue/client/jsonrpcclient.cpp create mode 100644 avogadro/molequeue/client/jsonrpcclient.h diff --git a/avogadro/CMakeLists.txt b/avogadro/CMakeLists.txt index b66fb2011b..b878f5f510 100644 --- a/avogadro/CMakeLists.txt +++ b/avogadro/CMakeLists.txt @@ -60,10 +60,9 @@ if(USE_QT) add_subdirectory(qtopengl) include_directories(${CMAKE_CURRENT_BINARY_DIR}/qtopengl) endif() - if(USE_MOLEQUEUE) - add_subdirectory(molequeue) - include_directories(${CMAKE_CURRENT_BINARY_DIR}/molequeue) - endif() + # Add unconditionally as this talks to MoleQueue, but doesn't depend on it. + add_subdirectory(molequeue) + include_directories(${CMAKE_CURRENT_BINARY_DIR}/molequeue) if(USE_VTK) add_subdirectory(vtk) include_directories(${CMAKE_CURRENT_BINARY_DIR}/vtk) diff --git a/avogadro/molequeue/CMakeLists.txt b/avogadro/molequeue/CMakeLists.txt index 37431cd300..f540c56e37 100644 --- a/avogadro/molequeue/CMakeLists.txt +++ b/avogadro/molequeue/CMakeLists.txt @@ -1,7 +1,3 @@ -# Pull in MoleQueue -find_package(MoleQueue REQUIRED NO_MODULE) -include_directories(${MoleQueue_INCLUDE_DIRS}) - find_package(Eigen3 REQUIRED) # Add as "system headers" to avoid warnings generated by them with # compilers that support that notion. @@ -29,6 +25,9 @@ set(SOURCES molequeuemanager.cpp molequeuequeuelistmodel.cpp molequeuewidget.cpp + client/client.cpp + client/jobobject.cpp + client/jsonrpcclient.cpp ) set(UIS @@ -42,4 +41,4 @@ list(APPEND SOURCES ${UI_SOURCES}) avogadro_add_library(AvogadroMoleQueue ${HEADERS} ${SOURCES}) set_target_properties(AvogadroMoleQueue PROPERTIES AUTOMOC TRUE) -target_link_libraries(AvogadroMoleQueue AvogadroQtGui MoleQueueClient Qt5::Widgets Qt5::Network) +target_link_libraries(AvogadroMoleQueue AvogadroQtGui Qt5::Widgets Qt5::Network) diff --git a/avogadro/molequeue/batchjob.h b/avogadro/molequeue/batchjob.h index efb69b0f61..a1597e5d28 100644 --- a/avogadro/molequeue/batchjob.h +++ b/avogadro/molequeue/batchjob.h @@ -23,7 +23,7 @@ #include -#include +#include "client/jobobject.h" #include #include diff --git a/avogadro/molequeue/client/client.cpp b/avogadro/molequeue/client/client.cpp new file mode 100644 index 0000000000..c1c3b291fe --- /dev/null +++ b/avogadro/molequeue/client/client.cpp @@ -0,0 +1,310 @@ +/****************************************************************************** + + This source file is part of the MoleQueue project. + + Copyright 2012-2013 Kitware, Inc. + + This source code is released under the New BSD License, (the "License"). + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +******************************************************************************/ + +#include "client.h" + +#include "jsonrpcclient.h" +#include "jobobject.h" + +#include + +namespace MoleQueue +{ + +Client::Client(QObject *parent_) : QObject(parent_), m_jsonRpcClient(NULL) +{ +} + +Client::~Client() +{ +} + +bool Client::isConnected() const +{ + if (!m_jsonRpcClient) + return false; + else + return m_jsonRpcClient->isConnected(); +} + +bool Client::connectToServer(const QString &serverName) +{ + if (!m_jsonRpcClient) { + m_jsonRpcClient = new JsonRpcClient(this); + connect(m_jsonRpcClient, SIGNAL(resultReceived(QJsonObject)), + SLOT(processResult(QJsonObject))); + connect(m_jsonRpcClient, SIGNAL(notificationReceived(QJsonObject)), + SLOT(processNotification(QJsonObject))); + connect(m_jsonRpcClient, SIGNAL(errorReceived(QJsonObject)), + SLOT(processError(QJsonObject))); + connect(m_jsonRpcClient, SIGNAL(connectionStateChanged()), + SIGNAL(connectionStateChanged())); + } + + return m_jsonRpcClient->connectToServer(serverName); +} + +int Client::requestQueueList() +{ + if (!m_jsonRpcClient) + return -1; + + QJsonObject packet = m_jsonRpcClient->emptyRequest(); + packet["method"] = QLatin1String("listQueues"); + if (!m_jsonRpcClient->sendRequest(packet)) + return -1; + + int localId = static_cast(packet["id"].toDouble()); + m_requests[localId] = ListQueues; + return localId; +} + +int Client::submitJob(const JobObject &job) +{ + if (!m_jsonRpcClient) + return -1; + + QJsonObject packet = m_jsonRpcClient->emptyRequest(); + packet["method"] = QLatin1String("submitJob"); + packet["params"] = job.json(); + if (!m_jsonRpcClient->sendRequest(packet)) + return -1; + + int localId = static_cast(packet["id"].toDouble()); + m_requests[localId] = SubmitJob; + return localId; +} + +int Client::lookupJob(unsigned int moleQueueId) +{ + if (!m_jsonRpcClient) + return -1; + + QJsonObject packet = m_jsonRpcClient->emptyRequest(); + packet["method"] = QLatin1String("lookupJob"); + QJsonObject params; + params["moleQueueId"] = static_cast(moleQueueId); + packet["params"] = params; + if (!m_jsonRpcClient->sendRequest(packet)) + return -1; + + int localId = static_cast(packet["id"].toDouble()); + m_requests[localId] = LookupJob; + return localId; +} + +int Client::cancelJob(unsigned int moleQueueId) +{ + if (!m_jsonRpcClient) + return -1; + + QJsonObject packet = m_jsonRpcClient->emptyRequest(); + packet["method"] = QLatin1String("cancelJob"); + QJsonObject params; + params["moleQueueId"] = static_cast(moleQueueId); + packet["params"] = params; + if (!m_jsonRpcClient->sendRequest(packet)) + return -1; + + int localId = static_cast(packet["id"].toDouble()); + m_requests[localId] = CancelJob; + return localId; +} + +int Client::registerOpenWith(const QString &name, const QString &executable, + const QList &filePatterns) +{ + if (!m_jsonRpcClient) + return -1; + + QJsonObject method; + method["executable"] = executable; + + QJsonObject packet(buildRegisterOpenWithRequest(name, filePatterns, method)); + + if (!m_jsonRpcClient->sendRequest(packet)) + return -1; + + int localId = static_cast(packet["id"].toDouble()); + m_requests[localId] = RegisterOpenWith; + return localId; +} + +int Client::registerOpenWith(const QString &name, + const QString &rpcServer, const QString &rpcMethod, + const QList &filePatterns) +{ + if (!m_jsonRpcClient) + return -1; + + QJsonObject method; + method["rpcServer"] = rpcServer; + method["rpcMethod"] = rpcMethod; + + QJsonObject packet(buildRegisterOpenWithRequest(name, filePatterns, method)); + + if (!m_jsonRpcClient->sendRequest(packet)) + return -1; + + int localId = static_cast(packet["id"].toDouble()); + m_requests[localId] = RegisterOpenWith; + return localId; +} + +int Client::listOpenWithNames() +{ + if (!m_jsonRpcClient) + return -1; + + QJsonObject packet = m_jsonRpcClient->emptyRequest(); + packet["method"] = QLatin1String("listOpenWithNames"); + if (!m_jsonRpcClient->sendRequest(packet)) + return -1; + + int localId = static_cast(packet["id"].toDouble()); + m_requests[localId] = ListOpenWithNames; + return localId; +} + +int Client::unregisterOpenWith(const QString &handlerName) +{ + if (!m_jsonRpcClient) + return -1; + + QJsonObject packet = m_jsonRpcClient->emptyRequest(); + packet["method"] = QLatin1String("unregisterOpenWith"); + QJsonObject params; + params["name"] = handlerName; + packet["params"] = params; + if (!m_jsonRpcClient->sendRequest(packet)) + return -1; + + int localId = static_cast(packet["id"].toDouble()); + m_requests[localId] = UnregisterOpenWith; + return localId; +} + +void Client::flush() +{ + if (m_jsonRpcClient) + m_jsonRpcClient->flush(); +} + +void Client::processResult(const QJsonObject &response) +{ + if (response["id"] != QJsonValue::Null + && m_requests.contains(static_cast(response["id"].toDouble()))) { + int localId = static_cast(response["id"].toDouble()); + switch (m_requests[localId]) { + case ListQueues: + emit queueListReceived(response["result"].toObject()); + break; + case SubmitJob: + emit submitJobResponse(localId, + static_cast(response["result"] + .toObject()["moleQueueId"].toDouble())); + break; + case LookupJob: + emit lookupJobResponse(localId, response["result"].toObject()); + break; + case CancelJob: + emit cancelJobResponse(static_cast(response["result"] + .toObject()["moleQueueId"].toDouble())); + break; + case RegisterOpenWith: + emit registerOpenWithResponse(localId); + break; + case ListOpenWithNames: + emit listOpenWithNamesResponse(localId, response["result"].toArray()); + break; + case UnregisterOpenWith: + emit unregisterOpenWithResponse(localId); + break; + default: + break; + } + } +} + +void Client::processNotification(const QJsonObject ¬ification) +{ + if (notification["method"].toString() == "jobStateChanged") { + QJsonObject params = notification["params"].toObject(); + emit jobStateChanged( + static_cast(params["moleQueueId"].toDouble()), + params["oldState"].toString(), params["newState"].toString()); + } +} + +void Client::processError(const QJsonObject &error) +{ + int localId = static_cast(error["id"].toDouble()); + int errorCode = -1; + QString errorMessage = tr("No message specified."); + QJsonValue errorData; + + const QJsonValue &errorValue = error.value(QLatin1String("error")); + if (errorValue.isObject()) { + const QJsonObject errorObject = errorValue.toObject(); + if (errorObject.value("code").isDouble()) + errorCode = static_cast(errorObject.value("code").toDouble()); + if (errorObject.value("message").isString()) + errorMessage = errorObject.value("message").toString(); + if (errorObject.contains("data")) + errorData = errorObject.value("data"); + } + emit errorReceived(localId, errorCode, errorMessage, errorData); +} + +QJsonObject Client::buildRegisterOpenWithRequest( + const QString &name, const QList &filePatterns, + const QJsonObject &handlerMethod) +{ + QJsonArray patterns; + foreach (const QRegExp ®ex, filePatterns) { + QJsonObject pattern; + switch (regex.patternSyntax()) { + case QRegExp::RegExp: + case QRegExp::RegExp2: + pattern["regexp"] = regex.pattern(); + break; + case QRegExp::Wildcard: + case QRegExp::WildcardUnix: + pattern["wildcard"] = regex.pattern(); + break; + default: + case QRegExp::FixedString: + case QRegExp::W3CXmlSchema11: + continue; + } + + pattern["caseSensitive"] = regex.caseSensitivity() == Qt::CaseSensitive; + patterns.append(pattern); + } + + QJsonObject params; + params["name"] = name; + params["method"] = handlerMethod; + params["patterns"] = patterns; + + QJsonObject packet = m_jsonRpcClient->emptyRequest(); + packet["method"] = QLatin1String("registerOpenWith"); + packet["params"] = params; + + return packet; +} + +} // End namespace MoleQueue diff --git a/avogadro/molequeue/client/client.h b/avogadro/molequeue/client/client.h new file mode 100644 index 0000000000..dacb6f1835 --- /dev/null +++ b/avogadro/molequeue/client/client.h @@ -0,0 +1,260 @@ +/****************************************************************************** + + This source file is part of the MoleQueue project. + + Copyright 2012-2013 Kitware, Inc. + + This source code is released under the New BSD License, (the "License"). + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +******************************************************************************/ + +#ifndef MOLEQUEUE_CLIENT_H +#define MOLEQUEUE_CLIENT_H + +#include "avogadromolequeueexport.h" + +#include +#include +#include +#include +#include + +namespace MoleQueue +{ + +class JsonRpcClient; +class JobObject; + +/** + * @class Client client.h + * @brief 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. + */ + +class AVOGADROMOLEQUEUE_EXPORT Client : public QObject +{ + Q_OBJECT + +public: + explicit Client(QObject *parent_ = 0); + ~Client(); + + /** + * Query if the client is connected to a server. + * @return True if connected, false if not. + */ + bool isConnected() const; + +public slots: + /** + * Connect to the server. + * @param serverName Name of the socket to connect to, the default of + * "MoleQueue" is usually correct when connecting to the running MoleQueue. + */ + bool connectToServer(const QString &serverName = "MoleQueue"); + + /** + * Request the list of queues and programs from the server. The signal + * queueListReceived() will be emitted once this has been received. + * @return The local ID of the job submission request. + */ + int requestQueueList(); + + /** + * 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. + * @param job The job specification to be submitted to MoleQueue. + * @return The local ID of the job submission request. + */ + int submitJob(const JobObject &job); + + /** + * Request information about a job. You should supply the MoleQueue ID that + * was received in response to a job submission. + * @param moleQueueId The MoleQueue ID for the job. + * @return The local ID of the job submission request. + */ + int lookupJob(unsigned int moleQueueId); + + /** + * Cancel a job that was submitted. + * @param moleQueueId The MoleQueue ID for the job. + * @return The local ID of the job submission request. + */ + int cancelJob(unsigned int moleQueueId); + + /** + * 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 &executable, + const QList &filePatterns); + + /** + * 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": "", + "params": { + "fileName": "/absolute/path/to/selected/fileName" + } + }, + "id": "XXX" +} +~~~ + * where is replaced by the @a rpcMethod argument. + */ + int registerOpenWith(const QString &name, + const QString &rpcServer, const QString &rpcMethod, + const QList &filePatterns); + + /** + * @brief Request a list of all file handler names. + * @return The local ID of the request. + */ + int listOpenWithNames(); + + /** + * @brief Unregister the indicated file handler from the molequeue server. + * @param handlerName Name of the file handler to remove. + * @return The local ID of the request. + * @sa listOpenWithNames + */ + int unregisterOpenWith(const QString &handlerName); + + /** + * @brief 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 flush(); + +signals: + /** + * Emitted when the connection state changes. + */ + void connectionStateChanged(); + + /** + * 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. + * @param queues A JSON object containing the names of the queues and the + * programs each queue have available. + */ + void queueListReceived(QJsonObject queues); + + /** + * Emitted when the job request response is received. + * @param localId The local ID the job submission response is in reply to. + * @param moleQueueId The remote MoleQueue ID for the job submission (can be + * used to perform further actions on the job). + */ + void submitJobResponse(int localId, unsigned int moleQueueId); + + /** + * Emitted when a job lookup response is received. + * @param localId The local ID the job submission response is in reply to. + * @param jobInfo A Json object containing all available job information. + */ + void lookupJobResponse(int localId, QJsonObject jobInfo); + + /** + * Emitted when a job is successfully cancelled. + */ + void cancelJobResponse(unsigned int moleQueueId); + + /** + * Emitted when the job state changes. + */ + void jobStateChanged(unsigned int moleQueueId, QString oldState, + QString newState); + + /** + * Emitted when a successful registerOpenWith response is received. + */ + void registerOpenWithResponse(int localId); + + /** + * Emitted when a successful listOpenWithNames response is received. + */ + void listOpenWithNamesResponse(int localId, QJsonArray handlerNames); + + /** + * Emitted when a successful unregisterOpenWith response is received. + */ + void unregisterOpenWithResponse(int localId); + + /** + * Emitted when an error response is received. + */ + void errorReceived(int localId, int errorCode, QString errorMessage, + QJsonValue errorData); + +protected slots: + /** Parse the response object and emit the appropriate signal(s). */ + void processResult(const QJsonObject &response); + + /** Parse a notification object and emit the appropriate signal(s). */ + void processNotification(const QJsonObject ¬ification); + + /** Parse an error object and emit the appropriate signal(s). */ + void processError(const QJsonObject ¬ification); + +protected: + enum MessageType { + Invalid = -1, + ListQueues, + SubmitJob, + CancelJob, + LookupJob, + RegisterOpenWith, + ListOpenWithNames, + UnregisterOpenWith + }; + + JsonRpcClient *m_jsonRpcClient; + QHash m_requests; + +private: + QJsonObject buildRegisterOpenWithRequest(const QString &name, + const QList &filePatterns, + const QJsonObject &handlerMethod); +}; + +} // End namespace MoleQueue + +#endif // MOLEQUEUE_CLIENT_H diff --git a/avogadro/molequeue/client/jobobject.cpp b/avogadro/molequeue/client/jobobject.cpp new file mode 100644 index 0000000000..7a801b3a50 --- /dev/null +++ b/avogadro/molequeue/client/jobobject.cpp @@ -0,0 +1,142 @@ +/****************************************************************************** + + This source file is part of the MoleQueue project. + + Copyright 2012 Kitware, Inc. + + This source code is released under the New BSD License, (the "License"). + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +******************************************************************************/ + +#include "jobobject.h" + +#include + +namespace MoleQueue +{ + +JobObject::JobObject() +{ +} + +JobObject::~JobObject() +{ +} + +void JobObject::setValue(const QString &key, const QVariant &value_) +{ + m_value[key] = QJsonValue::fromVariant(value_); +} + +QVariant JobObject::value(const QString &key, + const QVariant &defaultValue) const +{ + return m_value.contains(key) ? m_value[key].toVariant() : defaultValue; +} + +void JobObject::setQueue(const QString &queueName) +{ + m_value["queue"] = queueName; +} + +QString JobObject::queue() const +{ + return m_value["queue"].toString(); +} + +void JobObject::setProgram(const QString &programName) +{ + m_value["program"] = programName; +} + +QString JobObject::program() const +{ + return m_value["program"].toString(); +} + +void JobObject::setDescription(const QString &descriptionText) +{ + m_value["description"] = descriptionText; +} + +QString JobObject::description() const +{ + return m_value["description"].toString(); +} + +void JobObject::setInputFile(const QString &fileName, const QString &contents) +{ + m_value["inputFile"] = fileSpec(fileName, contents); +} + +void JobObject::setInputFile(const QString &path) +{ + m_value["inputFile"] = fileSpec(path); +} + +void JobObject::setInputFile(const QJsonObject &file) +{ + m_value["inputFile"] = file; +} + +QJsonObject JobObject::inputFile() const +{ + return m_value["inputFile"].toObject(); +} + +void JobObject::appendAdditionalInputFile(const QString &fileName, + const QString &contents) +{ + QJsonArray extraInputFiles; + if (m_value["additionalInputFiles"].isArray()) + extraInputFiles = m_value["additionalInputFiles"].toArray(); + extraInputFiles.append(fileSpec(fileName, contents)); + m_value["additionalInputFiles"] = extraInputFiles; +} + +void JobObject::appendAdditionalInputFile(const QString &path) +{ + QJsonArray extraInputFiles; + if (m_value["additionalInputFiles"].isArray()) + extraInputFiles = m_value["additionalInputFiles"].toArray(); + extraInputFiles.append(fileSpec(path)); + m_value["additionalInputFiles"] = extraInputFiles; +} + +void JobObject::setAdditionalInputFiles(const QJsonArray &files) +{ + m_value["additionalInputFiles"] = files; +} + +void JobObject::clearAdditionalInputFiles() +{ + m_value.remove("additionalInputFiles"); +} + +QJsonArray JobObject::additionalInputFiles() const +{ + return m_value["additionalInputFiles"].toArray(); +} + +QJsonObject JobObject::fileSpec(const QString &fileName, const QString &contents) +{ + QJsonObject result; + result["filename"] = fileName; + result["contents"] = contents; + return result; +} + +QJsonObject JobObject::fileSpec(const QString &path) +{ + QJsonObject result; + result["path"] = path; + return result; +} + +} // End namespace MoleQueue diff --git a/avogadro/molequeue/client/jobobject.h b/avogadro/molequeue/client/jobobject.h new file mode 100644 index 0000000000..99eb8b22f5 --- /dev/null +++ b/avogadro/molequeue/client/jobobject.h @@ -0,0 +1,174 @@ +/****************************************************************************** + + This source file is part of the MoleQueue project. + + Copyright 2012 Kitware, Inc. + + This source code is released under the New BSD License, (the "License"). + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +******************************************************************************/ + +#ifndef MOLEQUEUE_JOBOBJECT_H +#define MOLEQUEUE_JOBOBJECT_H + +#include "avogadromolequeueexport.h" + +#include + +#include +#include + +namespace MoleQueue +{ + +/** + * @class JobObject jobobject.h + * @brief Simple client-side representation for a MoleQueue job. + * @author Marcus D. Hanwell + * + * The Job class provides a simple interface to the client side representation + * of a job to be submitted to MoleQueue. Any fields that are not set/present + * will be omitted entirely, or set to default values by MoleQueue. The internal + * representation of a job (and the transport used) is JSON. + * + * The Job class and data structure is very lightweight, and designed to be + * easily copied, modified and passed around. + */ + +class AVOGADROMOLEQUEUE_EXPORT JobObject +{ +public: + JobObject(); + ~JobObject(); + + /** Set the @p value of the specified @p key. */ + void setValue(const QString &key, const QVariant &value); + + /** Get the value of the specified @p key. If the key is not set, return + * @p defaultValue. */ + QVariant value(const QString &key, + const QVariant &defaultValue = QVariant()) const; + + /** + * Set the job up using the supplied JSON object. This replaces all previous + * settings that may have been applied. + */ + void fromJson(const QJsonObject &jsonObject) { m_value = jsonObject; } + + /** Get the JSON object with the current job settings in it. */ + QJsonObject json() const { return m_value; } + + /** + * Set the queue that the job should be submitted to. This must be a valid + * queue name discovered using the client API. + */ + void setQueue(const QString &queueName); + + /** + * Get the name of the queue that the job will be submitted to. An empty + * string means that no queue has been set. + */ + QString queue() const; + + /** + * Set the program that the job should be submitted to. This must be a valid + * program in a valid queue as discovered using the client API. + */ + void setProgram(const QString &programName); + + /** + * Get the name of the program that the job will be submitted to. An empty + * string means that no program has been set. + */ + QString program() const; + + /** + * Set the description of the job, this is free text. + */ + void setDescription(const QString &descriptionText); + + /** + * Get the description of the job. + */ + QString description() const; + + /** + * @brief Set the input file for the job. + * @param fileName The file name as it will appear in the working directory. + * @param contents The contents of the file specified. + */ + void setInputFile(const QString &fileName, const QString &contents); + + /** + * Set the input file for the job, the file will be copied and the file name + * used in the working directory of the job submission. + * \param path The full path to the input file. + */ + void setInputFile(const QString &path); + + /** + * Set the input file using a JSON object. This must conform to the file + * specification. + * @param file A JSON object employing file specification to specify input. + */ + void setInputFile(const QJsonObject &file); + + /** + * Get the input file for the job. This is a JSON object using the file spec. + */ + QJsonObject inputFile() const; + + /** + * Append an additional input file for the job. + * @param fileName The file name as it will appear in the working directory. + * @param contents The contents of the file specified. + */ + void appendAdditionalInputFile(const QString &fileName, + const QString &contents); + + /** + * Append an additional input file for the job, the file will be copied and + * the file name used in the working directory of the job submission. + * @param path The full path to the input file. + */ + void appendAdditionalInputFile(const QString &path); + + /** + * Set the additional input file using a JSON object. This must conform to the + * file specification. + * @param files A JSON array employing file specification to specify input. + */ + void setAdditionalInputFiles(const QJsonArray &files); + + /** Clear additional input files. */ + void clearAdditionalInputFiles(); + + /** + * Get the additional input files for the job. This is a JSON object using the + * file spec. + */ + QJsonArray additionalInputFiles() const; + +protected: + QJsonObject m_value; + + /** + * Generate a filespec JSON object form the supplied file name and contents. + */ + QJsonObject fileSpec(const QString &fileName, const QString &contents); + + /** + * Generate a filespec JSON object form the supplied file path (must exist). + */ + QJsonObject fileSpec(const QString &path); +}; + +} // End namespace MoleQueue + +#endif // MOLEQUEUE_JOBOBJECT_H diff --git a/avogadro/molequeue/client/jsonrpcclient.cpp b/avogadro/molequeue/client/jsonrpcclient.cpp new file mode 100644 index 0000000000..bd2a91ed96 --- /dev/null +++ b/avogadro/molequeue/client/jsonrpcclient.cpp @@ -0,0 +1,157 @@ +/****************************************************************************** + + This source file is part of the MoleQueue project. + + Copyright 2012-2013 Kitware, Inc. + + This source code is released under the New BSD License, (the "License"). + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +******************************************************************************/ + +#include "jsonrpcclient.h" + +#include +#include +#include +#include + +namespace MoleQueue +{ + +JsonRpcClient::JsonRpcClient(QObject *parent_) : + QObject(parent_), + m_packetCounter(0), + m_socket(NULL) +{ + connect(this, SIGNAL(newPacket(QByteArray)), SLOT(readPacket(QByteArray)), + Qt::QueuedConnection); +} + +JsonRpcClient::~JsonRpcClient() +{ + flush(); +} + +bool JsonRpcClient::isConnected() const +{ + if (!m_socket) + return false; + else + return m_socket->isOpen(); +} + +bool JsonRpcClient::connectToServer(const QString &serverName_) +{ + if (m_socket && m_socket->isOpen()) { + if (m_socket->serverName() == serverName_) { + return false; + } + else { + m_socket->close(); + delete m_socket; + m_socket = NULL; + } + } + + // New connection. + if (m_socket == NULL) { + m_socket = new QLocalSocket(this); + connect(m_socket, SIGNAL(readyRead()), this, SLOT(readSocket())); + } + + if (serverName_.isEmpty()) { + return false; + } + else { + m_socket->connectToServer(serverName_); + return isConnected(); + } +} + +QString JsonRpcClient::serverName() const +{ + if (m_socket) + return m_socket->serverName(); + else + return QString(); +} + +void JsonRpcClient::flush() +{ + if (m_socket) + m_socket->flush(); +} + +QJsonObject JsonRpcClient::emptyRequest() +{ + QJsonObject request; + request["jsonrpc"] = QLatin1String("2.0"); + request["id"] = static_cast(m_packetCounter++); + return request; +} + +bool JsonRpcClient::sendRequest(const QJsonObject &request) +{ + if (!m_socket) + return false; + + QJsonDocument document(request); + QDataStream stream(m_socket); + stream.setVersion(QDataStream::Qt_4_8); + stream << document.toJson(); + return true; +} + +void JsonRpcClient::readPacket(const QByteArray message) +{ + // Read packet into a Json value + QJsonParseError error; + QJsonDocument reader = QJsonDocument::fromJson(message, &error); + + if (error.error != QJsonParseError::NoError) { + emit badPacketReceived("Unparseable message received\n:" + + error.errorString() + "\nContent: " + message); + return; + } + else if (!reader.isObject()) { + // We need a valid object, something bad happened. + emit badPacketReceived("Packet did not contain a valid JSON object."); + return; + } + else { + QJsonObject root = reader.object(); + if (root["method"] != QJsonValue::Null) { + if (root["id"] != QJsonValue::Null) + emit badPacketReceived("Received a request packet for the client."); + else + emit notificationReceived(root); + } + if (root["result"] != QJsonValue::Null) { + // This is a result packet, and should emit a signal. + emit resultReceived(root); + } + else if (root["error"] != QJsonValue::Null) { + emit errorReceived(root); + } + } +} + +void JsonRpcClient::readSocket() +{ + if (m_socket->bytesAvailable() > 0) { + QDataStream stream(m_socket); + QByteArray json; + stream >> json; + emit newPacket(json); + if (m_socket->bytesAvailable() > 0) + QTimer::singleShot(0, this, SLOT(readSocket())); + } +} + +} // End namespace MoleQueue diff --git a/avogadro/molequeue/client/jsonrpcclient.h b/avogadro/molequeue/client/jsonrpcclient.h new file mode 100644 index 0000000000..2473a8aa71 --- /dev/null +++ b/avogadro/molequeue/client/jsonrpcclient.h @@ -0,0 +1,153 @@ +/****************************************************************************** + + This source file is part of the MoleQueue project. + + Copyright 2012-2013 Kitware, Inc. + + This source code is released under the New BSD License, (the "License"). + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +******************************************************************************/ + +#ifndef MOLEQUEUE_JSONRPCCLIENT_H +#define MOLEQUEUE_JSONRPCCLIENT_H + +#include "avogadromolequeueexport.h" + +#include +#include + +class QLocalSocket; + +namespace MoleQueue +{ + +/** + * @class JsonRpcClient jsonrpcclient.h + * @brief The JsonRpcClient class is used by clients to submit calls to an RPC + * server using JSON-RPC 2.0. + * @author Marcus D. Hanwell + * + * Provides a simple Qt C++ API to make JSON-RPC 2.0 calls to an RPC server. To + * create a client connection and call a method the following should be done: + * + @code + #include + + MoleQueue::JsonRpcClient *client = new MoleQueue::JsonRpcClient(this); + client->connectToServer("MyRpcServer"); + QJsonObject request(client->emptyRequest()); + request["method"] = QLatin1String("listQueues"); + client->sendRequest(request); + @endcode + * + * You should connect to the appropriate signals in order to act on results, + * notifications and errors received in response to requests set using the + * client connection. + */ + +class AVOGADROMOLEQUEUE_EXPORT JsonRpcClient : public QObject +{ + Q_OBJECT + +public: + explicit JsonRpcClient(QObject *parent_ = 0); + ~JsonRpcClient(); + + /** + * Query if the client is connected to a server. + * @return True if connected, false if not. + */ + bool isConnected() const; + + /** + * @return The server name that the client is connected to. + */ + QString serverName() const; + +public slots: + /** + * Connect to the server. + * @param serverName Name of the socket to connect to. + */ + bool connectToServer(const QString &serverName); + + /** + * @brief 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 flush(); + + /** + * Use this function to construct an empty JSON-RPC 2.0 request, with a valid + * request id, JSON-RPC 2.0 key etc. + * @return a standard empty JSON-RPC 2.0 packet, the method etc is empty. + */ + QJsonObject emptyRequest(); + + /** + * Send the Json request to the RPC server. + * @param request The JSON-RPC 2.0 request object. + * @return True on success, false on failure. + */ + bool sendRequest(const QJsonObject &request); + +protected slots: + /** + * Read incoming packets of data from the server. + */ + void readPacket(const QByteArray message); + + /** + * Read incoming data, interpret JSON stream. + */ + void readSocket(); + +signals: + /** + * Emitted when the connection state changes. + */ + void connectionStateChanged(); + + /** + * Emitted when a result is received. + */ + void resultReceived(QJsonObject message); + + /** + * Emitted when a notification is received. + */ + void notificationReceived(QJsonObject message); + + /** + * Emitted when an error response is received. + */ + void errorReceived(QJsonObject message); + + /** + * Emitted when a bad packet was received that the client could not parse. + */ + void badPacketReceived(QString error); + + /** + * Emitted when a new packet of data is received. This is handled internally, + * other classes should listen to resultReceived, notificationReceived, + * errorReceived, and badPacketReceived. + */ + void newPacket(const QByteArray &packet); + +protected: + unsigned int m_packetCounter; + QLocalSocket *m_socket; +}; + +} // End namespace MoleQueue + +#endif // MOLEQUEUE_JSONRPCCLIENT_H diff --git a/avogadro/molequeue/inputgeneratorwidget.cpp b/avogadro/molequeue/inputgeneratorwidget.cpp index bfc9de9c26..5d06d0ba89 100644 --- a/avogadro/molequeue/inputgeneratorwidget.cpp +++ b/avogadro/molequeue/inputgeneratorwidget.cpp @@ -24,8 +24,6 @@ #include #include -#include - #include #include #include diff --git a/avogadro/molequeue/molequeuedialog.cpp b/avogadro/molequeue/molequeuedialog.cpp index bce86e57cc..40ec1942ef 100644 --- a/avogadro/molequeue/molequeuedialog.cpp +++ b/avogadro/molequeue/molequeuedialog.cpp @@ -18,8 +18,6 @@ #include "molequeuewidget.h" #include "ui_molequeuedialog.h" -#include - #include #include diff --git a/avogadro/molequeue/molequeuemanager.h b/avogadro/molequeue/molequeuemanager.h index ef012bf7bf..ffa1b01115 100644 --- a/avogadro/molequeue/molequeuemanager.h +++ b/avogadro/molequeue/molequeuemanager.h @@ -23,7 +23,7 @@ #include -#include +#include "client/client.h" namespace Avogadro { namespace MoleQueue { diff --git a/avogadro/molequeue/molequeuewidget.h b/avogadro/molequeue/molequeuewidget.h index 213ad70083..0095d7bacf 100644 --- a/avogadro/molequeue/molequeuewidget.h +++ b/avogadro/molequeue/molequeuewidget.h @@ -22,7 +22,7 @@ #include -#include +#include "client/jobobject.h" namespace Avogadro { namespace MoleQueue { From 340415517479e93f4a9d90b0290faacd1bdc5501 Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Fri, 28 May 2021 14:24:33 -0400 Subject: [PATCH 2/4] Move into the Avogadro nested namespace Needed a few edits for odd use of namespace that was less flexible than desired, it looks a lot simpler now too. Signed-off-by: Marcus D. Hanwell --- avogadro/molequeue/batchjob.cpp | 8 +++----- avogadro/molequeue/batchjob.h | 14 +++++++------- avogadro/molequeue/client/client.cpp | 5 +++-- avogadro/molequeue/client/client.h | 11 ++++++----- avogadro/molequeue/client/jobobject.cpp | 5 +++-- avogadro/molequeue/client/jobobject.h | 11 ++++++----- avogadro/molequeue/client/jsonrpcclient.cpp | 5 +++-- avogadro/molequeue/client/jsonrpcclient.h | 11 ++++++----- avogadro/molequeue/inputgeneratorwidget.cpp | 6 ++---- avogadro/molequeue/inputgeneratorwidget.h | 7 ++----- avogadro/molequeue/molequeuedialog.cpp | 2 -- avogadro/molequeue/molequeuedialog.h | 9 +++------ avogadro/molequeue/molequeuemanager.cpp | 4 ++-- avogadro/molequeue/molequeuemanager.h | 8 ++++---- avogadro/molequeue/molequeuewidget.cpp | 3 --- avogadro/molequeue/molequeuewidget.h | 12 ++++++------ 16 files changed, 56 insertions(+), 65 deletions(-) diff --git a/avogadro/molequeue/batchjob.cpp b/avogadro/molequeue/batchjob.cpp index 4e9cfc5822..3a80c36b0a 100644 --- a/avogadro/molequeue/batchjob.cpp +++ b/avogadro/molequeue/batchjob.cpp @@ -21,8 +21,6 @@ #include -using MoleQueue::JobObject; - namespace Avogadro { namespace MoleQueue { @@ -78,7 +76,7 @@ BatchJob::BatchId BatchJob::submitNextJob(const Core::Molecule& mol) BatchId bId = m_jobObjects.size(); // Create the job object: - ::MoleQueue::JobObject job; + JobObject job; job.fromJson(m_moleQueueOptions); job.setDescription( tr("Batch Job #%L1 (%2)").arg(bId + 1).arg(job.description())); @@ -119,7 +117,7 @@ bool BatchJob::lookupJob(BatchId bId) if (!mqManager.connectIfNeeded()) return false; - ::MoleQueue::Client& client = mqManager.client(); + Client& client = mqManager.client(); RequestId rId = client.lookupJob(sId); m_requests.insert(rId, Request(Request::LookupJob, bId)); return true; @@ -223,7 +221,7 @@ void BatchJob::setup() } MoleQueueManager& mqManager = MoleQueueManager::instance(); - ::MoleQueue::Client& client = mqManager.client(); + Client& client = mqManager.client(); connect(&client, SIGNAL(submitJobResponse(int, uint)), SLOT(handleSubmissionReply(int, uint))); connect(&client, SIGNAL(lookupJobResponse(int, QJsonObject)), diff --git a/avogadro/molequeue/batchjob.h b/avogadro/molequeue/batchjob.h index a1597e5d28..a2259e1e20 100644 --- a/avogadro/molequeue/batchjob.h +++ b/avogadro/molequeue/batchjob.h @@ -107,7 +107,7 @@ class AVOGADROMOLEQUEUE_EXPORT BatchJob : public QObject */ void setMoleQueueOptions(const QJsonObject& opts); QJsonObject moleQueueOptions() const; - ::MoleQueue::JobObject moleQueueJobTemplate() const; + JobObject moleQueueJobTemplate() const; /**@}*/ /** @@ -138,7 +138,7 @@ class AVOGADROMOLEQUEUE_EXPORT BatchJob : public QObject * @return The most recent JobObject for the job with the batch id @a batchId. * These are updated for each change in job state. */ - ::MoleQueue::JobObject jobObject(BatchId batchId) const; + JobObject jobObject(BatchId batchId) const; /** * @return True if @a state corresponds to a job that is finished running. @@ -237,7 +237,7 @@ private slots: QJsonObject m_moleQueueOptions; /// Cached job states. - QList<::MoleQueue::JobObject> m_jobObjects; + QList m_jobObjects; /// Lookup batch ids from server ids. QMap m_serverIds; /// Job states. For fast lookups without string conversions. @@ -270,9 +270,9 @@ inline QJsonObject BatchJob::moleQueueOptions() const return m_moleQueueOptions; } -inline ::MoleQueue::JobObject BatchJob::moleQueueJobTemplate() const +inline JobObject BatchJob::moleQueueJobTemplate() const { - ::MoleQueue::JobObject result; + JobObject result; result.fromJson(m_moleQueueOptions); return result; } @@ -306,9 +306,9 @@ inline BatchJob::ServerId BatchJob::serverId(BatchJob::BatchId id) const : InvalidServerId; } -inline ::MoleQueue::JobObject BatchJob::jobObject(BatchJob::BatchId id) const +inline JobObject BatchJob::jobObject(BatchJob::BatchId id) const { - return id < m_jobObjects.size() ? m_jobObjects[id] : ::MoleQueue::JobObject(); + return id < m_jobObjects.size() ? m_jobObjects[id] : JobObject(); } inline bool BatchJob::isTerminal(BatchJob::JobState state) diff --git a/avogadro/molequeue/client/client.cpp b/avogadro/molequeue/client/client.cpp index c1c3b291fe..fe1437c587 100644 --- a/avogadro/molequeue/client/client.cpp +++ b/avogadro/molequeue/client/client.cpp @@ -21,8 +21,8 @@ #include -namespace MoleQueue -{ +namespace Avogadro { +namespace MoleQueue { Client::Client(QObject *parent_) : QObject(parent_), m_jsonRpcClient(NULL) { @@ -308,3 +308,4 @@ QJsonObject Client::buildRegisterOpenWithRequest( } } // End namespace MoleQueue +} // End namespace Avogadro diff --git a/avogadro/molequeue/client/client.h b/avogadro/molequeue/client/client.h index dacb6f1835..6aca87d730 100644 --- a/avogadro/molequeue/client/client.h +++ b/avogadro/molequeue/client/client.h @@ -14,8 +14,8 @@ ******************************************************************************/ -#ifndef MOLEQUEUE_CLIENT_H -#define MOLEQUEUE_CLIENT_H +#ifndef AVOGADRO_MOLEQUEUE_CLIENT_H +#define AVOGADRO_MOLEQUEUE_CLIENT_H #include "avogadromolequeueexport.h" @@ -25,8 +25,8 @@ #include #include -namespace MoleQueue -{ +namespace Avogadro { +namespace MoleQueue { class JsonRpcClient; class JobObject; @@ -256,5 +256,6 @@ protected slots: }; } // End namespace MoleQueue +} // End namespace Avogadro -#endif // MOLEQUEUE_CLIENT_H +#endif // AVOGADRO_MOLEQUEUE_CLIENT_H diff --git a/avogadro/molequeue/client/jobobject.cpp b/avogadro/molequeue/client/jobobject.cpp index 7a801b3a50..fb0ae7672b 100644 --- a/avogadro/molequeue/client/jobobject.cpp +++ b/avogadro/molequeue/client/jobobject.cpp @@ -18,8 +18,8 @@ #include -namespace MoleQueue -{ +namespace Avogadro { +namespace MoleQueue { JobObject::JobObject() { @@ -140,3 +140,4 @@ QJsonObject JobObject::fileSpec(const QString &path) } } // End namespace MoleQueue +} // End namespace Avogadro diff --git a/avogadro/molequeue/client/jobobject.h b/avogadro/molequeue/client/jobobject.h index 99eb8b22f5..07c79b8cb0 100644 --- a/avogadro/molequeue/client/jobobject.h +++ b/avogadro/molequeue/client/jobobject.h @@ -14,8 +14,8 @@ ******************************************************************************/ -#ifndef MOLEQUEUE_JOBOBJECT_H -#define MOLEQUEUE_JOBOBJECT_H +#ifndef AVOGADRO_MOLEQUEUE_JOBOBJECT_H +#define AVOGADRO_MOLEQUEUE_JOBOBJECT_H #include "avogadromolequeueexport.h" @@ -24,8 +24,8 @@ #include #include -namespace MoleQueue -{ +namespace Avogadro { +namespace MoleQueue { /** * @class JobObject jobobject.h @@ -170,5 +170,6 @@ class AVOGADROMOLEQUEUE_EXPORT JobObject }; } // End namespace MoleQueue +} // End namespace Avogadro -#endif // MOLEQUEUE_JOBOBJECT_H +#endif // AVOGADRO_MOLEQUEUE_JOBOBJECT_H diff --git a/avogadro/molequeue/client/jsonrpcclient.cpp b/avogadro/molequeue/client/jsonrpcclient.cpp index bd2a91ed96..3396a0c634 100644 --- a/avogadro/molequeue/client/jsonrpcclient.cpp +++ b/avogadro/molequeue/client/jsonrpcclient.cpp @@ -21,8 +21,8 @@ #include #include -namespace MoleQueue -{ +namespace Avogadro { +namespace MoleQueue { JsonRpcClient::JsonRpcClient(QObject *parent_) : QObject(parent_), @@ -155,3 +155,4 @@ void JsonRpcClient::readSocket() } } // End namespace MoleQueue +} // End namespace Avogadro diff --git a/avogadro/molequeue/client/jsonrpcclient.h b/avogadro/molequeue/client/jsonrpcclient.h index 2473a8aa71..3634a273b4 100644 --- a/avogadro/molequeue/client/jsonrpcclient.h +++ b/avogadro/molequeue/client/jsonrpcclient.h @@ -14,8 +14,8 @@ ******************************************************************************/ -#ifndef MOLEQUEUE_JSONRPCCLIENT_H -#define MOLEQUEUE_JSONRPCCLIENT_H +#ifndef AVOGADRO_MOLEQUEUE_JSONRPCCLIENT_H +#define AVOGADRO_MOLEQUEUE_JSONRPCCLIENT_H #include "avogadromolequeueexport.h" @@ -24,8 +24,8 @@ class QLocalSocket; -namespace MoleQueue -{ +namespace Avogadro { +namespace MoleQueue { /** * @class JsonRpcClient jsonrpcclient.h @@ -149,5 +149,6 @@ protected slots: }; } // End namespace MoleQueue +} // End namespace Avogadro -#endif // MOLEQUEUE_JSONRPCCLIENT_H +#endif // AVOGADRO_MOLEQUEUE_JSONRPCCLIENT_H diff --git a/avogadro/molequeue/inputgeneratorwidget.cpp b/avogadro/molequeue/inputgeneratorwidget.cpp index 5d06d0ba89..91a95162f4 100644 --- a/avogadro/molequeue/inputgeneratorwidget.cpp +++ b/avogadro/molequeue/inputgeneratorwidget.cpp @@ -43,8 +43,6 @@ namespace Avogadro { namespace MoleQueue { -using ::MoleQueue::JobObject; - InputGeneratorWidget::InputGeneratorWidget(QWidget* parent_) : QWidget(parent_), m_ui(new Ui::InputGeneratorWidget), m_molecule(nullptr), m_updatePending(false), m_batchMode(false), m_inputGenerator(QString()) @@ -96,7 +94,7 @@ bool InputGeneratorWidget::configureBatchJob(BatchJob& batch) const if (mqOpts.empty()) return false; - MoleQueue::JobObject job; + JobObject job; job.fromJson(mqOpts); QJsonObject calcOpts; @@ -623,7 +621,7 @@ QJsonObject InputGeneratorWidget::promptForBatchJobOptions() const int numCores = optionString("Processor Cores", coresString) ? coresString.toInt() : 1; - MoleQueue::JobObject job; + JobObject job; job.setProgram(m_inputGenerator.displayName()); job.setValue("numberOfCores", numCores); diff --git a/avogadro/molequeue/inputgeneratorwidget.h b/avogadro/molequeue/inputgeneratorwidget.h index 66c2e300c8..c25d3072b6 100644 --- a/avogadro/molequeue/inputgeneratorwidget.h +++ b/avogadro/molequeue/inputgeneratorwidget.h @@ -27,16 +27,13 @@ class QJsonValue; class QTextEdit; class QWidget; -namespace MoleQueue { -class JobObject; -} - namespace Avogadro { namespace QtGui { class Molecule; } namespace MoleQueue { +class JobObject; namespace Ui { class InputGeneratorWidget; } @@ -117,7 +114,7 @@ public slots: /** * Emitted when the user requests that a job's output be loaded in Avogadro. */ - void openJobOutput(const ::MoleQueue::JobObject& job); + void openJobOutput(const JobObject& job); protected: /** diff --git a/avogadro/molequeue/molequeuedialog.cpp b/avogadro/molequeue/molequeuedialog.cpp index 40ec1942ef..4e688bd0b3 100644 --- a/avogadro/molequeue/molequeuedialog.cpp +++ b/avogadro/molequeue/molequeuedialog.cpp @@ -27,8 +27,6 @@ namespace Avogadro { namespace MoleQueue { -using ::MoleQueue::JobObject; - MoleQueueDialog::MoleQueueDialog(QWidget* parent_) : QDialog(parent_), m_ui(new Ui::MoleQueueDialog) { diff --git a/avogadro/molequeue/molequeuedialog.h b/avogadro/molequeue/molequeuedialog.h index d4f7484603..95c3aaa7ad 100644 --- a/avogadro/molequeue/molequeuedialog.h +++ b/avogadro/molequeue/molequeuedialog.h @@ -22,12 +22,9 @@ #include -namespace MoleQueue { -class JobObject; -} - namespace Avogadro { namespace MoleQueue { +class JobObject; class MoleQueueWidget; namespace Ui { @@ -139,7 +136,7 @@ class AVOGADROMOLEQUEUE_EXPORT MoleQueueDialog : public QDialog * @return A SubmitStatus enum value indicating the result of the submission. */ static SubmitStatus submitJob(QWidget* parent_, const QString& caption, - ::MoleQueue::JobObject& jobTemplate, + JobObject& jobTemplate, SubmitOptions options, unsigned int* moleQueueId = nullptr, int* submissionRequestId = nullptr); @@ -153,7 +150,7 @@ class AVOGADROMOLEQUEUE_EXPORT MoleQueueDialog : public QDialog * @return True on success, false otherwise. */ static bool promptForJobOptions(QWidget* windowParent, const QString& caption, - ::MoleQueue::JobObject& jobTemplate); + JobObject& jobTemplate); /** * @return A reference to the internal MoleQueueWidget instance. diff --git a/avogadro/molequeue/molequeuemanager.cpp b/avogadro/molequeue/molequeuemanager.cpp index 216dc64b27..239d525c77 100644 --- a/avogadro/molequeue/molequeuemanager.cpp +++ b/avogadro/molequeue/molequeuemanager.cpp @@ -42,12 +42,12 @@ bool MoleQueueManager::connectIfNeeded() return m_client.isConnected() || m_client.connectToServer(); } -::MoleQueue::Client& MoleQueueManager::client() +Client& MoleQueueManager::client() { return m_client; } -const ::MoleQueue::Client& MoleQueueManager::client() const +const Client& MoleQueueManager::client() const { return m_client; } diff --git a/avogadro/molequeue/molequeuemanager.h b/avogadro/molequeue/molequeuemanager.h index ffa1b01115..6e4e659dfc 100644 --- a/avogadro/molequeue/molequeuemanager.h +++ b/avogadro/molequeue/molequeuemanager.h @@ -59,11 +59,11 @@ class AVOGADROMOLEQUEUE_EXPORT MoleQueueManager : public QObject bool connectIfNeeded(); /** - * @return A reference to the managed MoleQueue::Client instance. + * @return A reference to the managed Client instance. * @{ */ - ::MoleQueue::Client& client(); - const ::MoleQueue::Client& client() const; + Client& client(); + const Client& client() const; /** @} */ /** @@ -89,7 +89,7 @@ private slots: private: static MoleQueueManager* m_instance; - ::MoleQueue::Client m_client; + Client m_client; MoleQueueQueueListModel m_queueModel; }; diff --git a/avogadro/molequeue/molequeuewidget.cpp b/avogadro/molequeue/molequeuewidget.cpp index b27d7183f8..dd3bae11be 100644 --- a/avogadro/molequeue/molequeuewidget.cpp +++ b/avogadro/molequeue/molequeuewidget.cpp @@ -28,9 +28,6 @@ namespace Avogadro { namespace MoleQueue { -using ::MoleQueue::JobObject; -using ::MoleQueue::Client; - const unsigned int MoleQueueWidget::InvalidMoleQueueId( std::numeric_limits::max()); diff --git a/avogadro/molequeue/molequeuewidget.h b/avogadro/molequeue/molequeuewidget.h index 0095d7bacf..4878a7eb26 100644 --- a/avogadro/molequeue/molequeuewidget.h +++ b/avogadro/molequeue/molequeuewidget.h @@ -50,10 +50,10 @@ class AVOGADROMOLEQUEUE_EXPORT MoleQueueWidget : public QWidget * that will be submitted by submitJobRequest. * @{ */ - ::MoleQueue::JobObject& jobTemplate(); - const ::MoleQueue::JobObject& jobTemplate() const; + JobObject& jobTemplate(); + const JobObject& jobTemplate() const; public slots: - void setJobTemplate(const ::MoleQueue::JobObject& job); + void setJobTemplate(const JobObject& job); public: /** @} */ @@ -147,7 +147,7 @@ public slots: * @return A JobObject with the GUI options. Any settings in jobTemplate that * are not handled by the GUI are passed through untouched to the new object. */ - ::MoleQueue::JobObject configuredJob() const; + JobObject configuredJob() const; public slots: /** @@ -182,7 +182,7 @@ public slots: * Emitted after a successful call to requestJobLookup(). * @param job The result of the lookupJob() RPC query. */ - void jobUpdated(const ::MoleQueue::JobObject& job); + void jobUpdated(const JobObject& job); private slots: void showAndSelectProgramHandler(); @@ -201,7 +201,7 @@ private slots: void listenForJobStateChange(bool listen = true); Ui::MoleQueueWidget* m_ui; - ::MoleQueue::JobObject m_jobTemplate; + JobObject m_jobTemplate; QString m_jobState; QString m_submissionError; int m_requestId; From fc9969a096362c6a752950cebe07a108bf6a7dc3 Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Fri, 28 May 2021 14:28:29 -0400 Subject: [PATCH 3/4] Updated to the modern, simple copyright header Signed-off-by: Marcus D. Hanwell --- avogadro/molequeue/batchjob.cpp | 13 +------------ avogadro/molequeue/batchjob.h | 13 +------------ avogadro/molequeue/client/client.cpp | 15 ++------------- avogadro/molequeue/client/client.h | 15 ++------------- avogadro/molequeue/client/jobobject.cpp | 15 ++------------- avogadro/molequeue/client/jobobject.h | 15 ++------------- avogadro/molequeue/client/jsonrpcclient.cpp | 15 ++------------- avogadro/molequeue/client/jsonrpcclient.h | 15 ++------------- avogadro/molequeue/inputgenerator.cpp | 13 +------------ avogadro/molequeue/inputgenerator.h | 13 +------------ avogadro/molequeue/inputgeneratordialog.cpp | 13 +------------ avogadro/molequeue/inputgeneratordialog.h | 13 +------------ avogadro/molequeue/inputgeneratorwidget.cpp | 13 +------------ avogadro/molequeue/inputgeneratorwidget.h | 13 +------------ avogadro/molequeue/molequeuedialog.cpp | 13 +------------ avogadro/molequeue/molequeuedialog.h | 13 +------------ avogadro/molequeue/molequeuemanager.cpp | 13 +------------ avogadro/molequeue/molequeuemanager.h | 13 +------------ avogadro/molequeue/molequeuequeuelistmodel.cpp | 13 +------------ avogadro/molequeue/molequeuequeuelistmodel.h | 13 +------------ avogadro/molequeue/molequeuewidget.cpp | 13 +------------ avogadro/molequeue/molequeuewidget.h | 13 +------------ 22 files changed, 28 insertions(+), 270 deletions(-) diff --git a/avogadro/molequeue/batchjob.cpp b/avogadro/molequeue/batchjob.cpp index 3a80c36b0a..8e5cb50c92 100644 --- a/avogadro/molequeue/batchjob.cpp +++ b/avogadro/molequeue/batchjob.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "batchjob.h" diff --git a/avogadro/molequeue/batchjob.h b/avogadro/molequeue/batchjob.h index a2259e1e20..e1e37a34be 100644 --- a/avogadro/molequeue/batchjob.h +++ b/avogadro/molequeue/batchjob.h @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_QTGUI_BATCHJOB_H diff --git a/avogadro/molequeue/client/client.cpp b/avogadro/molequeue/client/client.cpp index fe1437c587..f8505c0034 100644 --- a/avogadro/molequeue/client/client.cpp +++ b/avogadro/molequeue/client/client.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - - This source file is part of the MoleQueue project. - - Copyright 2012-2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source file is part of the Avogadro project. + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "client.h" diff --git a/avogadro/molequeue/client/client.h b/avogadro/molequeue/client/client.h index 6aca87d730..9a8eb2a61a 100644 --- a/avogadro/molequeue/client/client.h +++ b/avogadro/molequeue/client/client.h @@ -1,17 +1,6 @@ /****************************************************************************** - - This source file is part of the MoleQueue project. - - Copyright 2012-2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source file is part of the Avogadro project. + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_CLIENT_H diff --git a/avogadro/molequeue/client/jobobject.cpp b/avogadro/molequeue/client/jobobject.cpp index fb0ae7672b..282cbd936b 100644 --- a/avogadro/molequeue/client/jobobject.cpp +++ b/avogadro/molequeue/client/jobobject.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - - This source file is part of the MoleQueue project. - - Copyright 2012 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source file is part of the Avogadro project. + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "jobobject.h" diff --git a/avogadro/molequeue/client/jobobject.h b/avogadro/molequeue/client/jobobject.h index 07c79b8cb0..317faa9b4b 100644 --- a/avogadro/molequeue/client/jobobject.h +++ b/avogadro/molequeue/client/jobobject.h @@ -1,17 +1,6 @@ /****************************************************************************** - - This source file is part of the MoleQueue project. - - Copyright 2012 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source file is part of the Avogadro project. + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_JOBOBJECT_H diff --git a/avogadro/molequeue/client/jsonrpcclient.cpp b/avogadro/molequeue/client/jsonrpcclient.cpp index 3396a0c634..5ec5a796c5 100644 --- a/avogadro/molequeue/client/jsonrpcclient.cpp +++ b/avogadro/molequeue/client/jsonrpcclient.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - - This source file is part of the MoleQueue project. - - Copyright 2012-2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source file is part of the Avogadro project. + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "jsonrpcclient.h" diff --git a/avogadro/molequeue/client/jsonrpcclient.h b/avogadro/molequeue/client/jsonrpcclient.h index 3634a273b4..1987a6eafa 100644 --- a/avogadro/molequeue/client/jsonrpcclient.h +++ b/avogadro/molequeue/client/jsonrpcclient.h @@ -1,17 +1,6 @@ /****************************************************************************** - - This source file is part of the MoleQueue project. - - Copyright 2012-2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source file is part of the Avogadro project. + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_JSONRPCCLIENT_H diff --git a/avogadro/molequeue/inputgenerator.cpp b/avogadro/molequeue/inputgenerator.cpp index 4fac2f9960..0e98e44b94 100644 --- a/avogadro/molequeue/inputgenerator.cpp +++ b/avogadro/molequeue/inputgenerator.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "inputgenerator.h" diff --git a/avogadro/molequeue/inputgenerator.h b/avogadro/molequeue/inputgenerator.h index b71bdf119a..d281eadd6c 100644 --- a/avogadro/molequeue/inputgenerator.h +++ b/avogadro/molequeue/inputgenerator.h @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_INPUTGENERATOR_H diff --git a/avogadro/molequeue/inputgeneratordialog.cpp b/avogadro/molequeue/inputgeneratordialog.cpp index d15e7988ea..e3f91c4b9b 100644 --- a/avogadro/molequeue/inputgeneratordialog.cpp +++ b/avogadro/molequeue/inputgeneratordialog.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "inputgeneratordialog.h" diff --git a/avogadro/molequeue/inputgeneratordialog.h b/avogadro/molequeue/inputgeneratordialog.h index 77805f63e6..a07608bafd 100644 --- a/avogadro/molequeue/inputgeneratordialog.h +++ b/avogadro/molequeue/inputgeneratordialog.h @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_INPUTGENERATORDIALOG_H diff --git a/avogadro/molequeue/inputgeneratorwidget.cpp b/avogadro/molequeue/inputgeneratorwidget.cpp index 91a95162f4..06d2177e1d 100644 --- a/avogadro/molequeue/inputgeneratorwidget.cpp +++ b/avogadro/molequeue/inputgeneratorwidget.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "inputgeneratorwidget.h" diff --git a/avogadro/molequeue/inputgeneratorwidget.h b/avogadro/molequeue/inputgeneratorwidget.h index c25d3072b6..72816252c6 100644 --- a/avogadro/molequeue/inputgeneratorwidget.h +++ b/avogadro/molequeue/inputgeneratorwidget.h @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_INPUTGENERATORWIDGET_H diff --git a/avogadro/molequeue/molequeuedialog.cpp b/avogadro/molequeue/molequeuedialog.cpp index 4e688bd0b3..e536896c6f 100644 --- a/avogadro/molequeue/molequeuedialog.cpp +++ b/avogadro/molequeue/molequeuedialog.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "molequeuedialog.h" diff --git a/avogadro/molequeue/molequeuedialog.h b/avogadro/molequeue/molequeuedialog.h index 95c3aaa7ad..d9fff3cfa3 100644 --- a/avogadro/molequeue/molequeuedialog.h +++ b/avogadro/molequeue/molequeuedialog.h @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_MOLEQUEUEDIALOG_H diff --git a/avogadro/molequeue/molequeuemanager.cpp b/avogadro/molequeue/molequeuemanager.cpp index 239d525c77..3527d5f6df 100644 --- a/avogadro/molequeue/molequeuemanager.cpp +++ b/avogadro/molequeue/molequeuemanager.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "molequeuemanager.h" diff --git a/avogadro/molequeue/molequeuemanager.h b/avogadro/molequeue/molequeuemanager.h index 6e4e659dfc..0b3857b539 100644 --- a/avogadro/molequeue/molequeuemanager.h +++ b/avogadro/molequeue/molequeuemanager.h @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_MOLEQUEUEMANAGER_H diff --git a/avogadro/molequeue/molequeuequeuelistmodel.cpp b/avogadro/molequeue/molequeuequeuelistmodel.cpp index 3a77c28086..dd965f1b79 100644 --- a/avogadro/molequeue/molequeuequeuelistmodel.cpp +++ b/avogadro/molequeue/molequeuequeuelistmodel.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "molequeuequeuelistmodel.h" diff --git a/avogadro/molequeue/molequeuequeuelistmodel.h b/avogadro/molequeue/molequeuequeuelistmodel.h index 165489da7b..67aaa3c0a3 100644 --- a/avogadro/molequeue/molequeuequeuelistmodel.h +++ b/avogadro/molequeue/molequeuequeuelistmodel.h @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_MOLEQUEUEQUEUELISTMODEL_H diff --git a/avogadro/molequeue/molequeuewidget.cpp b/avogadro/molequeue/molequeuewidget.cpp index dd3bae11be..1c47c1315a 100644 --- a/avogadro/molequeue/molequeuewidget.cpp +++ b/avogadro/molequeue/molequeuewidget.cpp @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "molequeuewidget.h" diff --git a/avogadro/molequeue/molequeuewidget.h b/avogadro/molequeue/molequeuewidget.h index 4878a7eb26..35b7c8d0dc 100644 --- a/avogadro/molequeue/molequeuewidget.h +++ b/avogadro/molequeue/molequeuewidget.h @@ -1,17 +1,6 @@ /****************************************************************************** - This source file is part of the Avogadro project. - - Copyright 2013 Kitware, Inc. - - This source code is released under the New BSD License, (the "License"). - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #ifndef AVOGADRO_MOLEQUEUE_MOLEQUEUEWIDGET_H From 24454490d97f64d891f1f2a98d6afb6c1d21dc19 Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Fri, 28 May 2021 14:51:59 -0400 Subject: [PATCH 4/4] Remove the top-level USE_MOLEQUEUE The client is built in, and so removing conditional builds. Some porting of the code to use the renamed namespace/include location. Signed-off-by: Marcus D. Hanwell --- CMakeLists.txt | 1 - avogadro/qtplugins/CMakeLists.txt | 12 +++++------- avogadro/qtplugins/apbs/CMakeLists.txt | 6 +----- avogadro/qtplugins/cp2kinput/CMakeLists.txt | 3 --- avogadro/qtplugins/cp2kinput/cp2kinput.cpp | 8 ++++---- avogadro/qtplugins/cp2kinput/cp2kinput.h | 9 ++++----- avogadro/qtplugins/cp2kinput/cp2kinputdialog.cpp | 4 ++-- avogadro/qtplugins/cp2kinput/cp2kinputdialog.h | 5 ++--- avogadro/qtplugins/gamessinput/CMakeLists.txt | 3 --- avogadro/qtplugins/gamessinput/gamessinput.cpp | 8 ++++---- avogadro/qtplugins/gamessinput/gamessinput.h | 7 +++---- avogadro/qtplugins/gamessinput/gamessinputdialog.cpp | 4 ++-- avogadro/qtplugins/gamessinput/gamessinputdialog.h | 5 ++--- avogadro/qtplugins/quantuminput/CMakeLists.txt | 4 ---- avogadro/qtplugins/quantuminput/quantuminput.cpp | 8 ++++---- avogadro/qtplugins/quantuminput/quantuminput.h | 7 ++----- setup.py | 1 - 17 files changed, 35 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e481c1ea74..dde25db79f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,6 @@ option(USE_LIBMSYM "Enable optional features using libmsym" ON) option(USE_SPGLIB "Enable optional features using spglib" ON) option(USE_MMTF "Enable optional features using mmtf" ON) option(USE_PROTOCALL "Enable libraries that use ProtoCall" OFF) -option(USE_MOLEQUEUE "Enable the MoleQueue dependent functionality" ON) option(USE_PYTHON "Use Python to wrap some of our API" OFF) add_subdirectory(utilities) diff --git a/avogadro/qtplugins/CMakeLists.txt b/avogadro/qtplugins/CMakeLists.txt index 9944946b59..d4c79603b7 100644 --- a/avogadro/qtplugins/CMakeLists.txt +++ b/avogadro/qtplugins/CMakeLists.txt @@ -136,13 +136,11 @@ if(USE_VTK) add_subdirectory(coloropacitymap) endif() -if(USE_MOLEQUEUE) - add_subdirectory(apbs) - add_subdirectory(cp2kinput) - add_subdirectory(gamessinput) - add_subdirectory(quantuminput) - add_subdirectory(scriptfileformats) -endif() +add_subdirectory(apbs) +add_subdirectory(cp2kinput) +add_subdirectory(gamessinput) +add_subdirectory(quantuminput) +add_subdirectory(scriptfileformats) if(USE_LIBARCHIVE) add_subdirectory(plugindownloader) diff --git a/avogadro/qtplugins/apbs/CMakeLists.txt b/avogadro/qtplugins/apbs/CMakeLists.txt index e6aad6bad0..a8ce902b4e 100644 --- a/avogadro/qtplugins/apbs/CMakeLists.txt +++ b/avogadro/qtplugins/apbs/CMakeLists.txt @@ -1,7 +1,3 @@ -# Pull in MoleQueue (needed for QtJson) -find_package(MoleQueue REQUIRED NO_MODULE) -include_directories(${MoleQueue_INCLUDE_DIRS}) - set(apbs_srcs apbs.cpp apbsdialog.cpp @@ -24,4 +20,4 @@ avogadro_plugin(apbs ) target_link_libraries(apbs - LINK_PRIVATE AvogadroIO AvogadroMoleQueue MoleQueueClient) + LINK_PRIVATE AvogadroIO AvogadroMoleQueue) diff --git a/avogadro/qtplugins/cp2kinput/CMakeLists.txt b/avogadro/qtplugins/cp2kinput/CMakeLists.txt index a39aabf7b5..ef43193cb1 100644 --- a/avogadro/qtplugins/cp2kinput/CMakeLists.txt +++ b/avogadro/qtplugins/cp2kinput/CMakeLists.txt @@ -1,6 +1,3 @@ -find_package(MoleQueue) -include_directories(${MoleQueue_INCLUDE_DIRS}) - # Extension set(cp2kinput_srcs cp2kinputdialog.cpp diff --git a/avogadro/qtplugins/cp2kinput/cp2kinput.cpp b/avogadro/qtplugins/cp2kinput/cp2kinput.cpp index a127646c16..0f5544d3a6 100644 --- a/avogadro/qtplugins/cp2kinput/cp2kinput.cpp +++ b/avogadro/qtplugins/cp2kinput/cp2kinput.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -34,7 +34,7 @@ class Molecule; } namespace QtPlugins { -using ::MoleQueue::JobObject; +using Avogadro::MoleQueue::JobObject; Cp2kInput::Cp2kInput(QObject* parent_) : ExtensionPlugin(parent_), m_action(new QAction(this)), m_molecule(NULL), @@ -109,8 +109,8 @@ void Cp2kInput::menuActivated() { if (!m_dialog) { m_dialog = new Cp2kInputDialog(qobject_cast(parent())); - connect(m_dialog, SIGNAL(openJobOutput(MoleQueue::JobObject)), this, - SLOT(openJobOutput(MoleQueue::JobObject))); + connect(m_dialog, SIGNAL(openJobOutput(Avogadro::MoleQueue::JobObject)), this, + SLOT(openJobOutput(Avogadro::MoleQueue::JobObject))); } m_dialog->setMolecule(m_molecule); m_dialog->show(); diff --git a/avogadro/qtplugins/cp2kinput/cp2kinput.h b/avogadro/qtplugins/cp2kinput/cp2kinput.h index 007179d511..79f70e4771 100644 --- a/avogadro/qtplugins/cp2kinput/cp2kinput.h +++ b/avogadro/qtplugins/cp2kinput/cp2kinput.h @@ -22,14 +22,13 @@ class QAction; class QDialog; -namespace MoleQueue { -class JobObject; -} - namespace Avogadro { namespace Io { class FileFormat; } +namespace MoleQueue { +class JobObject; +} namespace QtPlugins { @@ -57,7 +56,7 @@ public slots: /** * Emitted when the user requests that a job's output be loaded in Avogadro. */ - void openJobOutput(const MoleQueue::JobObject& job); + void openJobOutput(const Avogadro::MoleQueue::JobObject& job); bool readMolecule(QtGui::Molecule& mol); diff --git a/avogadro/qtplugins/cp2kinput/cp2kinputdialog.cpp b/avogadro/qtplugins/cp2kinput/cp2kinputdialog.cpp index 1d7d4e6166..004bee1d90 100644 --- a/avogadro/qtplugins/cp2kinput/cp2kinputdialog.cpp +++ b/avogadro/qtplugins/cp2kinput/cp2kinputdialog.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -44,7 +44,7 @@ using Avogadro::MoleQueue::MoleQueueDialog; using Avogadro::MoleQueue::MoleQueueManager; -using MoleQueue::JobObject; +using Avogadro::MoleQueue::JobObject; namespace Avogadro { namespace QtPlugins { diff --git a/avogadro/qtplugins/cp2kinput/cp2kinputdialog.h b/avogadro/qtplugins/cp2kinput/cp2kinputdialog.h index f20f429edc..5ca0064c34 100644 --- a/avogadro/qtplugins/cp2kinput/cp2kinputdialog.h +++ b/avogadro/qtplugins/cp2kinput/cp2kinputdialog.h @@ -27,11 +27,10 @@ class QJsonObject; +namespace Avogadro { namespace MoleQueue { class JobObject; } - -namespace Avogadro { namespace QtGui { class Molecule; } @@ -53,7 +52,7 @@ class Cp2kInputDialog : public QDialog /** * Emitted when the user requests that a job's output be loaded in Avogadro. */ - void openJobOutput(const MoleQueue::JobObject& job); + void openJobOutput(const Avogadro::MoleQueue::JobObject& job); protected: void showEvent(QShowEvent* e); diff --git a/avogadro/qtplugins/gamessinput/CMakeLists.txt b/avogadro/qtplugins/gamessinput/CMakeLists.txt index 23697aad1d..99a401675d 100644 --- a/avogadro/qtplugins/gamessinput/CMakeLists.txt +++ b/avogadro/qtplugins/gamessinput/CMakeLists.txt @@ -1,6 +1,3 @@ -find_package(MoleQueue) -include_directories(${MoleQueue_INCLUDE_DIRS}) - # Extension set(gamessinput_srcs gamessinputdialog.cpp diff --git a/avogadro/qtplugins/gamessinput/gamessinput.cpp b/avogadro/qtplugins/gamessinput/gamessinput.cpp index 9b11241c1a..ccc83923fb 100644 --- a/avogadro/qtplugins/gamessinput/gamessinput.cpp +++ b/avogadro/qtplugins/gamessinput/gamessinput.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include @@ -35,7 +35,7 @@ class Molecule; } namespace QtPlugins { -using ::MoleQueue::JobObject; +using MoleQueue::JobObject; GamessInput::GamessInput(QObject* parent_) : ExtensionPlugin(parent_), m_action(new QAction(this)), m_molecule(nullptr), @@ -112,8 +112,8 @@ void GamessInput::menuActivated() { if (!m_dialog) { m_dialog = new GamessInputDialog(qobject_cast(parent())); - connect(m_dialog, SIGNAL(openJobOutput(MoleQueue::JobObject)), this, - SLOT(openJobOutput(MoleQueue::JobObject))); + connect(m_dialog, SIGNAL(openJobOutput(Avogadro::MoleQueue::JobObject)), this, + SLOT(openJobOutput(Avogadro::MoleQueue::JobObject))); } m_dialog->setMolecule(m_molecule); m_dialog->show(); diff --git a/avogadro/qtplugins/gamessinput/gamessinput.h b/avogadro/qtplugins/gamessinput/gamessinput.h index 8acacc1e8a..6cf4951218 100644 --- a/avogadro/qtplugins/gamessinput/gamessinput.h +++ b/avogadro/qtplugins/gamessinput/gamessinput.h @@ -22,14 +22,13 @@ class QAction; class QDialog; -namespace MoleQueue { -class JobObject; -} - namespace Avogadro { namespace Io { class FileFormat; } +namespace MoleQueue { +class JobObject; +} namespace QtPlugins { diff --git a/avogadro/qtplugins/gamessinput/gamessinputdialog.cpp b/avogadro/qtplugins/gamessinput/gamessinputdialog.cpp index a28d1a6760..280287f0d8 100644 --- a/avogadro/qtplugins/gamessinput/gamessinputdialog.cpp +++ b/avogadro/qtplugins/gamessinput/gamessinputdialog.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ using Avogadro::MoleQueue::MoleQueueDialog; using Avogadro::MoleQueue::MoleQueueManager; -using MoleQueue::JobObject; +using Avogadro::MoleQueue::JobObject; namespace Avogadro { namespace QtPlugins { diff --git a/avogadro/qtplugins/gamessinput/gamessinputdialog.h b/avogadro/qtplugins/gamessinput/gamessinputdialog.h index 8ac3735777..7d7d92f3d0 100644 --- a/avogadro/qtplugins/gamessinput/gamessinputdialog.h +++ b/avogadro/qtplugins/gamessinput/gamessinputdialog.h @@ -27,11 +27,10 @@ class QJsonObject; +namespace Avogadro { namespace MoleQueue { class JobObject; } - -namespace Avogadro { namespace QtGui { class Molecule; } @@ -53,7 +52,7 @@ class GamessInputDialog : public QDialog /** * Emitted when the user requests that a job's output be loaded in Avogadro. */ - void openJobOutput(const MoleQueue::JobObject& job); + void openJobOutput(const Avogadro::MoleQueue::JobObject& job); protected: void showEvent(QShowEvent* e) override; diff --git a/avogadro/qtplugins/quantuminput/CMakeLists.txt b/avogadro/qtplugins/quantuminput/CMakeLists.txt index fb21cc1c62..fce867ce89 100644 --- a/avogadro/qtplugins/quantuminput/CMakeLists.txt +++ b/avogadro/qtplugins/quantuminput/CMakeLists.txt @@ -1,7 +1,3 @@ -# Pull in MoleQueue -find_package(MoleQueue REQUIRED NO_MODULE) -include_directories(${MoleQueue_INCLUDE_DIRS}) - # Needed to find avogadroioexport.h: include_directories("${AvogadroLibs_BINARY_DIR}/avogadro/io/") diff --git a/avogadro/qtplugins/quantuminput/quantuminput.cpp b/avogadro/qtplugins/quantuminput/quantuminput.cpp index d3273a3f0e..ef77a5c1fd 100644 --- a/avogadro/qtplugins/quantuminput/quantuminput.cpp +++ b/avogadro/qtplugins/quantuminput/quantuminput.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -48,7 +48,7 @@ namespace QtPlugins { using MoleQueue::InputGenerator; using MoleQueue::InputGeneratorDialog; -using ::MoleQueue::JobObject; +using MoleQueue::JobObject; const int ConfigureAction = -1; // to find the configuration action @@ -151,8 +151,8 @@ void QuantumInput::menuActivated() if (!dlg) { dlg = new InputGeneratorDialog(scriptFileName, theParent); connect(&dlg->widget(), - SIGNAL(openJobOutput(const ::MoleQueue::JobObject&)), this, - SLOT(openJobOutput(const ::MoleQueue::JobObject&))); + SIGNAL(openJobOutput(const MoleQueue::JobObject&)), this, + SLOT(openJobOutput(const MoleQueue::JobObject&))); m_dialogs.insert(scriptFileName, dlg); } dlg->setMolecule(m_molecule); diff --git a/avogadro/qtplugins/quantuminput/quantuminput.h b/avogadro/qtplugins/quantuminput/quantuminput.h index d082ce3ea1..03f2f9a2a3 100644 --- a/avogadro/qtplugins/quantuminput/quantuminput.h +++ b/avogadro/qtplugins/quantuminput/quantuminput.h @@ -25,10 +25,6 @@ class QAction; class QDialog; -namespace MoleQueue { -class JobObject; -} - namespace Avogadro { namespace Io { class FileFormat; @@ -36,6 +32,7 @@ class FileFormat; namespace MoleQueue { class InputGeneratorDialog; +class JobObject; } namespace QtPlugins { @@ -75,7 +72,7 @@ public slots: /** * Emitted when the user requests that a job's output be loaded in Avogadro. */ - void openJobOutput(const ::MoleQueue::JobObject& job); + void openJobOutput(const MoleQueue::JobObject& job); bool readMolecule(QtGui::Molecule& mol) override; diff --git a/setup.py b/setup.py index ada8c7a4a0..807019f935 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,6 @@ def wheel_args(): '-DUSE_QT:BOOL=FALSE', '-DUSE_MMTF:BOOL=FALSE', '-DUSE_PYTHON:BOOL=TRUE', - '-DUSE_MOLEQUEUE:BOOL=FALSE', '-DUSE_HDF5:BOOL=FALSE', '-DUSE_LIBARCHIVE:BOOL=FALSE', '-DUSE_LIBMSYM:BOOL=FALSE',