Mantid
|
DataService stores instances of a given type. More...
#include <DataService.h>
Classes | |
class | AddNotification |
AddNotification is sent after an new object is added to the data service. More... | |
class | AfterReplaceNotification |
AfterReplaceNotification is sent after an object is replaced in the addOrReplace() function. More... | |
class | BeforeReplaceNotification |
BeforeReplaceNotification is sent before an object is replaced in the addOrReplace() function. More... | |
class | ClearNotification |
Clear notification is sent when the service is cleared. More... | |
class | DataServiceNotification |
Base class for DataService notifications that also stores a pointer to the object. More... | |
class | NamedObjectNotification |
Class for named object notifications. More... | |
class | PostDeleteNotification |
PostDeleteNotification is sent after an object is deleted from the data service. More... | |
class | PreDeleteNotification |
PreDeleteNotification is sent before an object is deleted from the data service. More... | |
class | RenameNotification |
Rename notification is sent when the rename method is called. More... | |
Public Member Functions | |
virtual void | add (const std::string &name, const std::shared_ptr< T > &Tobject) |
Add an object to the service. More... | |
virtual void | addOrReplace (const std::string &name, const std::shared_ptr< T > &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< T > > | 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< T > | 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... | |
Static Public Member Functions | |
static bool | isHiddenDataServiceObject (const std::string &name) |
static std::string | prefixToHide () |
static bool | showingHiddenObjects () |
Public Attributes | |
Poco::NotificationCenter | notificationCenter |
Sends notifications to observers. More... | |
Protected Member Functions | |
DataService (const std::string &name) | |
Protected constructor (singleton) More... | |
virtual | ~DataService ()=default |
Private Types | |
using | svc_constit = typename svcmap::const_iterator |
Const iterator for the data store map. More... | |
using | svc_it = typename svcmap::iterator |
Iterator for the data store map. More... | |
using | svcmap = std::map< std::string, std::shared_ptr< T >, CaseInsensitiveCmp > |
Typedef for the map holding the names of and pointers to the data objects. More... | |
Private Member Functions | |
void | checkForEmptyName (const std::string &name) |
void | checkForNullPointer (const std::shared_ptr< T > &Tobject) |
Private Attributes | |
svcmap | datamap |
Map of objects in the data service. More... | |
Logger | g_log |
Logger for this DataService. More... | |
std::recursive_mutex | m_mutex |
Recursive mutex to avoid simultaneous access or notifications. More... | |
const std::string | svcName |
DataService name. More... | |
DataService stores instances of a given type.
This is a templated class, designed to be implemented as a singleton. For simplicity and naming conventions, specialized classes must be constructed. The specialized classes must simply: 1) call the BaseClass constructor with the Name of the service 2) Support the SingletonHolder templated class. 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.
Definition at line 58 of file DataService.h.
|
private |
Const iterator for the data store map.
Definition at line 65 of file DataService.h.
|
private |
Iterator for the data store map.
Definition at line 63 of file DataService.h.
|
private |
Typedef for the map holding the names of and pointers to the data objects.
Definition at line 61 of file DataService.h.
|
delete |
Deleted copy constructor.
|
inlineprotected |
Protected constructor (singleton)
Definition at line 492 of file DataService.h.
References Mantid::API::g_log.
|
protectedvirtualdefault |
|
inlinevirtual |
Add an object to the service.
name | :: name of the object |
Tobject | :: shared pointer to object to add |
std::runtime_error | if name is empty |
std::runtime_error | if name exists in the map |
std::runtime_error | if a null pointer is passed for the object |
Reimplemented in Mantid::API::AnalysisDataServiceImpl.
Definition at line 190 of file DataService.h.
References Mantid::Kernel::Logger::debug(), error, Mantid::Kernel::Logger::error(), and Mantid::API::g_log.
Referenced by Mantid::API::AnalysisDataServiceImpl::add().
|
inlinevirtual |
Add or replace an object to the service.
Does NOT throw if the name was already used.
name | :: name of the object |
Tobject | :: shared pointer to object to add |
std::runtime_error | if name is empty |
Reimplemented in Mantid::API::AnalysisDataServiceImpl.
Definition at line 222 of file DataService.h.
References Mantid::Kernel::Logger::debug(), and Mantid::API::g_log.
Referenced by Mantid::API::AnalysisDataServiceImpl::addOrReplace().
|
inlineprivate |
Definition at line 496 of file DataService.h.
References Mantid::Kernel::Logger::debug(), error, and Mantid::API::g_log.
|
inlineprivate |
Definition at line 504 of file DataService.h.
References Mantid::Kernel::Logger::debug(), error, and Mantid::API::g_log.
|
inline |
Empty the service.
Definition at line 334 of file DataService.h.
References Mantid::Kernel::Logger::debug(), and Mantid::API::g_log.
|
inline |
Checks all elements within the specified vector exist in the ADS.
Definition at line 364 of file DataService.h.
|
inline |
Check to see if a data object exists in the store.
Definition at line 370 of file DataService.h.
Referenced by Mantid::Algorithms::DeleteWorkspace::checkGroups(), Mantid::WorkflowAlgorithms::MuonGroupAsymmetryCalculator::estimateAsymmetry(), Mantid::API::ScopedWorkspace::remove(), Mantid::API::ScopedWorkspace::retrieve(), and Mantid::API::ScopedWorkspace::set().
|
inline |
Returns a vector of strings containing all object names in the ADS.
sortState | Whether to sort the output before returning. Defaults to unsorted |
hiddenState | Whether to include hidden objects, Defaults to Auto which checks the current configuration to determine behavior. |
contain | Include only object names that contain this string. |
Definition at line 398 of file DataService.h.
Referenced by Mantid::Algorithms::UnGroupWorkspace::init().
|
inline |
Get a vector of the pointers to the data objects stored by the service.
Definition at line 451 of file DataService.h.
Referenced by MantidQt::MantidWidgets::SelectWorkspacesDialog::SelectWorkspacesDialog().
|
inlinestatic |
Definition at line 471 of file DataService.h.
|
delete |
Deleted copy assignment operator.
|
inlinestatic |
Definition at line 469 of file DataService.h.
|
inline |
Remove an object from the service.
name | :: name of the object |
Definition at line 251 of file DataService.h.
References Mantid::Kernel::Logger::debug(), and Mantid::API::g_log.
Referenced by Mantid::API::AnalysisDataServiceImpl::remove().
|
inline |
Rename an object within the service.
oldName | :: The old name of the object |
newName | :: The new name of the object |
Definition at line 281 of file DataService.h.
References Mantid::Kernel::Logger::debug(), error, Mantid::Kernel::Logger::error(), Mantid::API::g_log, and Mantid::Kernel::Logger::warning().
Referenced by Mantid::API::AnalysisDataServiceImpl::rename().
|
inline |
Get a shared pointer to a stored data object.
name | :: name of the object |
Definition at line 350 of file DataService.h.
Referenced by Mantid::Algorithms::GroupWorkspaces::addToGroup(), Mantid::Algorithms::DeleteWorkspace::checkGroups(), Mantid::Algorithms::UnGroupWorkspace::exec(), MantidQt::MantidWidgets::MantidTreeWidget::getSelectedMatrixWorkspaces(), Mantid::Algorithms::FilterEvents::groupOutputWorkspace(), Mantid::Algorithms::UnGroupWorkspace::init(), and MantidQt::MantidWidgets::MantidTreeWidget::mouseDoubleClickEvent().
|
inlinestatic |
Definition at line 475 of file DataService.h.
|
inlinevirtual |
Prepare for shutdown.
Reimplemented in Mantid::API::AnalysisDataServiceImpl.
Definition at line 345 of file DataService.h.
|
inline |
Return the number of objects stored by the data service.
Definition at line 378 of file DataService.h.
|
private |
Map of objects in the data service.
Definition at line 516 of file DataService.h.
|
private |
Logger for this DataService.
Definition at line 520 of file DataService.h.
|
mutableprivate |
Recursive mutex to avoid simultaneous access or notifications.
Definition at line 518 of file DataService.h.
Poco::NotificationCenter Mantid::Kernel::DataService< T >::notificationCenter |
Sends notifications to observers.
Observers can subscribe to notificationCenter using Poco::NotificationCenter::addObserver(...)
Definition at line 484 of file DataService.h.
Referenced by MantidQt::MantidWidgets::WorkspaceSelector::connectObservers(), and Mantid::Algorithms::UnGroupWorkspace::exec().
|
private |
DataService name.
This is set only at construction. DataService name should be provided when construction of derived classes
Definition at line 514 of file DataService.h.