Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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 
71  std::vector<itk::SmartPointer<BaseData>> Read() override = 0;
72 
73  DataStorage::SetOfObjects::Pointer Read(mitk::DataStorage &ds) override;
74 
75  ConfidenceLevel GetConfidenceLevel() const override;
76 
77  Options GetOptions() const override;
78  us::Any GetOption(const std::string &name) const override;
79 
80  void SetOptions(const Options &options) override;
81  void SetOption(const std::string &name, const us::Any &value) override;
82 
83  void AddProgressCallback(const ProgressCallback &callback) override;
84 
85  void RemoveProgressCallback(const ProgressCallback &callback) override;
86 
101  us::ServiceRegistration<IFileReader> RegisterService(us::ModuleContext *context = us::GetModuleContext());
102  void UnregisterService();
103 
107  std::vector< std::string > GetReadFiles() override;
108 
109  protected:
118  class MITKCORE_EXPORT InputStream : public std::istream
119  {
120  public:
121  InputStream(IFileReader *writer, std::ios_base::openmode mode = std::ios_base::in);
122  ~InputStream() override;
123 
124  private:
125  std::istream *m_Stream;
126  };
127 
129  ~AbstractFileReader() override;
130 
132 
149  explicit AbstractFileReader(const CustomMimeType &mimeType, const std::string &description);
150 
151  virtual us::ServiceProperties GetServiceProperties() const;
152 
166  virtual us::ServiceRegistration<CustomMimeType> RegisterMimeType(us::ModuleContext *context);
167 
168  void SetMimeType(const CustomMimeType &mimeType);
169 
173  const CustomMimeType *GetMimeType() const;
174 
175  void SetMimeTypePrefix(const std::string &prefix);
176  std::string GetMimeTypePrefix() const;
177 
178  void SetDescription(const std::string &description);
179  std::string GetDescription() const;
180 
181  void SetDefaultOptions(const Options &defaultOptions);
182  Options GetDefaultOptions() const;
183 
194  void SetRanking(int ranking);
195  int GetRanking() const;
196 
215  std::string GetLocalFileName() const;
216 
217  virtual void SetDefaultDataNodeProperties(DataNode *node, const std::string &filePath);
218 
219  std::vector< std::string > m_ReadFiles;
220 
221  private:
222  AbstractFileReader &operator=(const AbstractFileReader &other);
223 
224  virtual mitk::IFileReader *Clone() const = 0;
225 
226  class Impl;
227  std::unique_ptr<Impl> d;
228  };
229 
230 } // namespace mitk
231 
232 #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 mitk::PlanarFigure::Pointer Clone(mitk::PlanarFigure::Pointer original)
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64