Medical Imaging Interaction Toolkit  2016.11.0
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,
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 AbstractFileReader_H_HEADER_INCLUDED_C1E7E521
18 #define AbstractFileReader_H_HEADER_INCLUDED_C1E7E521
19 
20 // Macro
21 #include <MitkCoreExports.h>
22 
23 // MITK
24 #include <mitkBaseData.h>
25 #include <mitkIFileReader.h>
26 #include <mitkMimeType.h>
27 
28 // Microservices
29 #include <usGetModuleContext.h>
30 #include <usServiceProperties.h>
31 #include <usServiceRegistration.h>
32 
33 namespace us
34 {
36 }
37 
38 namespace mitk
39 {
40  class CustomMimeType;
41 
47  {
48  public:
49  virtual void SetInput(const std::string &location) override;
50 
51  virtual void SetInput(const std::string &location, std::istream *is) override;
52 
53  virtual std::string GetInputLocation() const override;
54 
55  virtual std::istream *GetInputStream() const override;
56 
57  MimeType GetRegisteredMimeType() const;
58 
75  virtual std::vector<itk::SmartPointer<BaseData>> Read() override = 0;
76 
77  virtual DataStorage::SetOfObjects::Pointer Read(mitk::DataStorage &ds) override;
78 
79  virtual ConfidenceLevel GetConfidenceLevel() const override;
80 
81  virtual Options GetOptions() const override;
82  virtual us::Any GetOption(const std::string &name) const override;
83 
84  virtual void SetOptions(const Options &options) override;
85  virtual void SetOption(const std::string &name, const us::Any &value) override;
86 
87  virtual void AddProgressCallback(const ProgressCallback &callback) override;
88 
89  virtual void RemoveProgressCallback(const ProgressCallback &callback) override;
90 
105  us::ServiceRegistration<IFileReader> RegisterService(us::ModuleContext *context = us::GetModuleContext());
106  void UnregisterService();
107 
108  protected:
117  class MITKCORE_EXPORT InputStream : public std::istream
118  {
119  public:
120  InputStream(IFileReader *writer, std::ios_base::openmode mode = std::ios_base::in);
121  ~InputStream();
122 
123  private:
124  std::istream *m_Stream;
125  };
126 
129 
131 
148  explicit AbstractFileReader(const CustomMimeType &mimeType, const std::string &description);
149 
150  virtual us::ServiceProperties GetServiceProperties() const;
151 
165  virtual us::ServiceRegistration<CustomMimeType> RegisterMimeType(us::ModuleContext *context);
166 
167  void SetMimeType(const CustomMimeType &mimeType);
168 
172  const CustomMimeType *GetMimeType() const;
173 
174  void SetMimeTypePrefix(const std::string &prefix);
175  std::string GetMimeTypePrefix() const;
176 
177  void SetDescription(const std::string &description);
178  std::string GetDescription() const;
179 
180  void SetDefaultOptions(const Options &defaultOptions);
181  Options GetDefaultOptions() const;
182 
193  void SetRanking(int ranking);
194  int GetRanking() const;
195 
214  std::string GetLocalFileName() const;
215 
216  virtual void SetDefaultDataNodeProperties(DataNode *node, const std::string &filePath);
217 
218  private:
219  AbstractFileReader &operator=(const AbstractFileReader &other);
220 
221  virtual mitk::IFileReader *Clone() const = 0;
222 
223  class Impl;
224  std::unique_ptr<Impl> d;
225  };
226 
227 } // namespace mitk
228 
229 #endif /* AbstractFileReader_H_HEADER_INCLUDED_C1E7E521 */
Data management class that handles 'was created by' relations.
itk::SmartPointer< Self > Pointer
Pointer Clone() const
#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:73
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
Definition: usAny.h:163
The MimeType class represens a registered mime-type. It is an immutable wrapper for mitk::CustomMimeT...
Definition: mitkMimeType.h:45
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.
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.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66