Medical Imaging Interaction Toolkit  2021.10.99-fd647480
Medical Imaging Interaction Toolkit
mitkAbstractFileReader.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 AbstractFileReader_H_HEADER_INCLUDED_C1E7E521
14 #define AbstractFileReader_H_HEADER_INCLUDED_C1E7E521
15 
16 // Macro
17 #include <MitkCoreExports.h>
18 
19 // MITK
20 #include <mitkBaseData.h>
21 #include <mitkIFileReader.h>
22 #include <mitkMimeType.h>
23 
24 // Microservices
25 #include <usGetModuleContext.h>
26 #include <usServiceProperties.h>
27 #include <usServiceRegistration.h>
28 
29 namespace us
30 {
32 }
33 
34 namespace mitk
35 {
36  class CustomMimeType;
37 
43  {
44  public:
45  void SetInput(const std::string &location) override;
46 
47  void SetInput(const std::string &location, std::istream *is) override;
48 
49  std::string GetInputLocation() const override;
50 
51  std::istream *GetInputStream() const override;
52 
53  MimeType GetRegisteredMimeType() const;
54 
62  std::vector<itk::SmartPointer<BaseData>> Read() override;
63 
64  DataStorage::SetOfObjects::Pointer Read(mitk::DataStorage &ds) override;
65 
66  ConfidenceLevel GetConfidenceLevel() const override;
67 
68  Options GetOptions() const override;
69  us::Any GetOption(const std::string &name) const override;
70 
71  void SetOptions(const Options &options) override;
72  void SetOption(const std::string &name, const us::Any &value) override;
73 
74  void AddProgressCallback(const ProgressCallback &callback) override;
75 
76  void RemoveProgressCallback(const ProgressCallback &callback) override;
77 
90  us::ServiceRegistration<IFileReader> RegisterService(us::ModuleContext *context = us::GetModuleContext());
91  void UnregisterService();
92 
96  std::vector< std::string > GetReadFiles() override;
97 
98  protected:
107  class MITKCORE_EXPORT InputStream : public std::istream
108  {
109  public:
110  InputStream(IFileReader *writer, std::ios_base::openmode mode = std::ios_base::in);
111  ~InputStream() override;
112 
113  private:
114  std::istream *m_Stream;
115  };
116 
118  ~AbstractFileReader() override;
119 
121 
138  explicit AbstractFileReader(const CustomMimeType &mimeType, const std::string &description);
139 
155  virtual std::vector<itk::SmartPointer<BaseData>> DoRead() = 0;
156 
157 
158  virtual us::ServiceProperties GetServiceProperties() const;
159 
173  virtual us::ServiceRegistration<CustomMimeType> RegisterMimeType(us::ModuleContext *context);
174 
175  void SetMimeType(const CustomMimeType &mimeType);
176 
180  const CustomMimeType *GetMimeType() const;
181 
182  void SetMimeTypePrefix(const std::string &prefix);
183  std::string GetMimeTypePrefix() const;
184 
185  void SetDescription(const std::string &description);
186  std::string GetDescription() const;
187 
188  void SetDefaultOptions(const Options &defaultOptions);
189  Options GetDefaultOptions() const;
190 
201  void SetRanking(int ranking);
202  int GetRanking() const;
203 
222  std::string GetLocalFileName() const;
223 
224  virtual void SetDefaultDataNodeProperties(DataNode *node, const std::string &filePath);
225 
226  std::vector< std::string > m_ReadFiles;
227 
228  private:
229  AbstractFileReader &operator=(const AbstractFileReader &other);
230 
231  virtual mitk::IFileReader *Clone() const = 0;
232 
233  class Impl;
234  std::unique_ptr<Impl> d;
235  };
236 
237 } // namespace mitk
238 
239 #endif /* AbstractFileReader_H_HEADER_INCLUDED_C1E7E521 */
Data management class that handles &#39;was created by&#39; relations.
#define MITKCORE_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
std::map< std::string, us::Any > Options
Options for reading or writing data.
Definition: mitkIFileIO.h:69
std::vector< std::string > m_ReadFiles
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
Definition: mitkIFileIO.h:45
Definition: usAny.h:163
The MimeType class represens a registered mime-type. It is an immutable wrapper for mitk::CustomMimeT...
Definition: mitkMimeType.h:36
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
Base class for creating mitk::BaseData objects from files or streams.
The common interface for all MITK file readers.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57