Mantid
Loading...
Searching...
No Matches
Classes | List of all members
Mantid::API::AnalysisDataServiceImpl Class Referencefinal

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>

Inheritance diagram for Mantid::API::AnalysisDataServiceImpl:
Mantid::Kernel::DataService< API::Workspace >

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_sptrretrieveWorkspaces (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...
 
DataServiceoperator= (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::Workspaceretrieve (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_sptrtopLevelItems () 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...
 
AnalysisDataServiceImploperator= (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
 

Detailed Description

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.

Author
Russell Taylor, Tessella Support Services plc
Date
01/10/2007
Author
L C Chapon, ISIS, Rutherford Appleton Laboratory

Modified to inherit from DataService

Definition at line 43 of file AnalysisDataService.h.

Constructor & Destructor Documentation

◆ AnalysisDataServiceImpl() [1/2]

Mantid::API::AnalysisDataServiceImpl::AnalysisDataServiceImpl ( )
private

Constructor.

Definition at line 332 of file AnalysisDataService.cpp.

◆ AnalysisDataServiceImpl() [2/2]

Mantid::API::AnalysisDataServiceImpl::AnalysisDataServiceImpl ( const AnalysisDataServiceImpl )
privatedelete

Private, unimplemented copy constructor.

◆ ~AnalysisDataServiceImpl()

Mantid::API::AnalysisDataServiceImpl::~AnalysisDataServiceImpl ( )
overrideprivatedefault

Private destructor.

Member Function Documentation

◆ add()

void Mantid::API::AnalysisDataServiceImpl::add ( const std::string &  name,
const std::shared_ptr< API::Workspace > &  workspace 
)
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.

Parameters
nameThe name of the object
workspaceThe 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().

◆ addOrReplace()

void Mantid::API::AnalysisDataServiceImpl::addOrReplace ( const std::string &  name,
const std::shared_ptr< API::Workspace > &  workspace 
)
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.

Parameters
nameThe name of the object
workspaceThe 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().

◆ addToGroup()

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.

Parameters
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().

◆ deepRemoveGroup()

void Mantid::API::AnalysisDataServiceImpl::deepRemoveGroup ( const std::string &  name)

Remove a workspace group and all its members from the ADS.

Parameters
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().

◆ illegalCharacters()

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.

Returns
A n array of c strings containing the following characters: " +-/*\%<>&|^~=!@()[]{},:.`$?"

Definition at line 342 of file AnalysisDataService.cpp.

References m_illegalChars.

Referenced by isValid().

◆ 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.

Parameters
nameA string containing a possible name for an object in the ADS
Returns
An empty string if the name is valid or an error message stating the problem if the name is unacceptable.

Definition at line 40 of file AnalysisDataService.cpp.

References error, and illegalCharacters().

Referenced by verifyName().

◆ operator=()

AnalysisDataServiceImpl & Mantid::API::AnalysisDataServiceImpl::operator= ( const AnalysisDataServiceImpl )
privatedelete

Private, unimplemented copy assignment operator.

◆ remove()

void Mantid::API::AnalysisDataServiceImpl::remove ( const std::string &  name)
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.

Parameters
nameThe 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().

◆ removeFromGroup()

void Mantid::API::AnalysisDataServiceImpl::removeFromGroup ( const std::string &  groupName,
const std::string &  wsName 
)

Remove a workspace from a group but not from the ADS.

Parameters
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().

◆ rename()

void Mantid::API::AnalysisDataServiceImpl::rename ( const std::string &  oldName,
const std::string &  newName 
)
virtual

Overridden rename member to attach the new name to the workspace when a workspace object is renamed.

Parameters
oldNameThe old name of the object
newNameThe 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().

◆ retrieveWorkspaces()

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.

Parameters
namesA list of names of workspaces, if any does not exist then a Kernel::Exception::NotFoundError is thrown.
unrollGroupsIf true flatten groups into the list of members.
Returns
A vector of pointers to Workspaces
Exceptions
std::invalid_argumentif no names are provided
Mantid::Kernel::Exception::NotFoundErrorif a workspace does not exist within the ADS

Definition at line 180 of file AnalysisDataService.cpp.

References Mantid::Kernel::DataService< API::Workspace >::retrieve().

◆ retrieveWS()

template<typename WSTYPE >
std::shared_ptr< WSTYPE > Mantid::API::AnalysisDataServiceImpl::retrieveWS ( const std::string &  name) const
inline

Retrieve a workspace and cast it to the given WSTYPE.

Parameters
name:: name of the workspace
Template Parameters
WSTYPE:: type of workspace to cast to. Should sub-class Workspace
Returns
a shared pointer of WSTYPE

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().

◆ setIllegalCharacterList()

void Mantid::API::AnalysisDataServiceImpl::setIllegalCharacterList ( const std::string &  illegalChars)

Set the list of illegal characters.

Set the list of illegal characeters.

Parameters
illegalCharsA 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.

◆ shutdown()

void Mantid::API::AnalysisDataServiceImpl::shutdown ( )
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().

◆ sortGroupByName()

void Mantid::API::AnalysisDataServiceImpl::sortGroupByName ( const std::string &  groupName)

Sort members by Workspace name.

The group must be in the ADS.

Parameters
groupName:: A group name.

Definition at line 218 of file AnalysisDataService.cpp.

References Mantid::Kernel::DataService< API::Workspace >::notificationCenter.

◆ topLevelItems()

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.

Returns
A lookup of name to Workspace pointer

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().

◆ verifyName()

void Mantid::API::AnalysisDataServiceImpl::verifyName ( const std::string &  name,
const std::shared_ptr< API::WorkspaceGroup > &  group 
)
private

Checks the name is valid, throwing if not.

Checks the name is valid.

Parameters
nameA string containing the name to check. If the name is invalid a std::invalid_argument or std::runtime_error is thrown
groupA 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().

Friends And Related Function Documentation

◆ Mantid::Kernel::CreateUsingNew< AnalysisDataServiceImpl >

Definition at line 138 of file AnalysisDataService.h.

Member Data Documentation

◆ m_illegalChars

std::string Mantid::API::AnalysisDataServiceImpl::m_illegalChars
private

The string of illegal characters.

Definition at line 151 of file AnalysisDataService.h.

Referenced by illegalCharacters(), and setIllegalCharacterList().


The documentation for this class was generated from the following files: