NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkIGIDataSource.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkIGIDataSource_h
16 #define niftkIGIDataSource_h
17 
18 #include <niftkIGIDataSourcesExports.h>
19 #include <niftkIGIDataType.h>
21 #include <niftkIGIDataSourceI.h>
23 
24 #include <mitkDataStorage.h>
25 #include <mitkServiceInterface.h>
26 #include <usServiceRegistration.h>
27 
28 #include <QDir>
29 #include <QString>
30 
31 namespace niftk
32 {
33 
47 class NIFTKIGIDATASOURCES_EXPORT IGIDataSource : public niftk::IGIDataSourceI
48 {
49 public:
50 
51  mitkClassMacroItkParent(IGIDataSource, niftk::IGIDataSourceI)
52 
53 
56  virtual QString GetName() const override;
57 
61  virtual QString GetFactoryName() const override;
62 
66  virtual QString GetStatus() const override;
67 
71  QString GetDescription() const override;
72 
76  virtual bool GetShouldUpdate() const override;
77 
81  virtual void SetShouldUpdate(bool shouldUpdate) override;
82 
86  virtual void StartPlayback(niftk::IGIDataType::IGITimeType firstTimeStamp,
87  niftk::IGIDataType::IGITimeType lastTimeStamp) override;
88 
92  virtual void StopPlayback() override;
93 
97  virtual void StartRecording() override;
98 
102  virtual void StopRecording() override;
103 
107  virtual void SetRecordingLocation(const QString& pathName) override;
108 
112  virtual QString GetRecordingLocation() const override;
113 
117  virtual void SetPlaybackSourceName(const QString& sourceName) override;
118 
122  virtual QString GetPlaybackSourceName() const override;
123 
127  QString GetPlaybackDirectory() const;
128 
132  QString GetRecordingDirectory() const;
133 
134  itkGetConstMacro(IsRecording, bool);
135  itkGetConstMacro(IsPlayingBack, bool);
136 
137  itkSetMacro(TimeStampTolerance, niftk::IGIDataType::IGITimeType);
138  itkGetConstMacro(TimeStampTolerance, niftk::IGIDataType::IGITimeType);
139 
140 protected:
141 
143  const std::string& factoryName,
144  mitk::DataStorage::Pointer dataStorage); // Purposefully hidden.
145  virtual ~IGIDataSource(); // Purposefully hidden.
146 
147  IGIDataSource(const IGIDataSource&); // Purposefully not implemented.
148  IGIDataSource& operator=(const IGIDataSource&); // Purposefully not implemented.
149 
158  mitk::DataNode::Pointer GetDataNode(const QString& name=QString(), const bool& addToDataStorage=true);
159 
164  bool IsLate(const niftk::IGIDataType::IGITimeType& requested,
165  const niftk::IGIDataType::IGITimeType& actual
166  ) const;
167 
171  unsigned int GetLagInMilliseconds(const niftk::IGIDataType::IGITimeType& requested,
172  const niftk::IGIDataType::IGITimeType& actual
173  ) const;
174 
178  mitk::DataStorage::Pointer GetDataStorage() const;
179 
183  niftk::IGIDataType::IGITimeType GetTimeStampInNanoseconds();
184 
185  itkSetMacro(IsRecording, bool);
186  itkSetMacro(IsPlayingBack, bool);
187 
188  void SetStatus(const QString& status);
189  void SetDescription(const QString& description);
190 
191 private:
192 
193  niftk::SystemTimeServiceRAII *m_SystemTimeService;
194  mitk::DataStorage::Pointer m_DataStorage;
195  std::set<mitk::DataNode::Pointer> m_DataNodes;
196  us::ServiceRegistration<Self> m_MicroServiceRegistration;
197  QString m_Name;
198  QString m_FactoryName;
199  QString m_Status;
200  QString m_Description;
201  QString m_RecordingLocation;
202  QString m_PlaybackSourceName;
203  niftk::IGIDataType::IGITimeType m_TimeStampTolerance; // nanoseconds.
204  bool m_ShouldUpdate;
205  bool m_IsRecording;
206  bool m_IsPlayingBack;
207 };
208 
209 } // end namespace
210 
211 MITK_DECLARE_SERVICE_INTERFACE(niftk::IGIDataSource, "uk.ac.ucl.cmic.IGIDataSource")
212 
213 #endif
Interface for an IGI Data Source (e.g. video feed, ultrasound feed, tracker feed).
Definition: niftkIGIDataSourceI.h:70
SystemTimeServiceI::TimeType IGITimeType
Definition: niftkIGIDataType.h:39
RAII object to retrieve the system time via a SystemTimeServiceI implementation.
Definition: niftkSystemTimeServiceRAII.h:33
Abstract base class for IGI DataSources, such as objects that produce tracking data, video frames or ultrasound frames.
Definition: niftkIGIDataSource.h:47
MITK_DECLARE_SERVICE_INTERFACE(niftk::IGIDataSourceFactoryServiceI,"uk.ac.ucl.cmic.IGIDataSourceFactoryServiceI")
GLuint const GLchar * name
Definition: glew.h:1798
Definition: niftkExceptionObject.h:21
GLsizei const GLcharARB ** string
Definition: glew.h:5194