Mantid
Loading...
Searching...
No Matches
AnalysisDataService.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/DllConfig.h"
13#include "MantidAPI/Workspace.h"
16
17#include <Poco/AutoPtr.h>
18
19namespace Mantid {
20
21namespace API {
22
23//----------------------------------------------------------------------
24// Forward declaration
25//----------------------------------------------------------------------
26
27class WorkspaceGroup;
28
43class MANTID_API_DLL AnalysisDataServiceImpl final : public Kernel::DataService<API::Workspace> {
44public:
48 class GroupWorkspacesNotification : public DataServiceNotification {
49 public:
51 GroupWorkspacesNotification(const std::vector<std::string> &wsnames)
52 : DataServiceNotification("", std::shared_ptr<API::Workspace>()), m_wsnames(wsnames) {}
54 const std::vector<std::string> &inputworkspacenames() const { return m_wsnames; }
55
56 private:
57 std::vector<std::string> m_wsnames;
58 };
59
62 class UnGroupingWorkspaceNotification : public DataServiceNotification {
63 public:
65 UnGroupingWorkspaceNotification(const std::string &name, const std::shared_ptr<Workspace> &obj)
66 : DataServiceNotification(name, obj) {}
67 };
68
74 class GroupUpdatedNotification : public DataServiceNotification {
75 public:
77 GroupUpdatedNotification(const std::string &name);
79 std::shared_ptr<const WorkspaceGroup> getWorkspaceGroup() const;
80 };
81
83
84public:
86 const std::string &illegalCharacters() const;
88 void setIllegalCharacterList(const std::string &);
90 const std::string isValid(const std::string &name) const;
93 void add(const std::string &name, const std::shared_ptr<API::Workspace> &workspace) override;
96 void addOrReplace(const std::string &name, const std::shared_ptr<API::Workspace> &workspace) override;
99 virtual void rename(const std::string &oldName, const std::string &newName);
101 virtual void remove(const std::string &name);
102
110 template <typename WSTYPE> std::shared_ptr<WSTYPE> retrieveWS(const std::string &name) const {
111 // Get as a bare workspace
112 try {
113 // Cast to the desired type and return that.
114 return std::dynamic_pointer_cast<WSTYPE>(Kernel::DataService<API::Workspace>::retrieve(name));
115
117 throw;
118 }
119 }
120
121 std::vector<Workspace_sptr> retrieveWorkspaces(const std::vector<std::string> &names,
122 bool unrollGroups = false) const;
123
126 void sortGroupByName(const std::string &groupName);
127 void addToGroup(const std::string &groupName, const std::string &wsName);
128 void deepRemoveGroup(const std::string &name);
129 void removeFromGroup(const std::string &groupName, const std::string &wsName);
131
133 std::map<std::string, Workspace_sptr> topLevelItems() const;
134 void shutdown() override;
135
136private:
138 void verifyName(const std::string &name, const std::shared_ptr<API::WorkspaceGroup> &workspace);
139
148 ~AnalysisDataServiceImpl() override = default;
149
151 std::string m_illegalChars;
152};
153
155
158 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::AddNotification> &;
159
163 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::BeforeReplaceNotification> &;
164
167 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::AfterReplaceNotification> &;
168
171 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::PreDeleteNotification> &;
172
175 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::PostDeleteNotification> &;
176
179 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::ClearNotification> &;
180
183 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::RenameNotification> &;
184
186using WorkspacesGroupedNotification_ptr = const Poco::AutoPtr<AnalysisDataServiceImpl::GroupWorkspacesNotification> &;
187
190 const Poco::AutoPtr<AnalysisDataServiceImpl::UnGroupingWorkspaceNotification> &;
191
193using GroupUpdatedNotification_ptr = const Poco::AutoPtr<AnalysisDataServiceImpl::GroupUpdatedNotification> &;
194
195} // Namespace API
196} // Namespace Mantid
197
198namespace Mantid {
199namespace Kernel {
200EXTERN_MANTID_API template class MANTID_API_DLL Mantid::Kernel::SingletonHolder<Mantid::API::AnalysisDataServiceImpl>;
201}
202} // namespace Mantid
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
double obj
the value of the quadratic function
GroupWorkspaces notification is send when a group is updated by adding or removing members.
GroupWorkspaces notification is send from GroupWorkspaces algorithm.
GroupWorkspacesNotification(const std::vector< std::string > &wsnames)
Constructor.
const std::vector< std::string > & inputworkspacenames() const
returns the workspace names
UnGroupingWorkspace notification is sent from UnGroupWorkspace algorithm before the WorkspaceGroup is...
UnGroupingWorkspaceNotification(const std::string &name, const std::shared_ptr< Workspace > &obj)
Constructor.
The Analysis data service stores instances of the Workspace objects and anything that derives from te...
AnalysisDataServiceImpl(const AnalysisDataServiceImpl &)=delete
Private, unimplemented copy constructor.
std::string m_illegalChars
The string of illegal characters.
AnalysisDataServiceImpl & operator=(const AnalysisDataServiceImpl &)=delete
Private, unimplemented copy assignment operator.
std::shared_ptr< WSTYPE > retrieveWS(const std::string &name) const
Retrieve a workspace and cast it to the given WSTYPE.
~AnalysisDataServiceImpl() override=default
Private destructor.
Base Workspace Abstract Class.
Definition: Workspace.h:30
AddNotification is sent after an new object is added to the data service.
Definition: DataService.h:97
AfterReplaceNotification is sent after an object is replaced in the addOrReplace() function.
Definition: DataService.h:128
BeforeReplaceNotification is sent before an object is replaced in the addOrReplace() function.
Definition: DataService.h:105
Clear notification is sent when the service is cleared.
Definition: DataService.h:163
PostDeleteNotification is sent after an object is deleted from the data service.
Definition: DataService.h:156
PreDeleteNotification is sent before an object is deleted from the data service.
Definition: DataService.h:144
Rename notification is sent when the rename method is called.
Definition: DataService.h:169
DataService stores instances of a given type.
Definition: DataService.h:58
Exception for when an item is not found in a collection.
Definition: Exception.h:145
Manage the lifetime of a class intended to be a singleton.
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::AfterReplaceNotification > & WorkspaceAfterReplaceNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::ClearNotification > & ClearADSNotification_ptr
const Poco::AutoPtr< AnalysisDataServiceImpl::GroupUpdatedNotification > & GroupUpdatedNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::PreDeleteNotification > & WorkspacePreDeleteNotification_ptr
const Poco::AutoPtr< AnalysisDataServiceImpl::GroupWorkspacesNotification > & WorkspacesGroupedNotification_ptr
const Poco::AutoPtr< AnalysisDataServiceImpl::UnGroupingWorkspaceNotification > & WorkspaceUnGroupingNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::RenameNotification > & WorkspaceRenameNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::AddNotification > & WorkspaceAddNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::BeforeReplaceNotification > & WorkspaceBeforeReplaceNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::PostDeleteNotification > & WorkspacePostDeleteNotification_ptr
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.
Policy class controlling creation of the singleton Implementation classes should mark their default c...