Medical Imaging Interaction Toolkit  2026.06.00
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 
81  {
82  public:
88 
94  us::Any GetReaderOption(const std::string &name) const;
95 
100  void SetReaderOptions(const Options &options);
101 
107  void SetReaderOption(const std::string &name, const us::Any &value);
108 
114 
120  us::Any GetWriterOption(const std::string &name) const;
121 
126  void SetWriterOptions(const Options &options);
127 
133  void SetWriterOption(const std::string &name, const us::Any &value);
134 
140 
146 
157  std::pair<us::ServiceRegistration<IFileReader>, us::ServiceRegistration<IFileWriter>> RegisterService(
159 
160  protected:
166 
171  AbstractFileIO(const std::string &baseDataType);
172 
187  explicit AbstractFileIO(const std::string &baseDataType,
188  const CustomMimeType &mimeType,
189  const std::string &description);
190 
195  void SetMimeType(const CustomMimeType &mimeType);
196 
202  const CustomMimeType *GetMimeType() const;
203 
208  void SetReaderDescription(const std::string &description);
209 
214  std::string GetReaderDescription() const;
215 
220  void SetWriterDescription(const std::string &description);
221 
226  std::string GetWriterDescription() const;
227 
232  void SetDefaultReaderOptions(const Options &defaultOptions);
233 
239 
244  void SetDefaultWriterOptions(const Options &defaultOptions);
245 
251 
259  void SetReaderRanking(int ranking);
260 
265  int GetReaderRanking() const;
266 
271  void SetWriterRanking(int ranking);
272 
277  int GetWriterRanking() const;
278 
279  private:
280  AbstractFileIO &operator=(const AbstractFileIO &other);
281 
282  virtual AbstractFileIO *IOClone() const = 0;
283 
284  IFileReader *ReaderClone() const override;
285  IFileWriter *WriterClone() const override;
286  };
287 }
288 
289 #endif
#define MITKCORE_EXPORT
virtual ConfidenceLevel GetReaderConfidenceLevel() const
ConfidenceLevel GetConfidenceLevel() const override
Get the confidence level of this reader or writer for the current input.
AbstractFileIOReader(const CustomMimeType &mimeType, const std::string &description)
Abstract base class for implementing a combined file reader and writer.
AbstractFileIO(const std::string &baseDataType)
Construct with a BaseData type name only.
ConfidenceLevel GetReaderConfidenceLevel() const override
Get the reader confidence level for the current input.
std::pair< us::ServiceRegistration< IFileReader >, us::ServiceRegistration< IFileWriter > > RegisterService(us::ModuleContext *context=us::GetModuleContext())
Register both reader and writer as CppMicroServices services.
void SetReaderDescription(const std::string &description)
Set the description for the reader part.
void SetWriterDescription(const std::string &description)
Set the description for the writer part.
std::string GetWriterDescription() const
Get the description of the writer part.
Options GetDefaultReaderOptions() const
Get the default options for the reader part.
std::string GetReaderDescription() const
Get the description of the reader part.
void SetWriterRanking(int ranking)
Set the service ranking for the writer part.
void SetWriterOption(const std::string &name, const us::Any &value)
Set a single writer option.
int GetWriterRanking() const
Get the service ranking for the writer part.
Options GetReaderOptions() const
Get the reader-specific options.
AbstractFileIO(const AbstractFileIO &other)
Copy constructor.
int GetReaderRanking() const
Get the service ranking for the reader part.
AbstractFileIO(const std::string &baseDataType, const CustomMimeType &mimeType, const std::string &description)
Construct with a BaseData type, MIME type, and description.
void SetReaderOption(const std::string &name, const us::Any &value)
Set a single reader option.
void SetReaderOptions(const Options &options)
Set multiple reader options at once.
void SetWriterOptions(const Options &options)
Set multiple writer options at once.
Options GetDefaultWriterOptions() const
Get the default options for the writer part.
void SetDefaultWriterOptions(const Options &defaultOptions)
Set default options for the writer part.
us::Any GetWriterOption(const std::string &name) const
Get the value of a specific writer option.
void SetMimeType(const CustomMimeType &mimeType)
Set the shared MIME type for both reader and writer.
ConfidenceLevel GetWriterConfidenceLevel() const override
Get the writer confidence level for the current input data.
us::Any GetReaderOption(const std::string &name) const
Get the value of a specific reader option.
void SetDefaultReaderOptions(const Options &defaultOptions)
Set default options for the reader part.
Options GetWriterOptions() const
Get the writer-specific options.
void SetReaderRanking(int ranking)
Set the service ranking for the reader part.
const CustomMimeType * GetMimeType() const
Get the shared MIME type.
Base class for creating mitk::BaseData objects from files or streams.
ConfidenceLevel GetConfidenceLevel() const override
Determine confidence for reading the current input.
Base class for writing mitk::BaseData objects to files or streams.
ConfidenceLevel GetConfidenceLevel() const override
Determine confidence for writing the current input data.
A custom mime-type that can be registered as a service object.
An Any class represents a general type and is capable of storing any type, supporting type-safe extra...
Definition: usAny.h:145
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Find image slices visible on a given plane.
virtual ConfidenceLevel GetWriterConfidenceLevel() const
AbstractFileIOWriter(const std::string &baseDataType, const CustomMimeType &mimeType, const std::string &description)
ConfidenceLevel GetConfidenceLevel() const override
Get the confidence level of this reader or writer for the current input.
AbstractFileIOWriter(const std::string &baseDataType)
ConfidenceLevel
A confidence level describing the reader's or writer's ability to handle the given data or file forma...
Definition: mitkIFileIO.h:57
std::map< std::string, us::Any > Options
Options for reading or writing data.
Definition: mitkIFileIO.h:80
The common interface for all MITK file readers.
The common interface of all MITK file writers.