|
Mantid
|
Class to hold a set of workspaces. More...
#include <WorkspaceGroup.h>
Public Member Functions | |
| void | addWorkspace (const Workspace_sptr &workspace) |
| Adds a workspace to the group. | |
| bool | areNamesSimilar () const |
| Are the members of this group of similar names, e.g. | |
| std::vector< Workspace_sptr >::iterator | begin () |
| Returns a non-const iterator pointing at the first element in the workspace group. | |
| std::vector< Workspace_sptr >::const_iterator | begin () const |
| Returns a const iterator pointing at the first element in the workspace group. | |
| std::vector< Workspace_sptr >::iterator | end () |
| Returns a non-const iterator pointing at the last element in the workspace group. | |
| std::vector< Workspace_sptr >::const_iterator | end () const |
| Returns a const iterator pointing at the last element in the workspace group. | |
| std::vector< Workspace_sptr > | getAllItems () const |
| Return all workspaces in the group as one call for thread safety. | |
| Workspace_sptr | getItem (const size_t index) const |
| Return the ith workspace. | |
| Workspace_sptr | getItem (const std::string &wsName) const |
| Return the workspace by name. | |
| size_t | getMemorySize () const override |
| Return the memory size of all workspaces in this group and subgroups. | |
| int | getNumberOfEntries () const |
| Return the number of entries within the group. | |
| const std::string | id () const override |
| Return a string ID of the class. | |
| bool | isEmpty () const |
| This method returns true if the group is empty (no member workspace) | |
| bool | isGroup () const override |
| bool | isGroupPeaksWorkspaces () const |
| Check if the workspace group contains just peak workspaces. | |
| bool | isInGroup (const Workspace &workspaceToCheck, size_t level=0) const |
| Check if a workspace is included in this group or any nested groups. | |
| bool | isMultiperiod () const |
| Indicates that the workspace group can be treated as multiperiod. | |
| void | print () const |
| Prints the group to the screen using the logger at debug. | |
| void | removeAll () |
| Remove all names from the group but do not touch the ADS. | |
| void | removeItem (const size_t index) |
| Remove a workspace from the group. | |
| void | reorderMembersWithIndices (const std::vector< int > &indices) |
| Reorder the group members using a list of indices (e.g the list 4,3,2,1 would reverse the order) | |
| size_t | size () const |
| Return the size of the group, so it is more like a container. | |
| void | sortMembersByName () |
| Sort the internal data structure according to member name. | |
| void | throwIndexOutOfRangeError (int index) const |
| Throws an out_of_range error for an invalid index. | |
| const std::string | toString () const override |
| Returns a formatted string detailing the contents of the group. | |
| WorkspaceGroup () | |
| Default constructor. | |
| ~WorkspaceGroup () override | |
| Destructor. | |
Public Member Functions inherited from Mantid::API::Workspace | |
| Workspace_uptr | clone () const |
| Returns a clone (copy) of the workspace with covariant return type in all derived classes. | |
| Workspace_uptr | cloneEmpty () const |
| Returns a default-initialized clone of the workspace. | |
| const std::string & | getComment () const |
| Get the workspace comment. | |
| const WorkspaceHistory & | getHistory () const |
| Returns a reference to the WorkspaceHistory const. | |
| std::string | getMemorySizeAsStr () const |
| Returns the memory footprint in sensible units. | |
| const std::string & | getName () const override |
| Get the workspace name. | |
| const std::string & | getPythonVariableName () const |
| virtual const std::string | getTitle () const |
| Get the workspace title. | |
| WorkspaceHistory & | history () |
| Returns a reference to the WorkspaceHistory. | |
| bool | isDirty (const int n=1) const |
| Check whether other algorithms have been applied to the workspace by checking the history length. | |
| Workspace & | operator= (const Workspace &other)=delete |
| void | setComment (const std::string &) |
| Set the comment field of the workspace. | |
| void | setPythonVariableName (const std::string &) |
| virtual void | setTitle (const std::string &) |
| Set the title of the workspace. | |
| bool | threadSafe () const override |
| Marks the workspace as safe for multiple threads to edit data simutaneously. | |
| Workspace () | |
| ~Workspace () | |
Public Member Functions inherited from Mantid::Kernel::DataItem | |
| DataItem () | |
| Default constructor. | |
| DataItem (const DataItem &other) | |
| Copy constructor Always makes a unique lock. | |
| virtual | ~DataItem () |
| Destructor. | |
| void | readLock () |
| Acquires a read lock. | |
| void | unlock () |
Wrapped ADS calls | |
| Poco::NObserver< WorkspaceGroup, Mantid::API::WorkspacePostDeleteNotification > | m_deleteObserver |
| Observer for workspace delete notifications. | |
| Poco::NObserver< WorkspaceGroup, Mantid::API::WorkspaceBeforeReplaceNotification > | m_beforeReplaceObserver |
| Observer for workspace before-replace notifications. | |
| std::vector< Workspace_sptr > | m_workspaces |
| The list of workspace pointers in the group. | |
| bool | m_observingADS |
| Flag as to whether the observers have been added to the ADS. | |
| std::recursive_mutex | m_mutex |
| Recursive mutex to avoid simultaneous access. | |
| class | AnalysisDataServiceImpl |
| class | Algorithm |
| void | sortByName () |
| Invokes the ADS to sort group members by workspace name. | |
| void | add (const std::string &wsName) |
| Adds a workspace to the group. | |
| void | remove (const std::string &wsName) |
| Remove a name from the group. | |
| bool | containsInChildren (const std::string &wsName) const |
| Does a workspace exist within the group or any groups within this group. | |
| bool | contains (const std::string &wsName) const |
| Does a workspace exist within the group. | |
| bool | contains (const Workspace_sptr &workspace) const |
| Does a workspace exist within the group. | |
| void | reportMembers (std::set< Workspace_sptr > &memberList) const |
| Add the members of the group to the given list. | |
| std::vector< std::string > | getNames () const |
| Returns the names of workspaces that make up this group. | |
| WorkspaceGroup (const WorkspaceGroup &ref)=delete | |
| WorkspaceGroup & | operator= (const WorkspaceGroup &)=delete |
| WorkspaceGroup * | doClone () const override |
| Virtual clone method. Not implemented to force implementation in children. | |
| WorkspaceGroup * | doCloneEmpty () const override |
| Virtual cloneEmpty method. | |
| void | removeByADS (const std::string &wsName) |
| ADS removes a member of this group using this method. | |
| void | observeADSNotifications (const bool observeADS) |
| Turn ADS observations on/off. | |
| bool | isInChildGroup (const Workspace &workspaceToCheck) const |
| Check if a workspace is included in any child groups and groups in them. | |
| void | workspaceDeleteHandle (Mantid::API::WorkspacePostDeleteNotification_ptr notice) |
| Callback when a delete notification is received. | |
| void | workspaceBeforeReplaceHandle (Mantid::API::WorkspaceBeforeReplaceNotification_ptr notice) |
| Callback when a before-replace notification is received. | |
Additional Inherited Members | |
Protected Member Functions inherited from Mantid::API::Workspace | |
| Workspace (const Workspace &) | |
| Protected copy constructor. May be used by childs for cloning. | |
Protected Member Functions inherited from Mantid::Kernel::DataItem | |
| Poco::RWLock * | getLock () const |
| Private method to access the RWLock object. | |
Class to hold a set of workspaces.
The workspace group can be an entry in the AnalysisDataService. Its constituent workspaces should also have individual ADS entries. Workspace groups can be used in algorithms in the same way as single workspaces.
Definition at line 37 of file WorkspaceGroup.h.
| Mantid::API::WorkspaceGroup::WorkspaceGroup | ( | ) |
Default constructor.
Definition at line 24 of file WorkspaceGroup.cpp.
|
override |
|
delete |
|
inline |
Adds a workspace to the group.
Definition at line 105 of file WorkspaceGroup.h.
References getName().
Referenced by addItem().
| void Mantid::API::WorkspaceGroup::addWorkspace | ( | const Workspace_sptr & | workspace | ) |
Adds a workspace to the group.
The workspace does not have to be in the ADS
| workspace | :: A shared pointer to a workspace to add. If the workspace already exists give a warning. |
Definition at line 132 of file WorkspaceGroup.cpp.
References Mantid::API::g_log, m_mutex, m_workspaces, Mantid::Kernel::Logger::warning(), and workspace.
Referenced by addWorkspace(), and Mantid::CurveFitting::FuncMinimisers::FABADAMinimizer::outputPDF().
| bool Mantid::API::WorkspaceGroup::areNamesSimilar | ( | ) | const |
Are the members of this group of similar names, e.g.
for a WorkspaceGroup names "groupname", the members are "groupname_1", "groupname_2", etc.
Definition at line 425 of file WorkspaceGroup.cpp.
References m_mutex, m_workspaces, and workspace.
Referenced by Mantid::API::Algorithm::checkGroups().
| std::vector< Workspace_sptr >::iterator Mantid::API::WorkspaceGroup::begin | ( | ) |
Returns a non-const iterator pointing at the first element in the workspace group.
Returns an iterator pointing to the first element in the group.
Definition at line 293 of file WorkspaceGroup.cpp.
References m_workspaces.
| std::vector< Workspace_sptr >::const_iterator Mantid::API::WorkspaceGroup::begin | ( | ) | const |
Returns a const iterator pointing at the first element in the workspace group.
Returns a const iterator pointing to the first element in the group.
Definition at line 301 of file WorkspaceGroup.cpp.
References m_workspaces.
| bool Mantid::API::WorkspaceGroup::contains | ( | const std::string & | wsName | ) | const |
Does a workspace exist within the group.
Does this group contain the named workspace?
| wsName | :: A string to compare |
Definition at line 170 of file WorkspaceGroup.cpp.
References m_mutex, m_workspaces, and workspace.
Referenced by export_WorkspaceGroup(), and workspaceDeleteHandle().
| bool Mantid::API::WorkspaceGroup::contains | ( | const Workspace_sptr & | workspace | ) | const |
Does a workspace exist within the group.
| workspace | A pointer to a workspace |
Definition at line 180 of file WorkspaceGroup.cpp.
References m_mutex, m_workspaces, and workspace.
| bool Mantid::API::WorkspaceGroup::containsInChildren | ( | const std::string & | wsName | ) | const |
Does a workspace exist within the group or any groups within this group.
Does this group or any of it's child groups contain the named workspace?
| wsName | :: A string to compare |
Definition at line 151 of file WorkspaceGroup.cpp.
References m_mutex, m_workspaces, and workspace.
|
inlineoverrideprivatevirtual |
Virtual clone method. Not implemented to force implementation in children.
Implements Mantid::API::Workspace.
Definition at line 126 of file WorkspaceGroup.h.
|
inlineoverrideprivatevirtual |
Virtual cloneEmpty method.
Not implemented to force implementation in children.
Implements Mantid::API::Workspace.
Definition at line 129 of file WorkspaceGroup.h.
| std::vector< Workspace_sptr >::iterator Mantid::API::WorkspaceGroup::end | ( | ) |
Returns a non-const iterator pointing at the last element in the workspace group.
Returns an iterator pointing to the past-the-end element in the group.
Definition at line 309 of file WorkspaceGroup.cpp.
References m_workspaces.
Referenced by group_end().
| std::vector< Workspace_sptr >::const_iterator Mantid::API::WorkspaceGroup::end | ( | ) | const |
Returns a const iterator pointing at the last element in the workspace group.
Returns a const iterator pointing to the past-the-end element in the group.
Definition at line 317 of file WorkspaceGroup.cpp.
References m_workspaces.
| std::vector< Workspace_sptr > Mantid::API::WorkspaceGroup::getAllItems | ( | ) | const |
Return all workspaces in the group as one call for thread safety.
Definition at line 243 of file WorkspaceGroup.cpp.
References m_mutex, and m_workspaces.
| Workspace_sptr Mantid::API::WorkspaceGroup::getItem | ( | const size_t | index | ) | const |
Return the ith workspace.
| index | The index within the group |
| an | out_of_range error if the index is invalid |
Definition at line 217 of file WorkspaceGroup.cpp.
References index, m_mutex, m_workspaces, size(), and throwIndexOutOfRangeError().
Referenced by Mantid::DataHandling::MultiPeriodLoadMuonStrategy::applyTimeZeroCorrection(), getItem(), Mantid::DataHandling::MultiPeriodLoadMuonStrategy::getLoadedDetectors(), Mantid::DataHandling::MultiPeriodLoadMuonStrategy::getTimeZeroTable(), Mantid::DataHandling::MultiPeriodLoadMuonStrategy::loadDetectorGrouping(), Mantid::DataHandling::MultiPeriodLoadMuonStrategy::loadGoodFrames(), Mantid::DataHandling::MultiPeriodLoadMuonStrategy::loadMuonLogData(), and Mantid::Algorithms::CalculateEfficiency2::mergeGroup().
| Workspace_sptr Mantid::API::WorkspaceGroup::getItem | ( | const std::string & | wsName | ) | const |
Return the workspace by name.
| wsName | The name of the workspace |
| an | out_of_range error if the workspace's name not contained in the group's list of workspace names |
Definition at line 230 of file WorkspaceGroup.cpp.
References m_mutex, m_workspaces, and workspace.
|
overridevirtual |
Return the memory size of all workspaces in this group and subgroups.
Implements Mantid::API::Workspace.
Definition at line 516 of file WorkspaceGroup.cpp.
References m_workspaces, and workspace.
| std::vector< std::string > Mantid::API::WorkspaceGroup::getNames | ( | ) | const |
Returns the names of workspaces that make up this group.
Note that this returns a copy as the internal vector can mutate while the vector is being iterated over.
Definition at line 201 of file WorkspaceGroup.cpp.
References m_mutex, and m_workspaces.
Referenced by Mantid::DataHandling::LoadFITS::doLoadFiles(), Mantid::MDAlgorithms::MergeMD::exec(), export_WorkspaceGroup(), and Mantid::Algorithms::RunCombinationHelper::unWrapGroups().
|
inline |
Return the number of entries within the group.
Definition at line 57 of file WorkspaceGroup.h.
Referenced by Mantid::DataHandling::MultiPeriodLoadMuonStrategy::applyTimeZeroCorrection(), export_WorkspaceGroup(), Mantid::DataHandling::MultiPeriodLoadMuonStrategy::loadDeadTimeTable(), Mantid::DataHandling::MultiPeriodLoadMuonStrategy::loadDetectorGrouping(), Mantid::DataHandling::MultiPeriodLoadMuonStrategy::loadGoodFrames(), Mantid::DataHandling::MultiPeriodLoadMuonStrategy::loadMuonLogData(), and Mantid::Algorithms::CalculateEfficiency2::mergeGroup().
|
inlineoverridevirtual |
Return a string ID of the class.
Implements Mantid::Kernel::DataItem.
Definition at line 44 of file WorkspaceGroup.h.
Referenced by toString().
| bool Mantid::API::WorkspaceGroup::isEmpty | ( | ) | const |
This method returns true if the group is empty (no member workspace)
This method returns true if the workspace group is empty.
Definition at line 413 of file WorkspaceGroup.cpp.
References m_mutex, and m_workspaces.
Referenced by Mantid::Algorithms::DeleteWorkspace::checkGroups(), and workspaceDeleteHandle().
|
inlineoverridevirtual |
Reimplemented from Mantid::API::Workspace.
Definition at line 70 of file WorkspaceGroup.h.
| bool Mantid::API::WorkspaceGroup::isGroupPeaksWorkspaces | ( | ) | const |
Check if the workspace group contains just peak workspaces.
Definition at line 486 of file WorkspaceGroup.cpp.
References m_workspaces.
|
private |
Check if a workspace is included in any child groups and groups in them.
| workspaceToCheck | :: A workspace to check. |
Definition at line 75 of file WorkspaceGroup.cpp.
References group, m_mutex, m_workspaces, and workspace.
| bool Mantid::API::WorkspaceGroup::isInGroup | ( | const Workspace & | workspaceToCheck, |
| size_t | level = 0 |
||
| ) | const |
Check if a workspace is included in this group or any nested groups.
| workspaceToCheck | :: A workspace to check. |
| level | :: The current nesting level. Intended for internal use only by WorkspaceGroup. |
Definition at line 498 of file WorkspaceGroup.cpp.
References group, m_mutex, m_workspaces, and workspace.
| bool Mantid::API::WorkspaceGroup::isMultiperiod | ( | ) | const |
Indicates that the workspace group can be treated as multiperiod.
Determine in the WorkspaceGroup is multiperiod.
Definition at line 452 of file WorkspaceGroup.cpp.
References Mantid::Kernel::Strings::convert(), Mantid::Kernel::Logger::debug(), Mantid::API::g_log, m_mutex, m_workspaces, Mantid::Kernel::Property::value(), and workspace.
Referenced by export_WorkspaceGroup().
|
private |
Turn ADS observations on/off.
Turn on/off observing delete and rename notifications to update the group accordingly It can be useful to turn them off when constructing the group.
| observeADS | :: If true observe the ADS notifications, otherwise disable them |
Definition at line 55 of file WorkspaceGroup.cpp.
References m_beforeReplaceObserver, m_deleteObserver, and m_observingADS.
Referenced by workspaceDeleteHandle(), and ~WorkspaceGroup().
|
delete |
| void Mantid::API::WorkspaceGroup::print | ( | ) | const |
Prints the group to the screen using the logger at debug.
Print the names of all the workspaces in this group to the logger (at debug level)
Definition at line 269 of file WorkspaceGroup.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, m_mutex, m_workspaces, and workspace.
|
inline |
Remove a name from the group.
Definition at line 107 of file WorkspaceGroup.h.
References getName().
Referenced by removeItem().
| void Mantid::API::WorkspaceGroup::removeAll | ( | ) |
Remove all names from the group but do not touch the ADS.
Empty all the entries out of the workspace group.
Does not remove the workspaces from the ADS.
Definition at line 250 of file WorkspaceGroup.cpp.
References m_workspaces.
|
private |
ADS removes a member of this group using this method.
Remove the named workspace from the group.
It doesn't send notifications in contrast to remove(name).
Does not delete the workspace from the AnalysisDataService.
| wsName | :: The name of the workspace to be removed from the group. |
Definition at line 256 of file WorkspaceGroup.cpp.
References m_mutex, and m_workspaces.
Referenced by workspaceDeleteHandle().
| void Mantid::API::WorkspaceGroup::removeItem | ( | const size_t | index | ) |
Remove a workspace from the group.
Remove a workspace pointed to by an index.
The workspace remains in the ADS if it was there
| index | :: Index of a workspace to delete. |
Definition at line 325 of file WorkspaceGroup.cpp.
References Mantid::API::Workspace::getName(), index, m_mutex, m_workspaces, and size().
| void Mantid::API::WorkspaceGroup::reorderMembersWithIndices | ( | const std::vector< int > & | indices | ) |
Reorder the group members using a list of indices (e.g the list 4,3,2,1 would reverse the order)
Reorder the group members using a list of indices (e.g the list 3,2,1,0 would reverse the order)
Definition at line 102 of file WorkspaceGroup.cpp.
References Mantid::API::g_log, m_workspaces, and Mantid::Kernel::Logger::warning().
Referenced by reorder().
| void Mantid::API::WorkspaceGroup::reportMembers | ( | std::set< Workspace_sptr > & | memberList | ) | const |
Add the members of the group to the given list.
Adds the current workspace members to the given list.
| memberList |
Definition at line 191 of file WorkspaceGroup.cpp.
References m_mutex, and m_workspaces.
|
inline |
Return the size of the group, so it is more like a container.
Definition at line 59 of file WorkspaceGroup.h.
Referenced by export_WorkspaceGroup(), getItem(), getItem(), removeItem(), sortMembersByName(), throwIndexOutOfRangeError(), and Mantid::DataHandling::SaveReflectometryAscii::validateInputs().
|
inline |
Invokes the ADS to sort group members by workspace name.
Definition at line 102 of file WorkspaceGroup.h.
References getName().
Referenced by export_WorkspaceGroup().
| void Mantid::API::WorkspaceGroup::sortMembersByName | ( | ) |
Sort the internal data structure according to member name.
Sort members by Workspace name.
Definition at line 91 of file WorkspaceGroup.cpp.
References m_workspaces, and size().
| void Mantid::API::WorkspaceGroup::throwIndexOutOfRangeError | ( | int | index | ) | const |
|
overridevirtual |
Returns a formatted string detailing the contents of the group.
The format is: ID – Name1 – Name2.
Implements Mantid::Kernel::DataItem.
Definition at line 39 of file WorkspaceGroup.cpp.
References id(), m_mutex, m_workspaces, and workspace.
|
private |
Callback when a before-replace notification is received.
Callback when a before-replace notification is received Replaces a member if it was replaced in the ADS and checks for duplicate members within the group.
| notice | :: A pointer to a workspace before-replace notification object |
Definition at line 377 of file WorkspaceGroup.cpp.
References m_mutex, m_workspaces, and workspace.
|
private |
Callback when a delete notification is received.
Callback for a workspace delete notification.
Removes any deleted entries from the group. This also deletes the workspace group when the last member of it gets deleted.
| notice | :: A pointer to a workspace delete notificiation object |
Definition at line 349 of file WorkspaceGroup.cpp.
References contains(), Mantid::API::Workspace::getName(), isEmpty(), m_mutex, observeADSNotifications(), and removeByADS().
|
friend |
Definition at line 158 of file WorkspaceGroup.h.
|
friend |
Definition at line 157 of file WorkspaceGroup.h.
|
private |
Observer for workspace before-replace notifications.
Definition at line 149 of file WorkspaceGroup.h.
Referenced by observeADSNotifications().
|
private |
Observer for workspace delete notifications.
Definition at line 147 of file WorkspaceGroup.h.
Referenced by observeADSNotifications().
|
mutableprivate |
Recursive mutex to avoid simultaneous access.
Definition at line 155 of file WorkspaceGroup.h.
Referenced by addWorkspace(), areNamesSimilar(), contains(), contains(), containsInChildren(), getAllItems(), getItem(), getItem(), getNames(), isEmpty(), isInChildGroup(), isInGroup(), isMultiperiod(), print(), removeByADS(), removeItem(), reportMembers(), toString(), workspaceBeforeReplaceHandle(), and workspaceDeleteHandle().
|
private |
Flag as to whether the observers have been added to the ADS.
Definition at line 153 of file WorkspaceGroup.h.
Referenced by observeADSNotifications().
|
private |
The list of workspace pointers in the group.
Definition at line 151 of file WorkspaceGroup.h.
Referenced by addWorkspace(), areNamesSimilar(), begin(), begin(), contains(), contains(), containsInChildren(), end(), end(), getAllItems(), getItem(), getItem(), getMemorySize(), getNames(), isEmpty(), isGroupPeaksWorkspaces(), isInChildGroup(), isInGroup(), isMultiperiod(), print(), removeAll(), removeByADS(), removeItem(), reorderMembersWithIndices(), reportMembers(), sortMembersByName(), toString(), and workspaceBeforeReplaceHandle().