Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkFileWriter.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkFileWriter.h"
14 
16 {
17  // TODO #345 check for writing permission
18  if (node == nullptr || node->GetData() == nullptr)
19  return false;
20  return node->GetData()->GetNameOfClass() == this->GetSupportedBaseData();
21 }
22 
24 {
25  return "";
26 }
27 
29 {
30  this->SetNthInput(0, data);
31 }
32 
34 {
35  return "";
36 }
37 
39 {
40  std::vector<std::string> possibleFileExtensions = this->GetPossibleFileExtensions();
41  std::stringstream stream;
42  for (unsigned int i = 0; i < possibleFileExtensions.size() - 1; i++)
43  {
44  stream << "*" << possibleFileExtensions.at(i) << " ";
45  }
46  stream << "*" << possibleFileExtensions.at(possibleFileExtensions.size() - 1);
47  return stream.str();
48 }
49 
50 bool mitk::FileWriter::IsExtensionValid(std::string extension)
51 {
52  std::vector<std::string> possibleFileExtensions = this->GetPossibleFileExtensions();
53  for (unsigned int i = 0; i < possibleFileExtensions.size(); i++)
54  {
55  if (strcmp(extension.c_str(), possibleFileExtensions.at(i).c_str()) == 0)
56  return true;
57  }
58  return false;
59 }
60 
62 {
63 }
64 
66 {
67 }
68 
70 {
71  return m_CanWriteToMemory;
72 }
74 {
75  m_WriteToMemory = write;
76 }
78 {
79  return m_WriteToMemory;
80 }
82 {
83  return (const char *)m_MemoryBuffer;
84 }
86 {
87  return m_MemoryBufferSize;
88 }
90 {
91  // do nothing here
92 }
bool IsExtensionValid(std::string extension)
Checks if given extension is valid for file writer.
~FileWriter() override
Base of all data objects.
Definition: mitkBaseData.h:37
unsigned int m_MemoryBufferSize
virtual void SetWriteToMemory(bool write)
Set/Get functions to advise the file writer to use tis internal memory array as file writing destinat...
virtual bool CanWriteDataType(DataNode *)
Check if the Writer can write this type of data of the DataTreenode.
virtual std::string GetPossibleFileExtensionsAsString()
possible file extensions for the data type associated with the writer as string
void SetInput(BaseData *data)
virtual std::string GetFileExtension()
Return the extension to be added to the filename.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
virtual const char * GetMemoryPointer()
To be used along with a call of SetWriteToMemory(true). This returns the memory buffer where the file...
virtual unsigned int GetMemorySize()
To be used along with a call of SetWriteToMemory(true). This returns the size of the memory buffer wh...
virtual void ReleaseMemory()
CAUTION: It&#39;s up to the user to call this function to release the memory buffer after use in case the...
virtual std::string GetWritenMIMEType()
Return the MimeType of the saved File.
virtual bool CanWriteToMemory()
Specifies, whether the file writer also can write a file to a memory buffer.
virtual bool GetWriteToMemory()
virtual std::string GetSupportedBaseData() const =0
virtual std::vector< std::string > GetPossibleFileExtensions()=0
Return the possible file extensions for the data type associated with the writer. ...
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57