Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of clone() for all Workspaces #12951

Merged
merged 19 commits into from
Jul 3, 2015

Conversation

SimonHeybrock
Copy link
Contributor

Closes #12687.

Implements Workspace::clone() with covariant return type in all sub-classes. Note that there is one remaining issue when cloning a file-backed MDEventWorkspace, see #12994.

The copy implementation by CloneWorkspace was generally replaced by the new clone() method. Therefore the tests of CloneWorkspace test the changes in these commits. Furthermore a few tests of the clone() method itself were added, but the actual coverage is probably by far not complete.

Added non-virtual clone() interface with a virtual private doClone()
method to Workspace and derived classes. Workspaces that had a clone()
method before were adapted to have a common interface everywhere. In
cases where there was no clone() method previously we simply throw an
error for now, until this new functionality is implemented.

Some tests/mocks had to be adapted since there there is a pure virtual
doClone() in all abstract classes.

Do to smart pointer incompatibilities (mainly due to old boost versions)
we had do extract the raw pointer from the unique_ptr returned by clone
and put it into a boost::shared_ptr manually, in some cases. See also
issue 12949.
This seems to be incompatible with the RHEL6 compiler.
Boost < 1.53 does not support construction from a std::unique_ptr, so
for compatibility we must call clone().release() when dropping it to a
boost::shared_ptr.
The previous code which derives from the old implementation of clone()
did not call the base class copy constructor but the base class
constructor. This seemed wrong (though I am not aware of any related
issues).
Previously (before 12687) there was no implementation of clone(). That
is, when calling clone() though a base class (e.g., ITableWorkspace) we
would use TableWorkspace::clone() on an object of type
MementoTableWorkspace. Was that doing the right thing?
Previously (before 12687) there was no implementation of clone().
That is, when calling clone() though a base class (e.g., ITableWorkspace)
we would use TableWorkspace::clone() on an object of type
SplittersWorkspace. Was that doing the right thing?
Note that this does not (yet?) support cloning a file-backed workspace
(see CloneMDWorkspace algorithm).
Using the polymorpic clone, looking at the inheritance structure, code
in CloneWorkspace could be unified. PeaksWorkspace is a child of
ITableWorkspace, so Peaks* and Table* cast could be combined.
EventWorkspace is a child of MAtrixWorkpace, so they could also be
combined.
The remaining special case is due to MDEventWorkspace, which still has
some special code on CloneMDWorkspace.
@SimonHeybrock SimonHeybrock reopened this Jul 2, 2015
@SimonHeybrock SimonHeybrock added Framework Issues and pull requests related to components in the Framework Extra Attention Testers and Gate keepers should pay extra attention as this affects core aspects. labels Jul 2, 2015
@SimonHeybrock SimonHeybrock added this to the Release 3.5 milestone Jul 2, 2015
The reason for this change is related to the diamond inheritance that we
had previously for SplittersWorkspace. VS2012 did not manage to compile
this in combination with the virtual doClone() function with covariant
return types.
Just like IMaskWorkspace, ISplittersWorkspace is now not a Workspace
anymore, and thus the diamond is gone.
@martyngigg
Copy link
Member

This looks good now that the MSVC issues are sorted. CloneWorkspace is now on the road to not knowing too much about the types, which is how it should be.

martyngigg added a commit that referenced this pull request Jul 3, 2015
…thod

Implementation of clone() for all Workspaces
@martyngigg martyngigg merged commit ea1237c into master Jul 3, 2015
@martyngigg martyngigg deleted the 12687_workspace_clone_method branch July 3, 2015 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Extra Attention Testers and Gate keepers should pay extra attention as this affects core aspects. Framework Issues and pull requests related to components in the Framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants