Mantid
|
The Analysis data service stores instances of the Workspace objects and anything that derives from template class DynamicFactory<Mantid::Kernel::IAlgorithm>. More...
#include <AnalysisDataService.h>
Classes | |
class | GroupUpdatedNotification |
GroupWorkspaces notification is send when a group is updated by adding or removing members. More... | |
class | GroupWorkspacesNotification |
GroupWorkspaces notification is send from GroupWorkspaces algorithm. More... | |
class | UnGroupingWorkspaceNotification |
UnGroupingWorkspace notification is sent from UnGroupWorkspace algorithm before the WorkspaceGroup is removed from the DataService. More... | |
Public Member Functions | |
Extra notifications only applicable to the ADS | |
const std::string & | illegalCharacters () const |
Return the list of illegal characters as one string. More... | |
void | setIllegalCharacterList (const std::string &) |
Set the list of illegal characters. More... | |
const std::string | isValid (const std::string &name) const |
Is the given name a valid name for an object in the ADS. More... | |
void | add (const std::string &name, const std::shared_ptr< API::Workspace > &workspace) override |
Overridden add member to attach the name to the workspace when a workspace object is added to the service. More... | |
void | addOrReplace (const std::string &name, const std::shared_ptr< API::Workspace > &workspace) override |
Overridden addOrReplace member to attach the name to the workspace when a workspace object is added to the service. More... | |
virtual void | rename (const std::string &oldName, const std::string &newName) |
Overridden rename member to attach the new name to the workspace when a workspace object is renamed. More... | |
virtual void | remove (const std::string &name) |
Overridden remove member to delete its name held by the workspace itself. More... | |
template<typename WSTYPE > | |
std::shared_ptr< WSTYPE > | retrieveWS (const std::string &name) const |
Retrieve a workspace and cast it to the given WSTYPE. More... | |
std::vector< Workspace_sptr > | retrieveWorkspaces (const std::vector< std::string > &names, bool unrollGroups=false) const |
Given a list of names retrieve the corresponding workspace handles. More... | |
Public Member Functions inherited from Mantid::Kernel::DataService< API::Workspace > | |
virtual void | add (const std::string &name, const std::shared_ptr< API::Workspace > &Tobject) |
Add an object to the service. More... | |
virtual void | addOrReplace (const std::string &name, const std::shared_ptr< API::Workspace > &Tobject) |
Add or replace an object to the service. More... | |
void | clear () |
Empty the service. More... | |
DataService (const DataService &)=delete | |
Deleted copy constructor. More... | |
bool | doAllWsExist (const std::vector< std::string > &listOfNames) |
Checks all elements within the specified vector exist in the ADS. More... | |
bool | doesExist (const std::string &name) const |
Check to see if a data object exists in the store. More... | |
std::vector< std::string > | getObjectNames (DataServiceSort sortState=DataServiceSort::Unsorted, DataServiceHidden hiddenState=DataServiceHidden::Auto, const std::string &contain="") const |
Returns a vector of strings containing all object names in the ADS. More... | |
std::vector< std::shared_ptr< API::Workspace > > | getObjects (DataServiceHidden includeHidden=DataServiceHidden::Auto) const |
Get a vector of the pointers to the data objects stored by the service. More... | |
DataService & | operator= (const DataService &)=delete |
Deleted copy assignment operator. More... | |
void | remove (const std::string &name) |
Remove an object from the service. More... | |
void | rename (const std::string &oldName, const std::string &newName) |
Rename an object within the service. More... | |
std::shared_ptr< API::Workspace > | retrieve (const std::string &name) const |
Get a shared pointer to a stored data object. More... | |
virtual void | shutdown () |
Prepare for shutdown. More... | |
size_t | size () const |
Return the number of objects stored by the data service. More... | |
Methods to work with workspace groups | |
struct | Mantid::Kernel::CreateUsingNew< AnalysisDataServiceImpl > |
std::string | m_illegalChars |
The string of illegal characters. More... | |
void | sortGroupByName (const std::string &groupName) |
Sort members by Workspace name. More... | |
void | addToGroup (const std::string &groupName, const std::string &wsName) |
Add a workspace to a group. More... | |
void | deepRemoveGroup (const std::string &name) |
Remove a workspace group and all its members from the ADS. More... | |
void | removeFromGroup (const std::string &groupName, const std::string &wsName) |
Remove a workspace from a group but not from the ADS. More... | |
std::map< std::string, Workspace_sptr > | topLevelItems () const |
Return a lookup of the top level items. More... | |
void | shutdown () override |
Prepare for shutdown. More... | |
void | verifyName (const std::string &name, const std::shared_ptr< API::WorkspaceGroup > &workspace) |
Checks the name is valid, throwing if not. More... | |
AnalysisDataServiceImpl () | |
Constructor. More... | |
AnalysisDataServiceImpl (const AnalysisDataServiceImpl &)=delete | |
Private, unimplemented copy constructor. More... | |
AnalysisDataServiceImpl & | operator= (const AnalysisDataServiceImpl &)=delete |
Private, unimplemented copy assignment operator. More... | |
~AnalysisDataServiceImpl () override=default | |
Private destructor. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Mantid::Kernel::DataService< API::Workspace > | |
static bool | isHiddenDataServiceObject (const std::string &name) |
static std::string | prefixToHide () |
static bool | showingHiddenObjects () |
Public Attributes inherited from Mantid::Kernel::DataService< API::Workspace > | |
Poco::NotificationCenter | notificationCenter |
Sends notifications to observers. More... | |
Protected Member Functions inherited from Mantid::Kernel::DataService< API::Workspace > | |
DataService (const std::string &name) | |
Protected constructor (singleton) More... | |
virtual | ~DataService ()=default |
The Analysis data service stores instances of the Workspace objects and anything that derives from template class DynamicFactory<Mantid::Kernel::IAlgorithm>.
This is the primary data service that the users will interact with either through writing scripts or directly through the API. It is implemented as a singleton class.
This is the manager/owner of Workspace* when registered.
Modified to inherit from DataService
Definition at line 43 of file AnalysisDataService.h.
|
private |
Constructor.
Definition at line 332 of file AnalysisDataService.cpp.
|
privatedelete |
Private, unimplemented copy constructor.
|
overrideprivatedefault |
Private destructor.
|
overridevirtual |
Overridden add member to attach the name to the workspace when a workspace object is added to the service.
Overwridden add member to attach the name to the workspace when a workspace object is added to the service If the name already exists then this throws a std::runtime_error.
If a workspace group is added adds the members which are not in the ADS yet.
name | The name of the object |
workspace | The shared pointer to the workspace to store |
Reimplemented from Mantid::Kernel::DataService< API::Workspace >.
Definition at line 66 of file AnalysisDataService.cpp.
References add(), Mantid::Kernel::DataService< T >::add(), Mantid::Kernel::DataService< API::Workspace >::doesExist(), std::to_string(), verifyName(), and workspace.
Referenced by add(), and Mantid::API::ScopedWorkspace::set().
|
overridevirtual |
Overridden addOrReplace member to attach the name to the workspace when a workspace object is added to the service.
Overwridden addOrReplace member to attach the name to the workspace when a workspace object is added to the service.
This will overwrite one of the same name. If the workspace is group adds or replaces its members.
name | The name of the object |
workspace | The shared pointer to the workspace to store |
Reimplemented from Mantid::Kernel::DataService< API::Workspace >.
Definition at line 104 of file AnalysisDataService.cpp.
References addOrReplace(), Mantid::Kernel::DataService< T >::addOrReplace(), Mantid::Kernel::DataService< API::Workspace >::doesExist(), std::to_string(), verifyName(), and workspace.
Referenced by addOrReplace(), Mantid::WorkflowAlgorithms::MuonGroupAsymmetryCalculator::estimateAsymmetry(), MantidQt::MantidWidgets::MuonFitPropertyBrowser::finishAfterSimultaneousFit(), and MantidQt::MantidWidgets::MuonFitPropertyBrowser::finishAfterTFSimultaneousFit().
void Mantid::API::AnalysisDataServiceImpl::addToGroup | ( | const std::string & | groupName, |
const std::string & | wsName | ||
) |
Add a workspace to a group.
The group and the workspace must be in the ADS.
groupName | :: A group name. |
wsName | :: Name of a workspace to add to the group. |
Definition at line 232 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< API::Workspace >::notificationCenter, and Mantid::Kernel::DataService< API::Workspace >::retrieve().
Referenced by export_AnalysisDataService(), MantidQt::MantidWidgets::MuonFitPropertyBrowser::finishAfterSimultaneousFit(), and MantidQt::MantidWidgets::MuonFitPropertyBrowser::finishAfterTFSimultaneousFit().
void Mantid::API::AnalysisDataServiceImpl::deepRemoveGroup | ( | const std::string & | name | ) |
Remove a workspace group and all its members from the ADS.
name | :: A group to remove. |
Definition at line 251 of file AnalysisDataService.cpp.
References deepRemoveGroup(), and remove().
Referenced by deepRemoveGroup(), and Mantid::API::ScopedWorkspace::remove().
const std::string & Mantid::API::AnalysisDataServiceImpl::illegalCharacters | ( | ) | const |
Return the list of illegal characters as one string.
Return a string containing the characters not allowed in names objects within ADS.
Definition at line 342 of file AnalysisDataService.cpp.
References m_illegalChars.
Referenced by isValid().
const std::string Mantid::API::AnalysisDataServiceImpl::isValid | ( | const std::string & | name | ) | const |
Is the given name a valid name for an object in the ADS.
name | A string containing a possible name for an object in the ADS |
Definition at line 40 of file AnalysisDataService.cpp.
References error, and illegalCharacters().
Referenced by verifyName().
|
privatedelete |
Private, unimplemented copy assignment operator.
|
virtual |
Overridden remove member to delete its name held by the workspace itself.
It is important to do if the workspace isn't deleted after removal.
name | The name of a workspace to remove. |
Definition at line 157 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< T >::remove(), and Mantid::Kernel::DataService< API::Workspace >::retrieve().
Referenced by deepRemoveGroup(), Mantid::Algorithms::DeleteWorkspace::exec(), Mantid::Algorithms::UnGroupWorkspace::exec(), and Mantid::API::ScopedWorkspace::remove().
void Mantid::API::AnalysisDataServiceImpl::removeFromGroup | ( | const std::string & | groupName, |
const std::string & | wsName | ||
) |
Remove a workspace from a group but not from the ADS.
groupName | :: Name of a workspace group. |
wsName | :: Name of a workspace to remove. |
Definition at line 276 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< API::Workspace >::notificationCenter.
Referenced by export_AnalysisDataService().
|
virtual |
Overridden rename member to attach the new name to the workspace when a workspace object is renamed.
oldName | The old name of the object |
newName | The new name of the object |
Definition at line 138 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< T >::rename(), and Mantid::Kernel::DataService< API::Workspace >::retrieve().
std::vector< Workspace_sptr > Mantid::API::AnalysisDataServiceImpl::retrieveWorkspaces | ( | const std::vector< std::string > & | names, |
bool | unrollGroups = false |
||
) | const |
Given a list of names retrieve the corresponding workspace handles.
names | A list of names of workspaces, if any does not exist then a Kernel::Exception::NotFoundError is thrown. |
unrollGroups | If true flatten groups into the list of members. |
std::invalid_argument | if no names are provided |
Mantid::Kernel::Exception::NotFoundError | if a workspace does not exist within the ADS |
Definition at line 180 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< API::Workspace >::retrieve().
|
inline |
Retrieve a workspace and cast it to the given WSTYPE.
name | :: name of the workspace |
WSTYPE | :: type of workspace to cast to. Should sub-class Workspace |
Definition at line 110 of file AnalysisDataService.h.
Referenced by Mantid::Algorithms::DeleteWorkspace::checkGroups(), MantidQt::MantidWidgets::MuonFitPropertyBrowser::finishAfterSimultaneousFit(), MantidQt::MantidWidgets::MuonFitPropertyBrowser::finishAfterTFSimultaneousFit(), Mantid::API::ScopedWorkspace::remove(), and Mantid::API::ScopedWorkspace::retrieve().
void Mantid::API::AnalysisDataServiceImpl::setIllegalCharacterList | ( | const std::string & | illegalChars | ) |
Set the list of illegal characters.
Set the list of illegal characeters.
illegalChars | A string containing the characters, as one long string, that are not to be accepted by the ADS NOTE: This only affects further additions to the ADS |
Definition at line 350 of file AnalysisDataService.cpp.
References m_illegalChars.
|
overridevirtual |
Prepare for shutdown.
Reimplemented from Mantid::Kernel::DataService< API::Workspace >.
Definition at line 323 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< API::Workspace >::clear().
void Mantid::API::AnalysisDataServiceImpl::sortGroupByName | ( | const std::string & | groupName | ) |
Sort members by Workspace name.
The group must be in the ADS.
groupName | :: A group name. |
Definition at line 218 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< API::Workspace >::notificationCenter.
std::map< std::string, Workspace_sptr > Mantid::API::AnalysisDataServiceImpl::topLevelItems | ( | ) | const |
Return a lookup of the top level items.
Produces a map of names to Workspaces that doesn't include items that are part of a WorkspaceGroup already in the list.
Definition at line 293 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< API::Workspace >::getObjectNames(), and Mantid::Kernel::DataService< API::Workspace >::retrieve().
Referenced by Mantid::Algorithms::GroupWorkspaces::addToGroup().
|
private |
Checks the name is valid, throwing if not.
Checks the name is valid.
name | A string containing the name to check. If the name is invalid a std::invalid_argument or std::runtime_error is thrown |
group | A WorkspaceGroup shared ptr which will be evaluated if it is valid then it will check it's container for the same name that is passed if true throws std::runtime_error else nothing. |
Definition at line 363 of file AnalysisDataService.cpp.
References error, and isValid().
Referenced by add(), and addOrReplace().
|
friend |
Definition at line 138 of file AnalysisDataService.h.
|
private |
The string of illegal characters.
Definition at line 151 of file AnalysisDataService.h.
Referenced by illegalCharacters(), and setIllegalCharacterList().