|
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. | |
| void | setIllegalCharacterList (const std::string &) |
| Set the list of illegal characters. | |
| const std::string | isValid (const std::string &name) const |
| Is the given name a valid name for an object in the ADS. | |
| 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. | |
| 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. | |
| 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. | |
| virtual Workspace_sptr | remove (const std::string &name) |
| Overridden remove member to delete its name held by the workspace itself. | |
| const std::string | uniqueName (const int n=5, const std::string &prefix="", const std::string &suffix="") |
| Random generated unique workspace name. | |
| const std::string | uniqueHiddenName () |
| Random generated unique hidden workspace name. | |
| template<typename WSTYPE > | |
| std::shared_ptr< WSTYPE > | retrieveWS (const std::string &name) const |
| Retrieve a workspace and cast it to the given WSTYPE. | |
| 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. | |
Public Member Functions inherited from Mantid::Kernel::DataService< API::Workspace > | |
| void | clear () |
| Empty the service. | |
| DataService (const DataService &)=delete | |
| Deleted copy constructor. | |
| bool | doAllWsExist (const std::vector< std::string > &listOfNames) |
| Checks all elements within the specified vector exist in the ADS. | |
| bool | doesExist (const std::string &name) const |
| Check to see if a data object exists in the store. | |
| 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. | |
| 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. | |
| DataService & | operator= (const DataService &)=delete |
| Deleted copy assignment operator. | |
| void | remove (const std::string &name) |
| Remove an object from the service. | |
| void | rename (const std::string &oldName, const std::string &newName) |
| Rename an object within the service. | |
| std::shared_ptr< API::Workspace > | retrieve (const std::string &name) const |
| Get a shared pointer to a stored data object. | |
| virtual void | shutdown () |
| Prepare for shutdown. | |
| size_t | size () const |
| Return the number of objects stored by the data service. | |
Methods to work with workspace groups | |
| struct | Mantid::Kernel::CreateUsingNew< AnalysisDataServiceImpl > |
| std::string | m_illegalChars |
| The string of illegal characters. | |
| void | sortGroupByName (const std::string &groupName) |
| Sort members by Workspace name. | |
| void | addToGroup (const std::string &groupName, const std::string &wsName) |
| Add a workspace to a group. | |
| void | deepRemoveGroup (const std::string &name) |
| Remove a workspace group and all its members from the ADS. | |
| void | removeFromGroup (const std::string &groupName, const std::string &wsName) |
| Remove a workspace from a group but not from the ADS. | |
| std::map< std::string, Workspace_sptr > | topLevelItems () const |
| Return a lookup of the top level items. | |
| void | verifyName (const std::string &name, const std::shared_ptr< API::WorkspaceGroup > &workspace) |
| Checks the name is valid, throwing if not. | |
| AnalysisDataServiceImpl () | |
| Constructor. | |
| AnalysisDataServiceImpl (const AnalysisDataServiceImpl &)=delete | |
| Private, unimplemented copy constructor. | |
| AnalysisDataServiceImpl & | operator= (const AnalysisDataServiceImpl &)=delete |
| Private, unimplemented copy assignment operator. | |
| ~AnalysisDataServiceImpl () override=default | |
| Private destructor. | |
| static char | getRandomLowercaseLetter () |
| random lowercase letter used for generating workspace name in unique_name and unique_hidden_name | |
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. | |
Protected Member Functions inherited from Mantid::Kernel::DataService< API::Workspace > | |
| DataService (const std::string &name) | |
| Protected constructor (singleton) | |
| 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 388 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 67 of file AnalysisDataService.cpp.
References add(), Mantid::Kernel::DataService< T >::add(), Mantid::Kernel::DataService< API::Workspace >::doesExist(), group, name, 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 105 of file AnalysisDataService.cpp.
References addOrReplace(), Mantid::Kernel::DataService< T >::addOrReplace(), Mantid::Kernel::DataService< API::Workspace >::doesExist(), group, name, 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 290 of file AnalysisDataService.cpp.
References group, 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 309 of file AnalysisDataService.cpp.
References deepRemoveGroup(), group, name, and remove().
Referenced by deepRemoveGroup(), and Mantid::API::ScopedWorkspace::remove().
|
staticprivate |
random lowercase letter used for generating workspace name in unique_name and unique_hidden_name
Definition at line 184 of file AnalysisDataService.cpp.
Referenced by uniqueName().
| 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 398 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 41 of file AnalysisDataService.cpp.
References error, illegalCharacters(), and name.
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. If member is group workspace, stop ADS observing
| name | The name of a workspace to remove. |
Definition at line 160 of file AnalysisDataService.cpp.
References group, name, Mantid::Kernel::DataService< T >::remove(), and Mantid::Kernel::DataService< API::Workspace >::retrieve().
Referenced by Mantid::Algorithms::GroupWorkspaces::addToGroup(), 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 334 of file AnalysisDataService.cpp.
References group, and 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 139 of file AnalysisDataService.cpp.
References group, 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 238 of file AnalysisDataService.cpp.
References group, name, and 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 114 of file AnalysisDataService.h.
References name.
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 406 of file AnalysisDataService.cpp.
References m_illegalChars.
| 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 276 of file AnalysisDataService.cpp.
References group, and 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 351 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< API::Workspace >::getObjectNames(), group, name, and Mantid::Kernel::DataService< API::Workspace >::retrieve().
Referenced by Mantid::Algorithms::GroupWorkspaces::addToGroup().
| const std::string Mantid::API::AnalysisDataServiceImpl::uniqueHiddenName | ( | ) |
Random generated unique hidden workspace name.
generate a unique hidden name to be used as a temporary workspace
Definition at line 226 of file AnalysisDataService.cpp.
References uniqueName().
Referenced by export_AnalysisDataService().
| const std::string Mantid::API::AnalysisDataServiceImpl::uniqueName | ( | const int | n = 5, |
| const std::string & | prefix = "", |
||
| const std::string & | suffix = "" |
||
| ) |
Random generated unique workspace name.
generate a unique name that will not collide with any other workspace name
| n | Size of the sequence (must be a positive number) |
| prefix | String to prefix the random name |
| suffix | String to suffix the random name |
Definition at line 199 of file AnalysisDataService.cpp.
References Mantid::Kernel::DataService< API::Workspace >::doesExist(), getRandomLowercaseLetter(), n, name, and std::to_string().
Referenced by export_AnalysisDataService(), and uniqueHiddenName().
|
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 419 of file AnalysisDataService.cpp.
References error, group, isValid(), and name.
Referenced by add(), and addOrReplace().
|
friend |
Definition at line 142 of file AnalysisDataService.h.
|
private |
The string of illegal characters.
Definition at line 155 of file AnalysisDataService.h.
Referenced by illegalCharacters(), and setIllegalCharacterList().