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 Workspace_sptr remove(const std::string &name);
103 const std::string uniqueName(const int n = 5, const std::string &prefix = "", const std::string &suffix = "");
105 const std::string uniqueHiddenName();
106
114 template <typename WSTYPE> std::shared_ptr<WSTYPE> retrieveWS(const std::string &name) const {
115 // Get as a bare workspace
116 try {
117 // Cast to the desired type and return that.
118 return std::dynamic_pointer_cast<WSTYPE>(Kernel::DataService<API::Workspace>::retrieve(name));
119
121 throw;
122 }
123 }
124
125 std::vector<Workspace_sptr> retrieveWorkspaces(const std::vector<std::string> &names,
126 bool unrollGroups = false) const;
127
130 void sortGroupByName(const std::string &groupName);
131 void addToGroup(const std::string &groupName, const std::string &wsName);
132 void deepRemoveGroup(const std::string &name);
133 void removeFromGroup(const std::string &groupName, const std::string &wsName);
135
137 std::map<std::string, Workspace_sptr> topLevelItems() const;
138
139private:
141 void verifyName(const std::string &name, const std::shared_ptr<API::WorkspaceGroup> &workspace);
142 static char getRandomLowercaseLetter();
143
152 ~AnalysisDataServiceImpl() override = default;
153
155 std::string m_illegalChars;
156};
157
159
162 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::AddNotification> &;
163
167 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::BeforeReplaceNotification> &;
168
171 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::AfterReplaceNotification> &;
172
175 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::PreDeleteNotification> &;
176
179 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::PostDeleteNotification> &;
180
183 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::ClearNotification> &;
184
187 const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::RenameNotification> &;
188
190using WorkspacesGroupedNotification_ptr = const Poco::AutoPtr<AnalysisDataServiceImpl::GroupWorkspacesNotification> &;
191
194 const Poco::AutoPtr<AnalysisDataServiceImpl::UnGroupingWorkspaceNotification> &;
195
197using GroupUpdatedNotification_ptr = const Poco::AutoPtr<AnalysisDataServiceImpl::GroupUpdatedNotification> &;
198
199} // Namespace API
200} // Namespace Mantid
201
202namespace Mantid {
203namespace Kernel {
204EXTERN_MANTID_API template class MANTID_API_DLL Mantid::Kernel::SingletonHolder<Mantid::API::AnalysisDataServiceImpl>;
205}
206} // namespace Mantid
std::string name
Definition Run.cpp:60
IPeaksWorkspace_sptr workspace
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:29
AddNotification is sent after an new object is added to the data service.
Definition DataService.h:96
AfterReplaceNotification is sent after an object is replaced in the addOrReplace() function.
BeforeReplaceNotification is sent before an object is replaced in the addOrReplace() function.
Clear notification is sent when the service is cleared.
PostDeleteNotification is sent after an object is deleted from the data service.
PreDeleteNotification is sent before an object is deleted from the data service.
Rename notification is sent when the rename method is called.
DataService stores instances of a given type.
Definition DataService.h:57
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
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
const Poco::AutoPtr< AnalysisDataServiceImpl::UnGroupingWorkspaceNotification > & WorkspaceUnGroupingNotification_ptr
Mantid::Kernel::SingletonHolder< AnalysisDataServiceImpl > AnalysisDataService
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...