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 void observeAll(bool turnOn = true);
44 void observeAdd(bool turnOn = true);
45 void observeReplace(bool turnOn = true);
46 void observeDelete(bool turnOn = true);
47 void observeClear(bool turnOn = true);
48 void observeRename(bool turnOn = true);
49 void observeGroup(bool turnOn = true);
50 void observeUnGroup(bool turnOn = true);
51 void observeGroupUpdate(bool turnOn = true);
52
53 virtual void anyChangeHandle();
54 virtual void addHandle(const std::string &wsName, const Workspace_sptr &ws);
55 virtual void replaceHandle(const std::string &wsName, const Workspace_sptr &ws);
56 virtual void deleteHandle(const std::string &wsName, const Workspace_sptr &ws);
57 virtual void clearHandle();
58 virtual void renameHandle(const std::string &wsName, const std::string &newName);
59 virtual void groupHandle(const std::string &wsName, const Workspace_sptr &ws);
60 virtual void unGroupHandle(const std::string &wsName, const Workspace_sptr &ws);
61 virtual void groupUpdateHandle(const std::string &wsName, const Workspace_sptr &ws);
62
63private:
64 bool m_observingAdd{false}, m_observingReplace{false}, m_observingDelete{false}, m_observingClear{false},
65 m_observingRename{false}, m_observingGroup{false}, m_observingUnGroup{false}, m_observingGroupUpdate{false};
66
67 void _addHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::AddNotification> &pNf);
68 void _replaceHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::AfterReplaceNotification> &pNf);
69 void _deleteHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::PreDeleteNotification> &pNf);
70 void _clearHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::ClearNotification> &pNf);
71 void _renameHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::RenameNotification> &pNf);
72 void _groupHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::GroupWorkspacesNotification> &pNf);
73 void _unGroupHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::UnGroupingWorkspaceNotification> &pNf);
74 void _groupUpdateHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::GroupUpdatedNotification> &pNf);
75
78
81
84
87
90
93
97
101};
102
103} // namespace API
104} // 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.
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
Definition: Workspace_fwd.h:20
Helper class which provides the Collimation Length for SANS instruments.