diff --git a/Core/Code/IO/mitkLegacyFileWriterService.cpp b/Core/Code/IO/mitkLegacyFileWriterService.cpp index 44a2c495d4..8dfab80a78 100644 --- a/Core/Code/IO/mitkLegacyFileWriterService.cpp +++ b/Core/Code/IO/mitkLegacyFileWriterService.cpp @@ -1,69 +1,65 @@ /*=================================================================== 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 #include #include mitk::LegacyFileWriterService::LegacyFileWriterService(mitk::FileWriter::Pointer legacyWriter, const std::string& basedataType, const std::string& extension, const std::string& description) : AbstractFileWriter(basedataType, extension, description) , m_LegacyWriter(legacyWriter) { if (extension.empty()) mitkThrow() << "LegacyFileWriterWrapper cannot be initialized without FileExtension." ; RegisterService(); } ////////////////////// Writing ///////////////////////// void mitk::LegacyFileWriterService::Write(const BaseData* data, const std::string& path) { if (m_LegacyWriter.IsNull()) mitkThrow() << "LegacyFileWriterService was incorrectly initialized: Has no LegacyFileWriter."; m_LegacyWriter->SetFileName(path.c_str()); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(const_cast(data)); m_LegacyWriter->SetInput(node); m_LegacyWriter->Write(); } void mitk::LegacyFileWriterService::Write(const BaseData* /*data*/, std::ostream& /*stream*/ ) { mitkThrow () << "Streaming is not supported in Legacy Wrappers."; //return 0; } -bool mitk::LegacyFileWriterService::CanWrite(const BaseData* data, const std::string& path) const +bool mitk::LegacyFileWriterService::CanWrite(const BaseData* data) const { - // Default implementation only checks if extension and basedatatype are correct - std::string pathEnd = path.substr( path.length() - m_Extension.length(), m_Extension.length() ); - if ( !(m_Extension == pathEnd)) return false; - std::string externalDataType = data->GetNameOfClass(); return (externalDataType == m_BasedataType); } mitk::LegacyFileWriterService* mitk::LegacyFileWriterService::Clone() const { return new LegacyFileWriterService(*this); } diff --git a/Core/Code/IO/mitkLegacyFileWriterService.h b/Core/Code/IO/mitkLegacyFileWriterService.h index 44ee1bac9e..5c5e292074 100644 --- a/Core/Code/IO/mitkLegacyFileWriterService.h +++ b/Core/Code/IO/mitkLegacyFileWriterService.h @@ -1,61 +1,61 @@ /*=================================================================== 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 LegacyFileWriterService_H_HEADER_INCLUDED_C1E7E521 #define LegacyFileWriterService_H_HEADER_INCLUDED_C1E7E521 // Macro #include // MITK #include #include namespace mitk { //##Documentation //## @brief //## @ingroup Process class LegacyFileWriterService : public mitk::AbstractFileWriter { public: LegacyFileWriterService(mitk::FileWriter::Pointer legacyWriter, const std::string& basedataType, const std::string& extension, const std::string& description); using AbstractFileWriter::Write; virtual void Write(const BaseData* data, const std::string& path); virtual void Write(const BaseData* data, std::ostream& stream ); - virtual bool CanWrite(const BaseData* data, const std::string& path) const; + virtual bool CanWrite(const BaseData* data) const; protected: mitk::FileWriter::Pointer m_LegacyWriter; private: LegacyFileWriterService* Clone() const; }; } // namespace mitk #endif /* LegacyFileWriterService_H_HEADER_INCLUDED_C1E7E521 */