Medical Imaging Interaction Toolkit  2022.10.99-fe4dd45b
Medical Imaging Interaction Toolkit
mitkAbstractFileIO.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 (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 #ifndef MITKABSTRACTFILEIO_H
14 #define MITKABSTRACTFILEIO_H
15 
16 #include "mitkAbstractFileReader.h"
17 #include "mitkAbstractFileWriter.h"
18 
19 namespace mitk
20 {
21 #ifndef DOXYGEN_SKIP
22 
23  // Skip this code during Doxygen processing, because it only
24  // exists to resolve name clashes when inheriting from both
25  // AbstractFileReader and AbstractFileWriter.
26 
28  {
29  public:
31  ConfidenceLevel GetConfidenceLevel() const override { return this->GetReaderConfidenceLevel(); }
32  protected:
34  AbstractFileIOReader(const CustomMimeType &mimeType, const std::string &description)
35  : AbstractFileReader(mimeType, description)
36  {
37  }
38 
39  private:
40  virtual IFileReader *ReaderClone() const = 0;
41  IFileReader *Clone() const override { return ReaderClone(); }
42  };
43 
45  {
47  ConfidenceLevel GetConfidenceLevel() const override { return this->GetWriterConfidenceLevel(); }
48  protected:
49  AbstractFileIOWriter(const std::string &baseDataType) : AbstractFileWriter(baseDataType) {}
50  AbstractFileIOWriter(const std::string &baseDataType,
51  const CustomMimeType &mimeType,
52  const std::string &description)
53  : AbstractFileWriter(baseDataType, mimeType, description)
54  {
55  }
56 
57  private:
58  virtual IFileWriter *WriterClone() const = 0;
59  IFileWriter *Clone() const override { return WriterClone(); }
60  };
61 
62 #endif // DOXYGEN_SKIP
63 
70  {
71  public:
72  Options GetReaderOptions() const;
73  us::Any GetReaderOption(const std::string &name) const;
74 
75  void SetReaderOptions(const Options &options);
76  void SetReaderOption(const std::string &name, const us::Any &value);
77 
78  Options GetWriterOptions() const;
79  us::Any GetWriterOption(const std::string &name) const;
80 
81  void SetWriterOptions(const Options &options);
82  void SetWriterOption(const std::string &name, const us::Any &value);
83 
84  ConfidenceLevel GetReaderConfidenceLevel() const override;
85 
86  ConfidenceLevel GetWriterConfidenceLevel() const override;
87 
88  std::pair<us::ServiceRegistration<IFileReader>, us::ServiceRegistration<IFileWriter>> RegisterService(
89  us::ModuleContext *context = us::GetModuleContext());
90 
91  protected:
92  AbstractFileIO(const AbstractFileIO &other);
93 
94  AbstractFileIO(const std::string &baseDataType);
95 
110  explicit AbstractFileIO(const std::string &baseDataType,
111  const CustomMimeType &mimeType,
112  const std::string &description);
113 
114  void SetMimeType(const CustomMimeType &mimeType);
115 
119  const CustomMimeType *GetMimeType() const;
120 
121  void SetReaderDescription(const std::string &description);
122  std::string GetReaderDescription() const;
123 
124  void SetWriterDescription(const std::string &description);
125  std::string GetWriterDescription() const;
126 
127  void SetDefaultReaderOptions(const Options &defaultOptions);
128  Options GetDefaultReaderOptions() const;
129 
130  void SetDefaultWriterOptions(const Options &defaultOptions);
131  Options GetDefaultWriterOptions() const;
132 
143  void SetReaderRanking(int ranking);
144  int GetReaderRanking() const;
145 
146  void SetWriterRanking(int ranking);
147  int GetWriterRanking() const;
148 
149  private:
150  AbstractFileIO &operator=(const AbstractFileIO &other);
151 
152  virtual AbstractFileIO *IOClone() const = 0;
153 
154  IFileReader *ReaderClone() const override;
155  IFileWriter *WriterClone() const override;
156  };
157 }
158 
159 #endif // MITKABSTRACTFILEIO_H
mitk::AbstractFileReader::GetConfidenceLevel
ConfidenceLevel GetConfidenceLevel() const override
The confidence level of the reader or writer implementation.
mitk::IFileIO::Options
std::map< std::string, us::Any > Options
Options for reading or writing data.
Definition: mitkIFileIO.h:69
mitk::AbstractFileIOWriter::AbstractFileIOWriter
AbstractFileIOWriter(const std::string &baseDataType, const CustomMimeType &mimeType, const std::string &description)
Definition: mitkAbstractFileIO.h:50
mitk::AbstractFileIOReader::GetReaderConfidenceLevel
virtual ConfidenceLevel GetReaderConfidenceLevel() const
Definition: mitkAbstractFileIO.h:30
mitkAbstractFileWriter.h
mitk::AbstractFileReader
Base class for creating mitk::BaseData objects from files or streams.
Definition: mitkAbstractFileReader.h:42
mitk::CustomMimeType
The CustomMimeType class represents a custom mime-type which may be registered as a service object....
Definition: mitkCustomMimeType.h:44
us::GetModuleContext
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Definition: usGetModuleContext.h:50
mitk::AbstractFileIOWriter::GetWriterConfidenceLevel
virtual ConfidenceLevel GetWriterConfidenceLevel() const
Definition: mitkAbstractFileIO.h:46
mitk::AbstractFileIOWriter::AbstractFileIOWriter
AbstractFileIOWriter(const std::string &baseDataType)
Definition: mitkAbstractFileIO.h:49
mitk::AbstractFileWriter
Base class for writing mitk::BaseData objects to files or streams.
Definition: mitkAbstractFileWriter.h:50
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::IFileReader
The common interface for all MITK file readers.
Definition: mitkIFileReader.h:61
mitk::AbstractFileIOReader::GetConfidenceLevel
ConfidenceLevel GetConfidenceLevel() const override
The confidence level of the reader or writer implementation.
Definition: mitkAbstractFileIO.h:31
mitk::IFileWriter
The common interface of all MITK file writers.
Definition: mitkIFileWriter.h:56
us::Any
Definition: usAny.h:163
mitk::AbstractFileWriter::GetConfidenceLevel
ConfidenceLevel GetConfidenceLevel() const override
The confidence level of the reader or writer implementation.
mitkAbstractFileReader.h
mitk::AbstractFileIOReader::AbstractFileIOReader
AbstractFileIOReader(const CustomMimeType &mimeType, const std::string &description)
Definition: mitkAbstractFileIO.h:34
mitk::AbstractFileIOWriter
Definition: mitkAbstractFileIO.h:44
mitk::AbstractFileIOWriter::GetConfidenceLevel
ConfidenceLevel GetConfidenceLevel() const override
The confidence level of the reader or writer implementation.
Definition: mitkAbstractFileIO.h:47
mitk::AbstractFileIOReader
Definition: mitkAbstractFileIO.h:27
mitk::IFileIO::ConfidenceLevel
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data.
Definition: mitkIFileIO.h:45
us::ServiceRegistration
Definition: usServiceRegistration.h:48
mitk::AbstractFileIO
Abstract class for implementing a reader and writer.
Definition: mitkAbstractFileIO.h:69
mitk::AbstractFileIOReader::AbstractFileIOReader
AbstractFileIOReader()
Definition: mitkAbstractFileIO.h:33
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15