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