31 const std::string &category)
39 for (
auto extension : extensions)
41 if (!extension.empty() && extension[0] ==
'.')
43 extension.assign(extension.begin() + 1, extension.end());
61 std::vector<BaseData::Pointer> result;
63 std::list<IOAdapterBase::Pointer> possibleIOAdapter;
64 std::list<itk::LightObject::Pointer> allobjects = itk::ObjectFactoryBase::CreateAllInstance(
"mitkIOAdapter");
66 for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin(); i != allobjects.end(); ++i)
71 possibleIOAdapter.push_back(io);
75 MITK_ERROR <<
"Error BaseDataIO factory did not return an IOAdapterBase: " << (*i)->GetNameOfClass() << std::endl;
79 const std::string path = this->GetLocalFileName();
80 for (std::list<IOAdapterBase::Pointer>::iterator k = possibleIOAdapter.begin(); k != possibleIOAdapter.end(); ++k)
82 bool canReadFile = (*k)->CanReadFile(path,
"",
"");
88 int numberOfContents =
static_cast<int>(ioObject->GetNumberOfOutputs());
90 if (numberOfContents > 0)
93 for (
int i = 0; i < numberOfContents; ++i)
95 baseData =
dynamic_cast<BaseData *
>(ioObject->GetOutputs()[i].GetPointer());
98 result.push_back(baseData);
109 mitkThrow() <<
"Could not read file '" << path <<
"'";
Base of all data objects.
DataCollection - Class to facilitate loading/accessing structured data.
void SetMimeType(const CustomMimeType &mimeType)
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
void SetMimeTypePrefix(const std::string &prefix)
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
static std::string DEFAULT_BASE_NAME()
IOAdapterBase class is an abstract adapter class for IO process objects.
void SetDescription(const std::string &description)
virtual std::vector< itk::SmartPointer< BaseData > > Read() override
Reads a path or stream and creates a list of BaseData objects.
virtual ~LegacyFileReaderService()
void AddExtension(const std::string &extension)
LegacyFileReaderService(const LegacyFileReaderService &other)
void SetCategory(const std::string &category)
Base class for creating mitk::BaseData objects from files or streams.