-
Notifications
You must be signed in to change notification settings - Fork 121
/
CatalogLogout.cpp
43 lines (36 loc) · 1.31 KB
/
CatalogLogout.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "MantidICat/CatalogLogout.h"
#include "MantidAPI/CatalogManager.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/AlgorithmProperty.h"
namespace Mantid {
namespace ICat {
DECLARE_ALGORITHM(CatalogLogout)
/// Init method to declare algorithm properties
void CatalogLogout::init() {
declareProperty("Session", std::string(""),
"The session information of the catalog to log out. If none "
"provided then all catalogs are logged out.",
Kernel::Direction::Input);
}
/// execute the algorithm
void CatalogLogout::exec() {
std::string logoutSession = getPropertyValue("Session");
// Destroy all sessions if no session provided.
if (logoutSession.empty())
API::CatalogManager::Instance().destroyCatalog("");
auto keepAliveInstances =
API::AlgorithmManager::Instance().runningInstancesOf("CatalogKeepAlive");
for (auto &instance : keepAliveInstances) {
auto keepAliveInstance = API::AlgorithmManager::Instance().getAlgorithm(
instance->getAlgorithmID());
if (logoutSession == instance->getPropertyValue("Session")) {
keepAliveInstance->cancel();
API::CatalogManager::Instance().destroyCatalog(logoutSession);
break;
} else if (logoutSession.empty()) {
keepAliveInstance->cancel();
}
}
}
}
}