|
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. | |
| virtual void | addOrReplace (const std::string &name, const std::shared_ptr< T > &Tobject) |
| Add or replace an object to the service. | |
| 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< T > > | 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< T > | 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. | |
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. | |
Protected Member Functions | |
| DataService (const std::string &name) | |
| Protected constructor (singleton) | |
| virtual | ~DataService ()=default |
Private Types | |
| using | svc_constit = typename svcmap::const_iterator |
| Const iterator for the data store map. | |
| using | svc_it = typename svcmap::iterator |
| Iterator for the data store map. | |
| 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. | |
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. | |
| Logger | g_log |
| Logger for this DataService. | |
| std::recursive_mutex | m_mutex |
| Recursive mutex to avoid simultaneous access or notifications. | |
| const std::string | svcName |
| DataService name. | |
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 59 of file DataService.h.
|
private |
Const iterator for the data store map.
Definition at line 69 of file DataService.h.
|
private |
Iterator for the data store map.
Definition at line 67 of file DataService.h.
|
private |
Typedef for the map holding the names of and pointers to the data objects.
Definition at line 65 of file DataService.h.
|
delete |
Deleted copy constructor.
|
inlineprotected |
Protected constructor (singleton)
Definition at line 497 of file DataService.h.
|
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 194 of file DataService.h.
References Mantid::Kernel::Logger::debug(), error, Mantid::Kernel::Logger::error(), and name.
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 226 of file DataService.h.
References Mantid::Kernel::Logger::debug(), and name.
Referenced by Mantid::API::AnalysisDataServiceImpl::addOrReplace().
|
inlineprivate |
Definition at line 501 of file DataService.h.
References Mantid::Kernel::Logger::debug(), error, and name.
|
inlineprivate |
Definition at line 509 of file DataService.h.
References Mantid::Kernel::Logger::debug(), and error.
|
inline |
Empty the service.
Definition at line 341 of file DataService.h.
References Mantid::Kernel::Logger::debug(), and name.
|
inline |
Checks all elements within the specified vector exist in the ADS.
Definition at line 371 of file DataService.h.
References name.
|
inline |
Check to see if a data object exists in the store.
Definition at line 377 of file DataService.h.
References name.
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 405 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 458 of file DataService.h.
Referenced by MantidQt::MantidWidgets::SelectWorkspacesDialog::SelectWorkspacesDialog().
|
inlinestatic |
Definition at line 478 of file DataService.h.
References name.
|
delete |
Deleted copy assignment operator.
|
inlinestatic |
Definition at line 476 of file DataService.h.
|
inline |
Remove an object from the service.
| name | :: name of the object |
Definition at line 255 of file DataService.h.
References Mantid::Kernel::Logger::debug(), and name.
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 285 of file DataService.h.
References Mantid::Kernel::Logger::debug(), error, Mantid::Kernel::Logger::error(), 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 357 of file DataService.h.
References name.
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 480 of file DataService.h.
|
inlinevirtual |
Prepare for shutdown.
Definition at line 352 of file DataService.h.
|
inline |
Return the number of objects stored by the data service.
Definition at line 385 of file DataService.h.
|
private |
Map of objects in the data service.
Definition at line 521 of file DataService.h.
|
private |
Logger for this DataService.
Definition at line 525 of file DataService.h.
|
mutableprivate |
Recursive mutex to avoid simultaneous access or notifications.
Definition at line 523 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 489 of file DataService.h.
Referenced by MantidQt::MantidWidgets::WorkspaceSelector::connectObservers(), MantidQt::MantidWidgets::WorkspaceMultiSelector::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 519 of file DataService.h.