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