Medical Imaging Interaction Toolkit  2024.06.00
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 mitkAbstractFileReader_h
14 #define mitkAbstractFileReader_h
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  void SetProperties(const PropertyList* properties) 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  const PropertyList* GetProperties() const override;
229 
230  std::vector< std::string > m_ReadFiles;
231 
232  private:
233  AbstractFileReader &operator=(const AbstractFileReader &other);
234 
235  virtual mitk::IFileReader *Clone() const = 0;
236 
237  class Impl;
238  std::unique_ptr<Impl> d;
239  };
240 
241 } // namespace mitk
242 
243 #endif
us::ServiceProperties
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
Definition: usServiceProperties.h:42
usServiceProperties.h
mitk::DICOMIOHelper::SetProperties
MITKDICOM_EXPORT void SetProperties(BaseData *image, const FindingsListVectorType &findings)
mitk::IFileIO::Options
std::map< std::string, us::Any > Options
Options for reading or writing data.
Definition: mitkIFileIO.h:69
us
Definition: mitkAbstractFileReader.h:29
mitk::AbstractFileReader
Base class for creating mitk::BaseData objects from files or streams.
Definition: mitkAbstractFileReader.h:42
mitk::CustomMimeType
The CustomMimeType class represents a custom mime-type which may be registered as a service object....
Definition: mitkCustomMimeType.h:44
us::GetModuleContext
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Definition: usGetModuleContext.h:50
mitkMimeType.h
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::IFileReader
The common interface for all MITK file readers.
Definition: mitkIFileReader.h:61
us::Any
Definition: usAny.h:163
MitkCoreExports.h
mitk::MessageAbstractDelegate1
Definition: mitkMessage.h:93
mitkIFileReader.h
mitk::PropertyList
Key-value list holding instances of BaseProperty.
Definition: mitkPropertyList.h:56
usServiceRegistration.h
mitk::DataStorage
Data management class that handles 'was created by' relations.
Definition: mitkDataStorage.h:43
us::PrototypeServiceFactory
Definition: usPrototypeServiceFactory.h:59
mitkBaseData.h
usGetModuleContext.h
mitk::IFileIO::ConfidenceLevel
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data.
Definition: mitkIFileIO.h:45
us::ServiceRegistration
Definition: usServiceRegistration.h:48
mitk::AbstractFileReader::m_ReadFiles
std::vector< std::string > m_ReadFiles
Definition: mitkAbstractFileReader.h:230
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::AbstractFileReader::InputStream
An input stream wrapper.
Definition: mitkAbstractFileReader.h:109
mitk::MimeType
The MimeType class represents a registered mime-type. It is an immutable wrapper for mitk::CustomMime...
Definition: mitkMimeType.h:36