Mantid
Loading...
Searching...
No Matches
AnalysisDataServiceObserver.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2019 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 +
7#pragma once
8
10#include "MantidAPI/DllConfig.h"
12#include <Poco/NObserver.h>
13
14using namespace Mantid::Kernel;
15using namespace Mantid::API;
16
17namespace Mantid {
18namespace API {
19
20/*
21 * To use the AnalysisDataServiceObserver you will need to do a few things:
22 *
23 * 1. Inherit from this class in the class you wish to take effect on
24 *
25 * 2. Make sure that the effect you are attempting to observe has been added
26 * to the AnalysisDataService itself by using the public method in this
27 * class, e.g. observeAll, observeAdd, observeReplace etc.
28 *
29 * 3. The last thing to actually have something take effect is by overriding
30 * the relevant handle function e.g. when observing all override
31 * anyChangeHandle and anything done in that overriden method will happen
32 * every time something changes in the AnalysisDataService.
33 *
34 * This works in both C++ and Python, some functionality is limited in
35 * python, but the handlers will all be called.
36 */
37
38class MANTID_API_DLL AnalysisDataServiceObserver {
39public:
42
43 // delete copy operations - Poco::NObserver contains std::atomic which is not copyable
46
47 void observeAll(bool turnOn = true);
48 void observeAdd(bool turnOn = true);
49 void observeReplace(bool turnOn = true);
50 void observeDelete(bool turnOn = true);
51 void observeClear(bool turnOn = true);
52 void observeRename(bool turnOn = true);
53 void observeGroup(bool turnOn = true);
54 void observeUnGroup(bool turnOn = true);
55 void observeGroupUpdate(bool turnOn = true);
56
57 virtual void anyChangeHandle();
58 virtual void addHandle(const std::string &wsName, const Workspace_sptr &ws);
59 virtual void replaceHandle(const std::string &wsName, const Workspace_sptr &ws);
60 virtual void deleteHandle(const std::string &wsName, const Workspace_sptr &ws);
61 virtual void clearHandle();
62 virtual void renameHandle(const std::string &wsName, const std::string &newName);
63 virtual void groupHandle(const std::string &wsName, const Workspace_sptr &ws);
64 virtual void unGroupHandle(const std::string &wsName, const Workspace_sptr &ws);
65 virtual void groupUpdateHandle(const std::string &wsName, const Workspace_sptr &ws);
66
67private:
68 bool m_observingAdd{false}, m_observingReplace{false}, m_observingDelete{false}, m_observingClear{false},
69 m_observingRename{false}, m_observingGroup{false}, m_observingUnGroup{false}, m_observingGroupUpdate{false};
70
71 void _addHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::AddNotification> &pNf);
72 void _replaceHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::AfterReplaceNotification> &pNf);
73 void _deleteHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::PreDeleteNotification> &pNf);
74 void _clearHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::ClearNotification> &pNf);
75 void _renameHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::RenameNotification> &pNf);
76 void _groupHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::GroupWorkspacesNotification> &pNf);
77 void _unGroupHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::UnGroupingWorkspaceNotification> &pNf);
78 void _groupUpdateHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::GroupUpdatedNotification> &pNf);
79
82
85
88
91
94
97
101
105};
106
107} // namespace API
108} // namespace Mantid
Poco::NObserver< AnalysisDataServiceObserver, AnalysisDataServiceImpl::AddNotification > m_addObserver
Poco::NObserver for AddNotification.
Poco::NObserver< AnalysisDataServiceObserver, AnalysisDataServiceImpl::ClearNotification > m_clearObserver
Poco::NObserver for ClearNotification.
Poco::NObserver< AnalysisDataServiceObserver, AnalysisDataServiceImpl::PreDeleteNotification > m_deleteObserver
Poco::NObserver for DeleteNotification.
AnalysisDataServiceObserver & operator=(const AnalysisDataServiceObserver &)=delete
AnalysisDataServiceObserver(const AnalysisDataServiceObserver &)=delete
Poco::NObserver< AnalysisDataServiceObserver, AnalysisDataServiceImpl::RenameNotification > m_renameObserver
Poco::NObserver for RenameNotification.
Poco::NObserver< AnalysisDataServiceObserver, AnalysisDataServiceImpl::GroupUpdatedNotification > m_groupUpdatedObserver
Poco::NObserver for GroupUpdateNotification.
Poco::NObserver< AnalysisDataServiceObserver, AnalysisDataServiceImpl::UnGroupingWorkspaceNotification > m_unGroupObserver
Poco::NObserver for UnGroupNotification.
Poco::NObserver< AnalysisDataServiceObserver, AnalysisDataServiceImpl::GroupWorkspacesNotification > m_groupObserver
Poco::NObserver for GroupNotification.
Poco::NObserver< AnalysisDataServiceObserver, AnalysisDataServiceImpl::AfterReplaceNotification > m_replaceObserver
Poco::NObserver for ReplaceNotification.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Helper class which provides the Collimation Length for SANS instruments.