Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Loaders/DicomResourcesLoader.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/DicomResourcesLoader.h@121d01aa328e |
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 "../OrthancStone.h" | |
25 | |
26 #if !defined(ORTHANC_ENABLE_DCMTK) | |
27 # error The macro ORTHANC_ENABLE_DCMTK must be defined | |
28 #endif | |
29 | |
30 #include "../Oracle/HttpCommand.h" | |
31 #include "../Oracle/OracleCommandExceptionMessage.h" | |
32 #include "../Oracle/OrthancRestApiCommand.h" | |
33 #include "../Oracle/ReadFileCommand.h" | |
34 #include "DicomSource.h" | |
35 #include "ILoaderFactory.h" | |
36 #include "LoadedDicomResources.h" | |
37 #include "OracleScheduler.h" | |
38 | |
39 namespace Orthanc | |
40 { | |
41 #if ORTHANC_ENABLE_DCMTK == 1 | |
42 class ParsedDicomDir; | |
43 #endif | |
44 } | |
45 | |
46 namespace OrthancStone | |
47 { | |
48 #if ORTHANC_ENABLE_DCMTK == 1 | |
49 class ParseDicomFromFileCommand; | |
50 #endif | |
51 | |
52 class DicomResourcesLoader : | |
53 public ObserverBase<DicomResourcesLoader>, | |
54 public IObservable | |
55 { | |
56 private: | |
57 class Handler; | |
58 class StringHandler; | |
59 class DicomWebHandler; | |
60 class OrthancHandler; | |
61 class OrthancInstanceTagsHandler; | |
62 class OrthancOneChildInstanceHandler; | |
63 class OrthancAllChildrenInstancesHandler; | |
64 | |
65 #if ORTHANC_ENABLE_DCMTK == 1 | |
66 class DicomDirHandler; | |
67 #endif | |
68 | |
69 void Handle(const HttpCommand::SuccessMessage& message); | |
70 | |
71 void Handle(const OrthancRestApiCommand::SuccessMessage& message); | |
72 | |
73 void Handle(const ReadFileCommand::SuccessMessage& message); | |
74 | |
75 void Handle(const OracleCommandExceptionMessage& message); | |
76 | |
77 #if ORTHANC_ENABLE_DCMTK == 1 | |
78 void Handle(const ParseDicomSuccessMessage& message); | |
79 #endif | |
80 | |
81 void ScheduleLoadOrthancInstanceTags(boost::shared_ptr<LoadedDicomResources> target, | |
82 int priority, | |
83 const DicomSource& source, | |
84 const std::string& instanceId, | |
85 boost::shared_ptr<unsigned int> remainingCommands, | |
86 boost::shared_ptr<Orthanc::IDynamicObject> userPayload); | |
87 | |
88 void ScheduleLoadOrthancOneChildInstance(boost::shared_ptr<LoadedDicomResources> target, | |
89 int priority, | |
90 const DicomSource& source, | |
91 Orthanc::ResourceType level, | |
92 const std::string& id, | |
93 boost::shared_ptr<unsigned int> remainingCommands, | |
94 boost::shared_ptr<Orthanc::IDynamicObject> userPayload); | |
95 | |
96 DicomResourcesLoader(ILoadersContext& context) : | |
97 context_(context) | |
98 { | |
99 } | |
100 | |
101 ILoadersContext& context_; | |
102 | |
103 | |
104 public: | |
105 class SuccessMessage : public OrthancStone::OriginMessage<DicomResourcesLoader> | |
106 { | |
107 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); | |
108 | |
109 private: | |
110 boost::shared_ptr<LoadedDicomResources> resources_; | |
111 int priority_; | |
112 const DicomSource& source_; | |
113 const Orthanc::IDynamicObject* userPayload_; | |
114 | |
115 public: | |
116 SuccessMessage(const DicomResourcesLoader& origin, | |
117 boost::shared_ptr<LoadedDicomResources> resources, | |
118 int priority, | |
119 const DicomSource& source, | |
120 const Orthanc::IDynamicObject* userPayload) : | |
121 OriginMessage(origin), | |
122 resources_(resources), | |
123 priority_(priority), | |
124 source_(source), | |
125 userPayload_(userPayload) | |
126 { | |
127 } | |
128 | |
129 int GetPriority() const | |
130 { | |
131 return priority_; | |
132 } | |
133 | |
134 const boost::shared_ptr<LoadedDicomResources> GetResources() const | |
135 { | |
136 return resources_; | |
137 } | |
138 | |
139 const DicomSource& GetDicomSource() const | |
140 { | |
141 return source_; | |
142 } | |
143 | |
144 bool HasUserPayload() const | |
145 { | |
146 return userPayload_ != NULL; | |
147 } | |
148 | |
149 const Orthanc::IDynamicObject& GetUserPayload() const; | |
150 }; | |
151 | |
152 | |
153 class Factory : public ILoaderFactory | |
154 { | |
155 public: | |
156 virtual boost::shared_ptr<IObserver> Create(ILoadersContext::ILock& stone) | |
157 { | |
158 return DicomResourcesLoader::Create(stone); | |
159 } | |
160 }; | |
161 | |
162 | |
163 static boost::shared_ptr<DicomResourcesLoader> Create(ILoadersContext::ILock& stone); | |
164 | |
165 void ScheduleGetDicomWeb(boost::shared_ptr<LoadedDicomResources> target, | |
166 int priority, | |
167 const DicomSource& source, | |
168 const std::string& uri, | |
169 const std::set<Orthanc::DicomTag>& includeTags, | |
170 Orthanc::IDynamicObject* userPayload); | |
171 | |
172 void ScheduleGetDicomWeb(boost::shared_ptr<LoadedDicomResources> target, | |
173 int priority, | |
174 const DicomSource& source, | |
175 const std::string& uri, | |
176 Orthanc::IDynamicObject* userPayload) | |
177 { | |
178 std::set<Orthanc::DicomTag> includeTags; | |
179 ScheduleGetDicomWeb(target, priority, source, uri, includeTags, userPayload); | |
180 } | |
181 | |
182 void ScheduleQido(boost::shared_ptr<LoadedDicomResources> target, | |
183 int priority, | |
184 const DicomSource& source, | |
185 Orthanc::ResourceType level, | |
186 const Orthanc::DicomMap& filter, | |
187 const std::set<Orthanc::DicomTag>& includeTags, | |
188 Orthanc::IDynamicObject* userPayload); | |
189 | |
190 void ScheduleLoadOrthancResources(boost::shared_ptr<LoadedDicomResources> target, | |
191 int priority, | |
192 const DicomSource& source, | |
193 Orthanc::ResourceType topLevel, | |
194 const std::string& topId, | |
195 Orthanc::ResourceType bottomLevel, | |
196 Orthanc::IDynamicObject* userPayload); | |
197 | |
198 void ScheduleLoadOrthancResource(boost::shared_ptr<LoadedDicomResources> target, | |
199 int priority, | |
200 const DicomSource& source, | |
201 Orthanc::ResourceType level, | |
202 const std::string& id, | |
203 Orthanc::IDynamicObject* userPayload) | |
204 { | |
205 ScheduleLoadOrthancResources(target, priority, source, level, id, level, userPayload); | |
206 } | |
207 | |
208 #if ORTHANC_ENABLE_DCMTK == 1 | |
209 static void GetDicomDirInstances(LoadedDicomResources& target, | |
210 const Orthanc::ParsedDicomDir& dicomDir); | |
211 #endif | |
212 | |
213 void ScheduleLoadDicomDir(boost::shared_ptr<LoadedDicomResources> target, | |
214 int priority, | |
215 const DicomSource& source, | |
216 const std::string& path, | |
217 Orthanc::IDynamicObject* userPayload); | |
218 | |
219 void ScheduleLoadDicomFile(boost::shared_ptr<LoadedDicomResources> target, | |
220 int priority, | |
221 const DicomSource& source, | |
222 const std::string& path, | |
223 bool includePixelData, | |
224 Orthanc::IDynamicObject* userPayload); | |
225 | |
226 bool ScheduleLoadDicomFile(boost::shared_ptr<LoadedDicomResources> target, | |
227 int priority, | |
228 const DicomSource& source, | |
229 const std::string& dicomDirPath, | |
230 const Orthanc::DicomMap& dicomDirEntry, | |
231 bool includePixelData, | |
232 Orthanc::IDynamicObject* userPayload); | |
233 }; | |
234 } |