[CCPPETMR/SIRF] Clone as sptr (#277)

已查看 0 次
跳至第一个未读帖子

Richard Brown

未读,
2018年12月21日 11:40:382018/12/21
收件人 CCPPETMR/SIRF、Subscribed

We need this so that we can create copies of derived image classes, stored as the base ImageData class.

We'll need this for registration etc., as the output will be a copy of one of the inputs (which will be stored as the abstract base class, ImageData).


You can view, comment on, or merge this pull request online at:

  https://github.com/CCPPETMR/SIRF/pull/277

Commit Summary

  • Clone as sptr

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Kris Thielemans

未读,
2018年12月21日 14:26:592018/12/21
收件人 CCPPETMR/SIRF、Subscribed

@KrisThielemans commented on this pull request.

I think most of these could use make_shared. However, shouldn't we be using @evgueni-ovtchinnikov's strategy of having a virtual function that creates a ptr (using covariant return types), and just making the shared_ptr at base class level?

Also, I think we have a naming problem. I cannot remember how we called the recent functions in that discussion. We do have gadgetron::shared_ptr<MRAcquisitionData> clone(). All of these should have the same name. for the same concept.

I'd be fine with clone return the bare pointer, and clone_as_sptr as a shared_ptr, or clone returning the shared_ptr and clone_as_ptr, or another sensible convention, but mixing things up is bad.

Richard Brown

未读,
2018年12月21日 14:41:042018/12/21
收件人 CCPPETMR/SIRF、Subscribed

I not overly fussed about which name we choose, but clone_as_sptr seems to make the most sense to me.

If you agree, I'll rename gadgetron::shared_ptr<MRAcquisitionData> clone() as gadgetron::shared_ptr<MRAcquisitionData> clone_as_sptr() and then they would all be consistent.

I think most of these could use make_shared.

We could, I can do that if you prefer (seems the same to me since they both call the constructor once).

However, shouldn't we be using @evgueni-ovtchinnikov's strategy of having a virtual function that creates a ptr (using covariant return types), and just making the shared_ptr at base class level?

I'd rather not do that, since we'd be creating double the number of methods, and I'd err away from using raw pointers anyway.

Thoughts?

Kris Thielemans

未读,
2018年12月22日 10:04:122018/12/22
收件人 CCPPETMR/SIRF、Subscribed

This seems to overlap with #254. Doesn't that give you what you need? You might need of course some ugly casting. But that can be resolved implementing a clone_as_sptr in terms of new_data_container_sptr (doing the casting there). No other code needed.

In fact, somewhat surprisingly, this trick can be used with the same function name (using "hiding").

I've created a separate issue for the longer term design, see #278. I guess you don't need this PR if you can use new_data_container_sptr. (Note however that there's an extra constructor for GadgetronImagesVector in this PR.)

(By the way, I think make_shared is a tiny bit more conservative in memory usage than shared_ptr(new T(...)) but it's probably the least of our worries).

Richard Brown

未读,
2019年1月2日 10:22:402019/1/2
收件人 CCPPETMR/SIRF、Subscribed

new_data_container_sptr returns a blank copy of that image type. In hindsight, I don't need new_data_container_sptr, but I do need a copy method.

So, could we:

  • close #254,
  • reopen #253 (which we had closed as it was merged into #254), and
  • use this PR?

If that's ok, I'll update this PR as per #278 so that clone_as_sptr is renamed as copy and returns a std::unique_ptr. I'll also use make_shared.

Richard Brown

未读,
2019年1月3日 08:46:282019/1/3
收件人 CCPPETMR/SIRF、Push

@rijobro pushed 1 commit.


You are receiving this because you are subscribed to this thread.

View it on GitHub or mute the thread.

Richard Brown

未读,
2019年1月3日 09:50:272019/1/3
收件人 CCPPETMR/SIRF、Subscribed

Implemented as per #278. Travis fine (as much as master).

Richard Brown

未读,
2019年1月3日 10:21:482019/1/3
收件人 CCPPETMR/SIRF、Push

@rijobro pushed 1 commit.

  • 209699a documentation in DeveloperGuide.md


You are receiving this because you are subscribed to this thread.

View it on GitHub or mute the thread.

Kris Thielemans

未读,
2019年1月3日 10:24:422019/1/3
收件人 CCPPETMR/SIRF、Subscribed

Merged #277 into master.

Kris Thielemans

未读,
2019年1月3日 10:25:092019/1/3
收件人 CCPPETMR/SIRF、Subscribed

@rijobro, please create an issue to "lift" this up to DataContainer

Richard Brown

未读,
2019年1月3日 10:29:592019/1/3
收件人 CCPPETMR/SIRF、Subscribed

@rijobro, please create an issue to "lift" this up to DataContainer

Issue here #280.

回复全部
回复作者
转发
0 个新帖子