Medical Imaging Interaction Toolkit  2018.4.99-1640525a
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 
92  us::ServiceRegistration<IFileReader> RegisterService(us::ModuleContext *context = us::GetModuleContext());
93  void UnregisterService();
94 
98  std::vector< std::string > GetReadFiles() override;
99 
100  protected:
109  class MITKCORE_EXPORT InputStream : public std::istream
110  {
111  public:
112  InputStream(IFileReader *writer, std::ios_base::openmode mode = std::ios_base::in);
113  ~InputStream() override;
114 
115  private:
116  std::istream *m_Stream;
117  };
118 
120  ~AbstractFileReader() override;
121 
123 
140  explicit AbstractFileReader(const CustomMimeType &mimeType, const std::string &description);
141 
157  virtual std::vector<itk::SmartPointer<BaseData>> DoRead() = 0;
158 
159 
160  virtual us::ServiceProperties GetServiceProperties() const;
161 
175  virtual us::ServiceRegistration<CustomMimeType> RegisterMimeType(us::ModuleContext *context);
176 
177  void SetMimeType(const CustomMimeType &mimeType);
178 
182  const CustomMimeType *GetMimeType() const;
183 
184  void SetMimeTypePrefix(const std::string &prefix);
185  std::string GetMimeTypePrefix() const;
186 
187  void SetDescription(const std::string &description);
188  std::string GetDescription() const;
189 
190  void SetDefaultOptions(const Options &defaultOptions);
191  Options GetDefaultOptions() const;
192 
203  void SetRanking(int ranking);
204  int GetRanking() const;
205 
224  std::string GetLocalFileName() const;
225 
226  virtual void SetDefaultDataNodeProperties(DataNode *node, const std::string &filePath);
227 
228  std::vector< std::string > m_ReadFiles;
229 
230  private:
231  AbstractFileReader &operator=(const AbstractFileReader &other);
232 
233  virtual mitk::IFileReader *Clone() const = 0;
234 
235  class Impl;
236  std::unique_ptr<Impl> d;
237  };
238 
239 } // namespace mitk
240 
241 #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
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244
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