Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkFileWriter.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef FILEWRITER_H_HEADER_INCLUDED
18 #define FILEWRITER_H_HEADER_INCLUDED
19 
20 #include <MitkCoreExports.h>
21 #include <itkProcessObject.h>
22 #include <mitkDataNode.h>
23 
24 namespace mitk
25 {
26  //##Documentation
27  //## @brief Interface class of writers that write data to files
28  //## @ingroup DeprecatedIO
29  //## @deprecatedSince{2014_10} Use mitk::IFileWriter instead.
30  class MITKCORE_EXPORT FileWriter : public itk::ProcessObject
31  {
32  public:
33  mitkClassMacroItkParent(FileWriter, itk::ProcessObject);
34  //##Documentation
35  //## @brief Get the specified the file to write
36  //##
37  //## Either the FileName or FilePrefix plus FilePattern are used to write.
38  virtual const char *GetFileName() const = 0;
39 
40  //##Documentation
41  //## @brief Specify the file to write.
42  //##
43  //## Either the FileName or FilePrefix plus FilePattern are used to write.
44  virtual void SetFileName(const char *aFileName) = 0;
45 
46  //##Documentation
47  //## @brief Get the specified file prefix for the file(s) to write.
48  //##
49  //## You should specify either a FileName or FilePrefix. Use FilePrefix if
50  //## the data is stored in multiple files.
51  virtual const char *GetFilePrefix() const = 0;
52 
53  //##Documentation
54  //## @brief Specify file prefix for the file(s) to write.
55  //##
56  //## You should specify either a FileName or FilePrefix. Use FilePrefix if
57  //## the data is stored in multiple files.
58  virtual void SetFilePrefix(const char *aFilePrefix) = 0;
59 
60  //##Documentation
61  //## @brief Get the specified file pattern for the file(s) to write. The
62  //## sprintf format used to build filename from FilePrefix and number.
63  //##
64  //## You should specify either a FileName or FilePrefix. Use FilePrefix if
65  //## the data is stored in multiple files.
66  virtual const char *GetFilePattern() const = 0;
67 
68  //##Documentation
69  //## @brief Specified file pattern for the file(s) to write. The sprintf
70  //## format used to build filename from FilePrefix and number.
71  //##
72  //## You should specify either a FileName or FilePrefix. Use FilePrefix if
73  //## the data is stored in multiple files.
74  virtual void SetFilePattern(const char *aFilePattern) = 0;
75 
76  //##Documentation
77  //## @brief Return the extension to be added to the filename.
78  virtual std::string GetFileExtension();
79 
80  //##Documentation
81  //## @brief Checks if given extension is valid for file writer
82  bool IsExtensionValid(std::string extension);
83 
84  //##Documentation
85  //## @brief Return the possible file extensions for the data type associated with the writer
86  virtual std::vector<std::string> GetPossibleFileExtensions() = 0;
87 
88  //##Documentation
89  //## @brief possible file extensions for the data type associated with the writer as string
90  virtual std::string GetPossibleFileExtensionsAsString();
91 
92  //##Documentation
93  //## @brief Check if the Writer can write this type of data of the
94  //## DataTreenode.
95  virtual bool CanWriteDataType(DataNode *);
96 
97  //##Documentation
98  //## @brief Return the MimeType of the saved File.
99  virtual std::string GetWritenMIMEType();
100 
101  virtual std::string GetSupportedBaseData() const = 0;
102 
103  using ProcessObject::SetInput;
104  void SetInput(BaseData *data);
105 
106  virtual void Write() = 0;
107 
111  virtual bool CanWriteToMemory();
112 
116  virtual void SetWriteToMemory(bool write);
117  virtual bool GetWriteToMemory();
118 
122  virtual const char *GetMemoryPointer();
123 
127  virtual unsigned int GetMemorySize();
128 
132  virtual void ReleaseMemory();
133 
134  protected:
135  FileWriter();
136  virtual ~FileWriter();
137 
141  unsigned int m_MemoryBufferSize;
142  };
143 
144 #define mitkWriterMacro \
145  \
146  virtual void Write() override \
147  \
148  { \
149  if (this->GetInput() == NULL) \
150  \
151  { \
152  itkExceptionMacro(<< "Write:Please specify an input!"); \
153  return; \
154  } \
155  /* Fill in image information.*/ \
156  this->UpdateOutputInformation(); \
157  (*(this->GetInputs().begin()))->SetRequestedRegionToLargestPossibleRegion(); \
158  this->PropagateRequestedRegion(NULL); \
159  this->UpdateOutputData(NULL); \
160  } \
161  \
162  virtual void Update() override { Write(); }
163 } // namespace mitk
164 #endif /* FILEWRITER_H_HEADER_INCLUDED */
#define MITKCORE_EXPORT
Base of all data objects.
Definition: mitkBaseData.h:39
unsigned int m_MemoryBufferSize
DataCollection - Class to facilitate loading/accessing structured data.
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
Interface class of writers that write data to files.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66