Mantid
Loading...
Searching...
No Matches
CatalogLogout.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
11
12namespace Mantid::ICat {
13DECLARE_ALGORITHM(CatalogLogout)
14
15
16void CatalogLogout::init() {
17 declareProperty("Session", std::string(""),
18 "The session information of the catalog to log out. If none "
19 "provided then all catalogs are logged out.",
21}
22
25 std::string logoutSession = getPropertyValue("Session");
26
27 // Destroy all sessions if no session provided.
28 if (logoutSession.empty())
29 API::CatalogManager::Instance().destroyCatalog("");
30
31 auto keepAliveInstances = API::AlgorithmManager::Instance().runningInstancesOf("CatalogKeepAlive");
32
33 for (auto &instance : keepAliveInstances) {
34 auto keepAliveInstance = API::AlgorithmManager::Instance().getAlgorithm(instance->getAlgorithmID());
35
36 if (logoutSession == instance->getPropertyValue("Session")) {
37 keepAliveInstance->cancel();
38 API::CatalogManager::Instance().destroyCatalog(logoutSession);
39 break;
40 } else if (logoutSession.empty()) {
41 keepAliveInstance->cancel();
42 }
43 }
44}
45} // namespace Mantid::ICat
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
Definition: Algorithm.cpp:2026
CatalogLogout is responsible for logging out of a catalog based on session information provided by th...
Definition: CatalogLogout.h:24
void exec() override
execute the algorithm
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
@ Input
An input workspace.
Definition: Property.h:53