20 #include "itksys/SystemTools.hxx"
28 "Default writer for the example data structure")
50 MITK_INFO <<
"Writing ExampleDataStructure";
54 MITK_ERROR <<
"Sorry, input to ExampleDataStructureWriterService is NULL!";
57 if (this->GetOutputLocation().empty())
59 MITK_ERROR <<
"Sorry, filename has not been set!";
63 std::string ext = itksys::SystemTools::GetFilenameLastExtension(this->GetOutputLocation());
64 ext = itksys::SystemTools::LowerCase(ext);
70 this->SetOutputLocation(this->GetOutputLocation() + ext);
75 std::ofstream file(this->GetOutputLocation());
79 file << input->GetData();
83 mitkThrow() <<
"Could not open file " << this->GetOutputLocation() <<
" for writing.";
86 MITK_INFO <<
"Example Data Structure has been written";
95 MITK_ERROR <<
"Unknown error occurred while trying to write file.";
ExampleDataStructureWriterService()
virtual void Write() override
Write the base data to the specified location or output stream.
DataCollection - Class to facilitate loading/accessing structured data.
virtual ~ExampleDataStructureWriterService()
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
static const char * GetStaticNameOfClass()
virtual mitk::ExampleDataStructureWriterService * Clone() const override
us::ServiceRegistration< IFileWriter > RegisterService(us::ModuleContext *context=us::GetModuleContext())
Base class for writing mitk::BaseData objects to files or streams.