Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Loaders/SeriesMetadataLoader.h @ 1512:244ad1e4e76a
reorganization of folders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 16:21:02 +0200 |
parents | Framework/Loaders/SeriesMetadataLoader.h@4db187d29731 |
children | 85e117739eca |
comparison
equal
deleted
inserted
replaced
1511:9dfeee74c1e6 | 1512:244ad1e4e76a |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "DicomResourcesLoader.h" | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 class SeriesMetadataLoader : | |
29 public ObserverBase<SeriesMetadataLoader>, | |
30 public IObservable | |
31 { | |
32 private: | |
33 enum State | |
34 { | |
35 State_Setup, | |
36 State_Default, | |
37 State_DicomDir, | |
38 State_DicomFile | |
39 }; | |
40 | |
41 typedef std::map<std::string, boost::shared_ptr<LoadedDicomResources> > Series; | |
42 | |
43 boost::shared_ptr<DicomResourcesLoader> loader_; | |
44 State state_; | |
45 std::map<std::string, int> scheduled_; // Maps a "SeriesInstanceUID" to a priority | |
46 Series series_; | |
47 boost::shared_ptr<LoadedDicomResources> dicomDir_; | |
48 std::string dicomDirPath_; | |
49 std::map<std::string, unsigned int> seriesSize_; | |
50 | |
51 SeriesMetadataLoader(boost::shared_ptr<DicomResourcesLoader>& loader); | |
52 | |
53 bool IsScheduledWithHigherPriority(const std::string& seriesInstanceUid, | |
54 int priority) const; | |
55 | |
56 void Handle(const DicomResourcesLoader::SuccessMessage& message); | |
57 | |
58 public: | |
59 class SuccessMessage : public OriginMessage<SeriesMetadataLoader> | |
60 { | |
61 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); | |
62 | |
63 private: | |
64 const DicomSource& source_; | |
65 const std::string& studyInstanceUid_; | |
66 const std::string& seriesInstanceUid_; | |
67 LoadedDicomResources& instances_; | |
68 std::string dicomDirPath_; | |
69 boost::shared_ptr<LoadedDicomResources> dicomDir_; | |
70 | |
71 public: | |
72 SuccessMessage(const SeriesMetadataLoader& loader, | |
73 const DicomSource& source, | |
74 const std::string& studyInstanceUid, | |
75 const std::string& seriesInstanceUid, | |
76 LoadedDicomResources& instances); | |
77 | |
78 const DicomSource& GetDicomSource() const | |
79 { | |
80 return source_; | |
81 } | |
82 | |
83 const std::string& GetStudyInstanceUid() const | |
84 { | |
85 return studyInstanceUid_; | |
86 } | |
87 | |
88 const std::string& GetSeriesInstanceUid() const | |
89 { | |
90 return seriesInstanceUid_; | |
91 } | |
92 | |
93 size_t GetInstancesCount() const | |
94 { | |
95 return instances_.GetSize(); | |
96 } | |
97 | |
98 const Orthanc::DicomMap& GetInstance(size_t index) const | |
99 { | |
100 return instances_.GetResource(index); | |
101 } | |
102 | |
103 LoadedDicomResources& GetInstances() const | |
104 { | |
105 return instances_; | |
106 } | |
107 | |
108 void SetDicomDir(const std::string& dicomDirPath, | |
109 boost::shared_ptr<LoadedDicomResources> dicomDir) | |
110 { | |
111 dicomDirPath_ = dicomDirPath; | |
112 dicomDir_ = dicomDir; | |
113 } | |
114 | |
115 const std::string& GetDicomDirPath() const | |
116 { | |
117 return dicomDirPath_; | |
118 } | |
119 | |
120 // Will be NULL on non-DICOMDIR sources | |
121 boost::shared_ptr<LoadedDicomResources> GetDicomDir() const | |
122 { | |
123 return dicomDir_; | |
124 } | |
125 }; | |
126 | |
127 | |
128 class Factory : public ILoaderFactory | |
129 { | |
130 public: | |
131 virtual boost::shared_ptr<IObserver> Create(ILoadersContext::ILock& context) | |
132 { | |
133 return SeriesMetadataLoader::Create(context); | |
134 } | |
135 }; | |
136 | |
137 | |
138 static boost::shared_ptr<SeriesMetadataLoader> Create(ILoadersContext::ILock& context); | |
139 | |
140 | |
141 class Accessor : public boost::noncopyable | |
142 { | |
143 private: | |
144 boost::shared_ptr<LoadedDicomResources> series_; | |
145 | |
146 public: | |
147 Accessor(SeriesMetadataLoader& that, | |
148 const std::string& seriesInstanceUid); | |
149 | |
150 bool IsComplete() const | |
151 { | |
152 return series_ != NULL; | |
153 } | |
154 | |
155 size_t GetInstancesCount() const; | |
156 | |
157 const Orthanc::DicomMap& GetInstance(size_t index) const; | |
158 }; | |
159 | |
160 | |
161 void ScheduleLoadSeries(int priority, | |
162 const DicomSource& source, | |
163 const std::string& studyInstanceUid, | |
164 const std::string& seriesInstanceUid); | |
165 | |
166 void ScheduleLoadSeries(int priority, | |
167 const DicomSource& source, | |
168 const std::string& patientId, | |
169 const std::string& studyInstanceUid, | |
170 const std::string& seriesInstanceUid); | |
171 | |
172 void ScheduleLoadDicomDir(int priority, | |
173 const DicomSource& source, | |
174 const std::string& path); | |
175 }; | |
176 } |