diff --git a/Modules/Core/include/mitkIOAdapter.h b/Modules/Core/include/mitkIOAdapter.h index 8017f263d2..e8632e4db1 100644 --- a/Modules/Core/include/mitkIOAdapter.h +++ b/Modules/Core/include/mitkIOAdapter.h @@ -1,99 +1,99 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkIOAdapter_h #define __mitkIOAdapter_h #include "mitkBaseProcess.h" #include "itkObject.h" namespace mitk { /** * @brief IOAdapterBase class is an abstract adapter class for IO process objects. * * @ingroup DeprecatedIO * @deprecatedSince{2014_10} Use mitk::IFileReader instead */ class IOAdapterBase: public itk::Object { public: /** Standard typedefs. */ typedef IOAdapterBase Self; typedef itk::Object Superclass; typedef itk::SmartPointerPointer; typedef itk::SmartPointerConstPointer; /// Create an object and return a pointer to it as a mitk::BaseProcess. virtual itk::SmartPointer CreateIOProcessObject(const std::string filename, const std::string filePrefix, const std::string filePattern) = 0; virtual bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern) = 0; protected: IOAdapterBase() {} ~IOAdapterBase() {} private: IOAdapterBase(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; /** * @brief IOAdapter class is an adapter class for instantiation of IO process objects. * Additional this interface defines the function CanReadFile(). * This interface allows the target (object) the access to the adaptee (IO process object). * * @ingroup IO * @deprecatedSince{2014_10} Use mitk::IFileReader instead */ template class IOAdapter : public IOAdapterBase { public: /** Standard class typedefs. */ typedef IOAdapter Self; typedef itk::SmartPointer Pointer; /** Methods from mitk::BaseProcess. */ itkFactorylessNewMacro(Self); - mitk::BaseProcess::Pointer CreateIOProcessObject(const std::string filename, const std::string filePrefix, const std::string filePattern) + mitk::BaseDataSource::Pointer CreateIOProcessObject(const std::string filename, const std::string filePrefix, const std::string filePattern) { typename T::Pointer ioProcessObject = T::New(); ioProcessObject->SetFileName(filename.c_str()); ioProcessObject->SetFilePrefix(filePrefix.c_str()); ioProcessObject->SetFilePattern(filePattern.c_str()); return ioProcessObject.GetPointer(); } virtual bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern) { return T::CanReadFile(filename, filePrefix, filePattern); } protected: IOAdapter() {} ~IOAdapter() {} private: IOAdapter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Modules/Core/src/IO/mitkLegacyFileReaderService.cpp b/Modules/Core/src/IO/mitkLegacyFileReaderService.cpp index 870114d0cb..f6c1a82a24 100644 --- a/Modules/Core/src/IO/mitkLegacyFileReaderService.cpp +++ b/Modules/Core/src/IO/mitkLegacyFileReaderService.cpp @@ -1,126 +1,126 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkLegacyFileReaderService.h" #include #include #include #include #include mitk::LegacyFileReaderService::LegacyFileReaderService(const mitk::LegacyFileReaderService& other) : mitk::AbstractFileReader(other) { } mitk::LegacyFileReaderService::LegacyFileReaderService(const std::vector& extensions, const std::string& category) : AbstractFileReader() { this->SetMimeTypePrefix(IOMimeTypes::DEFAULT_BASE_NAME() + ".legacy."); CustomMimeType customMimeType; customMimeType.SetCategory(category); for(std::vector::const_iterator iter = extensions.begin(), endIter = extensions.end(); iter != endIter; ++iter) { std::string extension = *iter; if (!extension.empty() && extension[0] == '.') { extension.assign(extension.begin()+1, extension.end()); } customMimeType.AddExtension(extension); } this->SetDescription(category); this->SetMimeType(customMimeType); m_ServiceReg = this->RegisterService(); } mitk::LegacyFileReaderService::~LegacyFileReaderService() { } ////////////////////// Reading ///////////////////////// std::vector > mitk::LegacyFileReaderService::Read() { std::vector result; std::list possibleIOAdapter; std::list allobjects = itk::ObjectFactoryBase::CreateAllInstance("mitkIOAdapter"); for( std::list::iterator i = allobjects.begin(); i != allobjects.end(); ++i) { IOAdapterBase* io = dynamic_cast(i->GetPointer()); if(io) { possibleIOAdapter.push_back(io); } else { MITK_ERROR << "Error BaseDataIO factory did not return an IOAdapterBase: " << (*i)->GetNameOfClass() << std::endl; } } const std::string path = this->GetLocalFileName(); for( std::list::iterator k = possibleIOAdapter.begin(); k != possibleIOAdapter.end(); ++k ) { bool canReadFile = (*k)->CanReadFile(path, "", ""); // they could read the file if( canReadFile ) { - BaseProcess::Pointer ioObject = (*k)->CreateIOProcessObject(path, "", ""); + BaseDataSource::Pointer ioObject = (*k)->CreateIOProcessObject(path, "", ""); ioObject->Update(); int numberOfContents = static_cast(ioObject->GetNumberOfOutputs()); if (numberOfContents > 0) { BaseData::Pointer baseData; for(int i=0; i(ioObject->GetOutputs()[i].GetPointer()); if (baseData) // this is what's wanted, right? { result.push_back( baseData ); } } } break; } } if (result.empty()) { mitkThrow() << "Could not read file '" << path << "'"; } return result; } mitk::LegacyFileReaderService* mitk::LegacyFileReaderService::Clone() const { return new LegacyFileReaderService(*this); }