NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxFileReaderWriterService.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXFILEREADERWRITERSERVICE_H
13 #define CXFILEREADERWRITERSERVICE_H
14 
15 #include <QObject>
16 #include "cxResourceExport.h"
17 #include "boost/shared_ptr.hpp"
18 #include "cxData.h"
19 
20 #define FileReaderWriterService_iid "cx::FileReaderWriterService"
21 
22 class ctkPluginContext;
23 
24 namespace cx
25 {
26 
27 typedef boost::shared_ptr<class FileReaderWriterService> FileReaderWriterServicePtr;
28 
29 
30 class cxResource_EXPORT FileReaderWriterService : public QObject
31 {
32  Q_OBJECT
33 public:
34  static FileReaderWriterServicePtr getNullObject();
35 
37  virtual bool isNull() = 0;
38 
39  virtual QString getName() const = 0;
40  virtual QString getFileSuffix() const = 0;
41 
42  //reading
43  virtual QString canReadDataType() const = 0;
44  virtual bool canRead(const QString& type, const QString& filename) = 0;
45 
46  virtual std::vector<DataPtr> read(const QString& filename) = 0;
47 
48  //--- TODO REMOVE:
49  virtual DataPtr read(const QString& uid, const QString& filename) = 0;
50  virtual bool readInto(DataPtr data, QString path) = 0;
51  //---
52 
53  //writing
54  virtual QString canWriteDataType() const = 0;
55  virtual bool canWrite(const QString& type, const QString& filename) const = 0;
56  virtual void write(DataPtr data, const QString& filename) = 0;
57 
58  //utility
59  virtual vtkImageDataPtr loadVtkImageData(QString filename) = 0;
60  virtual vtkPolyDataPtr loadVtkPolyData(QString filename) = 0;
61 
62  //TODO add advanced options
63 };
64 }//cx
65 
67 //------------
68 
69 namespace cx
70 {
71 class cxResource_EXPORT FileReaderWriterImplService : public FileReaderWriterService
72 {
73 public:
74  Q_INTERFACES(cx::FileReaderWriterService)
75 
76  FileReaderWriterImplService(QString name, QString canReadDataType, QString canWriteDataType, QString fileSuffix, PatientModelServicePtr patientModelService);
77 
78  virtual QString getName() const;
79  virtual QString getFileSuffix() const;
80 
81  virtual vtkImageDataPtr loadVtkImageData(QString filename) { return vtkImageDataPtr(); }
82  virtual vtkPolyDataPtr loadVtkPolyData(QString filename) { return vtkPolyDataPtr(); }
83 
84 protected:
85  bool canReadInternal(const QString& type, const QString& filename) const;
86  bool canWriteInternal(const QString& type, const QString& filename) const;
87 
88  DataPtr createData(QString type, QString filename, QString name = "") const;
89 
90 private:
91  PatientModelServicePtr mPatientModelService;
92 
93  QString mName;
94  QString mCanReadDataType; //TODO: convert to enum?
95  QString mCanWriteDataType; //TODO: convert to enum?
96  QString mFileSuffix;
97 
98 
99  //cxEnumConverter.h
100  //cxDefinitions.h
101  //cxDefinitionStrings.h
102 };
103 
104 } //cx
105 
106 
107 #endif // CXFILEREADERWRITERSERVICE_H
FileReaderWriterService_iid
#define FileReaderWriterService_iid
Definition: cxFileReaderWriterService.h:20
cx::FileReaderWriterImplService::loadVtkPolyData
virtual vtkPolyDataPtr loadVtkPolyData(QString filename)
Definition: cxFileReaderWriterService.h:82
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
vtkImageDataPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Definition: cxVideoConnectionWidget.h:30
cxData.h
cx::FileReaderWriterService::~FileReaderWriterService
virtual ~FileReaderWriterService()
Definition: cxFileReaderWriterService.h:36
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cx::vtkPolyDataPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Definition: cxCenterlineRegistration.h:42
cx::FileReaderWriterImplService
Definition: cxFileReaderWriterService.h:71
cx::FileReaderWriterImplService::loadVtkImageData
virtual vtkImageDataPtr loadVtkImageData(QString filename)
Definition: cxFileReaderWriterService.h:81
cx::FileReaderWriterServicePtr
boost::shared_ptr< class FileReaderWriterService > FileReaderWriterServicePtr
Definition: cxForwardDeclarations.h:118
cx::FileReaderWriterService
Definition: cxFileReaderWriterService.h:30