fw4spl
io/fwGdcmIO/include/fwGdcmIO/reader/SeriesDB.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #pragma once
8 
9 #include "fwGdcmIO/config.hpp"
10 #include "fwGdcmIO/exception/Failed.hpp"
11 
12 #include <fwData/location/Folder.hpp>
13 #include <fwData/location/MultiFiles.hpp>
14 
15 #include <fwDataIO/reader/GenericObjectReader.hpp>
16 
17 #include <fwLog/Logger.hpp>
18 
19 #include <fwMedData/DicomSeries.hpp>
20 #include <fwMedData/SeriesDB.hpp>
21 
22 #include <fwServices/IService.hpp>
23 
24 namespace fwJobs
25 {
26 class Aggregator;
27 class IJob;
28 class Observer;
29 }
30 
31 namespace fwGdcmIO
32 {
33 
34 namespace reader
35 {
36 
40 class FWGDCMIO_CLASS_API SeriesDB : public ::fwDataIO::reader::GenericObjectReader< ::fwMedData::SeriesDB >,
41  public ::fwData::location::enableFolder< ::fwDataIO::reader::IObjectReader >,
42  public ::fwData::location::enableMultiFiles< ::fwDataIO::reader::IObjectReader >,
43  public ::fwCom::HasSignals
44 {
45 
46 public:
47 
50  (()), ::fwDataIO::reader::factory::New< SeriesDB >);
51 
52  typedef std::vector< SPTR(::fwMedData::DicomSeries) > DicomSeriesContainerType;
53  typedef std::vector< std::string > FilenameContainerType;
54  typedef std::vector< std::string > SupportedSOPClassContainerType;
55 
58 
60  FWGDCMIO_API ~SeriesDB();
61 
63  FWGDCMIO_API void read() override;
64 
70  FWGDCMIO_API void readFromDicomSeriesDB(const ::fwMedData::SeriesDB::csptr& dicomSeriesDB,
71  const ::fwServices::IService::sptr& notifier
72  = ::fwServices::IService::sptr());
73 
77  FWGDCMIO_API void readDicomSeries();
78 
80  FWGDCMIO_API bool isDicomDirAvailable();
81 
83  FWGDCMIO_API DicomSeriesContainerType& getDicomSeries();
84 
86  const bool& getDicomdirActivated() const
87  {
88  return m_isDicomdirActivated;
89  }
90 
92  void setDicomdirActivated(const bool& isDicomdirActivated)
93  {
94  m_isDicomdirActivated = isDicomdirActivated;
95  }
96 
98  const std::string& getDicomFilterType() const
99  {
100  return m_dicomFilterType;
101  }
102 
104  void setDicomFilterType(const std::string& dicomFilterType)
105  {
106  m_dicomFilterType = dicomFilterType;
107  }
108 
110  const SupportedSOPClassContainerType& getSupportedSOPClassContainer() const
111  {
112  return m_supportedSOPClassContainer;
113  }
114 
116  void setSupportedSOPClassContainer(const SupportedSOPClassContainerType& supportedSOPClassContainer)
117  {
118  m_supportedSOPClassContainer = supportedSOPClassContainer;
119  }
120 
122  const ::fwLog::Logger::sptr& getLogger() const
123  {
124  return m_logger;
125  }
126 
128  void setLogger(const ::fwLog::Logger::sptr& logger)
129  {
130  m_logger = logger;
131  }
132 
134  FWGDCMIO_API SPTR(::fwJobs::IJob) getJob() const override;
135 
137  void setBufferRotationEnabled(bool enabled)
138  {
139  m_enableBufferRotation = enabled;
140  }
141 
142 private:
143 
147  void readDicom();
148 
153  void convertDicomSeries(const ::fwServices::IService::sptr& notifier = ::fwServices::IService::sptr());
154 
160  static bool dicomSeriesComparator(const SPTR(::fwMedData::DicomSeries)& a,
161  const SPTR(::fwMedData::DicomSeries)& b);
162 
164  DicomSeriesContainerType m_dicomSeriesContainer;
165 
167  bool m_isDicomdirActivated;
168 
170  std::string m_dicomFilterType;
171 
173  SupportedSOPClassContainerType m_supportedSOPClassContainer;
174 
176  ::fwLog::Logger::sptr m_logger;
177 
179  SPTR(::fwJobs::Aggregator) m_job;
180 
182  bool m_enableBufferRotation;
183 
184  SPTR(::fwJobs::Observer) m_dicomdirFileLookupJob;
185  SPTR(::fwJobs::Observer) m_regularFileLookupJob;
186  SPTR(::fwJobs::Observer) m_readerJob;
187  SPTR(::fwJobs::Observer) m_completeDicomSeriesJob;
188  SPTR(::fwJobs::Observer) m_converterJob;
189 };
190 
191 } // namespace reader
192 
193 } // namespace fwGdcmIO
#define SPTR(_cls_)
This class is an interface for class managing job.
Definition: IJob.hpp:28
const ::fwLog::Logger::sptr & getLogger() const
Get Logger.
void setBufferRotationEnabled(bool enabled)
Enable buffer rotation.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
generic class for all object readers.
void setDicomdirActivated(const bool &isDicomdirActivated)
Set Set whether the reader must use the dicomdir file or not.
This class adds patient(s) from DICOM file(s) to fwData::SeriesDB.
const SupportedSOPClassContainerType & getSupportedSOPClassContainer() const
Get Supported SOP Class.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
const std::string & getDicomFilterType() const
Get Dicom filter type that must be applied prior to the reading process.
void setDicomFilterType(const std::string &dicomFilterType)
Set Dicom filter type that must be applied prior to the reading process.
This class manages an aggregation of IJob.
Definition: Aggregator.hpp:32
void setLogger(const ::fwLog::Logger::sptr &logger)
Set Logger.
This class is derived by reader/writer.
Definition: Folder.hpp:80
const bool & getDicomdirActivated() const
Get Set whether the reader must use the dicomdir file or not.
This class is derived by reader/writer.
Definition: MultiFiles.hpp:58
This namespace fwJobs provides jobs management.
void setSupportedSOPClassContainer(const SupportedSOPClassContainerType &supportedSOPClassContainer)
Set Supported SOP Class.
This class manages a job.
Definition: Observer.hpp:22
This class proposes a mapping between a SignalKeyType and a SignalBase.
Definition: HasSignals.hpp:21