Page MenuHomePhabricator

Write templated convenience function for loading data with mitk::IOUtil
Closed, ResolvedPublic

Revisions and Commits

Event Timeline

kislinsk triaged this task as Wishlist priority.Mar 29 2018, 10:15 AM
kislinsk created this task.

All Load() methods that return a std::vector<mitk::BaseData::Pointer> could get a templated twin method that returns the typed smart pointer of the first element. In 99% of all cases, Load() returns a vector of a single element anyways and code readability would be a lot better with the templated versions:

mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(mitk::IOUtils::Load("...").at(0).GetPointer());
auto image = mitk::IOUtils::Load<mitk::Image>("...");

Also, after the deprecated LoadImage(), LoadSurface(), and LoadPointSet() were removed, new overloads were accidentally added. These overloads (which actually aren't overloads as they are the only methods with their name) should be removed again. This happened after the last release and hence we can spare the deprecation process.

I replaced dynamic_cast<(.+)\*>\(mitk::IOUtil::Load\((.+)\)(?:\[0\]|\.at\(0\)|\.front\(\))\.GetPointer\(\)\s*\) with mitk::IOUtil::Load<$1>\($2\) in all .h and .cpp files.

kislinsk added a revision: Restricted Differential Revision.Mar 29 2018, 1:13 PM