annotate OrthancStone/Sources/Loaders/DicomResourcesLoader.cpp @ 1546:94750ef63ad5

support of Orthanc framework shared library
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Aug 2020 17:09:59 +0200
parents d3cafeef07bb
children 85e117739eca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1271
0ca50d275b9a upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "DicomResourcesLoader.h"
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #if !defined(ORTHANC_ENABLE_DCMTK)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 # error The macro ORTHANC_ENABLE_DCMTK must be defined
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #if ORTHANC_ENABLE_DCMTK == 1
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 # include "../Oracle/ParseDicomFromFileCommand.h"
1484
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
30 # include <DicomParsing/ParsedDicomDir.h>
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1311
diff changeset
31 # include <DicomParsing/ParsedDicomFile.h>
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include <boost/filesystem/path.hpp>
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 namespace OrthancStone
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 static std::string GetUri(Orthanc::ResourceType level)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 switch (level)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 case Orthanc::ResourceType_Patient:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 return "patients";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 case Orthanc::ResourceType_Study:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 return "studies";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 case Orthanc::ResourceType_Series:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 return "series";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 case Orthanc::ResourceType_Instance:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 return "instances";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 default:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 class DicomResourcesLoader::Handler : public Orthanc::IDynamicObject
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 private:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 boost::shared_ptr<DicomResourcesLoader> loader_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 boost::shared_ptr<LoadedDicomResources> target_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 int priority_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 DicomSource source_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 boost::shared_ptr<Orthanc::IDynamicObject> userPayload_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 public:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 Handler(boost::shared_ptr<DicomResourcesLoader> loader,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) :
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 loader_(loader),
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 target_(target),
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 priority_(priority),
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 source_(source),
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 userPayload_(userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 if (!loader ||
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 !target)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 virtual ~Handler()
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 void BroadcastSuccess()
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 SuccessMessage message(*loader_, target_, priority_, source_, userPayload_.get());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 loader_->BroadcastMessage(message);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 boost::shared_ptr<DicomResourcesLoader> GetLoader()
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 assert(loader_);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 return loader_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 boost::shared_ptr<LoadedDicomResources> GetTarget()
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 assert(target_);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 return target_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 int GetPriority() const
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 return priority_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 const DicomSource& GetSource() const
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 return source_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 const boost::shared_ptr<Orthanc::IDynamicObject> GetUserPayload() const
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 return userPayload_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 };
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 class DicomResourcesLoader::StringHandler : public DicomResourcesLoader::Handler
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 public:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 StringHandler(boost::shared_ptr<DicomResourcesLoader> loader,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) :
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 Handler(loader, target, priority, source, userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 virtual void HandleJson(const Json::Value& body) = 0;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 virtual void HandleString(const std::string& body)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 Json::Reader reader;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 Json::Value value;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 if (reader.parse(body, value))
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 HandleJson(value);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 };
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 class DicomResourcesLoader::DicomWebHandler : public StringHandler
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 public:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 DicomWebHandler(boost::shared_ptr<DicomResourcesLoader> loader,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) :
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 StringHandler(loader, target, priority, source, userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 virtual void HandleJson(const Json::Value& body)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 GetTarget()->AddFromDicomWeb(body);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 BroadcastSuccess();
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 };
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 class DicomResourcesLoader::OrthancHandler : public StringHandler
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 private:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 boost::shared_ptr<unsigned int> remainingCommands_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 protected:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 void CloseCommand()
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 assert(remainingCommands_);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 if (*remainingCommands_ == 0)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 (*remainingCommands_) --;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 if (*remainingCommands_ == 0)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 BroadcastSuccess();
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 public:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 OrthancHandler(boost::shared_ptr<DicomResourcesLoader> loader,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 boost::shared_ptr<unsigned int> remainingCommands,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) :
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 StringHandler(loader, target, priority, source, userPayload),
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 remainingCommands_(remainingCommands)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 if (!remainingCommands)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 (*remainingCommands) ++;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 boost::shared_ptr<unsigned int> GetRemainingCommands()
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 assert(remainingCommands_);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 return remainingCommands_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 };
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 class DicomResourcesLoader::OrthancInstanceTagsHandler : public OrthancHandler
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 public:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 OrthancInstanceTagsHandler(boost::shared_ptr<DicomResourcesLoader> loader,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 boost::shared_ptr<unsigned int> remainingCommands,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) :
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 OrthancHandler(loader, target, priority, source, remainingCommands, userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 virtual void HandleJson(const Json::Value& body)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 GetTarget()->AddFromOrthanc(body);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 CloseCommand();
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 };
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 class DicomResourcesLoader::OrthancOneChildInstanceHandler : public OrthancHandler
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 public:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 OrthancOneChildInstanceHandler(boost::shared_ptr<DicomResourcesLoader> loader,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 boost::shared_ptr<unsigned int> remainingCommands,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) :
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 OrthancHandler(loader, target, priority, source, remainingCommands, userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 virtual void HandleJson(const Json::Value& body)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 static const char* const ID = "ID";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 if (body.type() == Json::arrayValue)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 if (body.size() > 0)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 if (body[0].type() == Json::objectValue &&
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 body[0].isMember(ID) &&
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 body[0][ID].type() == Json::stringValue)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 GetLoader()->ScheduleLoadOrthancInstanceTags
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 (GetTarget(), GetPriority(), GetSource(), body[0][ID].asString(), GetRemainingCommands(), GetUserPayload());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 CloseCommand();
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 };
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 class DicomResourcesLoader::OrthancAllChildrenInstancesHandler : public OrthancHandler
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 private:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 Orthanc::ResourceType bottomLevel_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 public:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 OrthancAllChildrenInstancesHandler(boost::shared_ptr<DicomResourcesLoader> loader,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 boost::shared_ptr<unsigned int> remainingCommands,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 Orthanc::ResourceType bottomLevel,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) :
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 OrthancHandler(loader, target, priority, source, remainingCommands, userPayload),
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 bottomLevel_(bottomLevel)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 virtual void HandleJson(const Json::Value& body)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 static const char* const ID = "ID";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 static const char* const INSTANCES = "Instances";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 if (body.type() == Json::arrayValue)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 for (Json::Value::ArrayIndex i = 0; i < body.size(); i++)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 switch (bottomLevel_)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 case Orthanc::ResourceType_Patient:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 case Orthanc::ResourceType_Study:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 if (body[i].type() == Json::objectValue &&
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 body[i].isMember(ID) &&
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 body[i][ID].type() == Json::stringValue)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 GetLoader()->ScheduleLoadOrthancOneChildInstance
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 (GetTarget(), GetPriority(), GetSource(), bottomLevel_,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 body[i][ID].asString(), GetRemainingCommands(), GetUserPayload());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 case Orthanc::ResourceType_Series:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 // At the series level, avoid a call to
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 // "/series/.../instances", as we already have this
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 // information in the JSON
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 if (body[i].type() == Json::objectValue &&
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 body[i].isMember(INSTANCES) &&
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 body[i][INSTANCES].type() == Json::arrayValue)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 if (body[i][INSTANCES].size() > 0)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 if (body[i][INSTANCES][0].type() == Json::stringValue)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 GetLoader()->ScheduleLoadOrthancInstanceTags
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 (GetTarget(), GetPriority(), GetSource(),
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 body[i][INSTANCES][0].asString(), GetRemainingCommands(), GetUserPayload());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 case Orthanc::ResourceType_Instance:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 if (body[i].type() == Json::objectValue &&
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 body[i].isMember(ID) &&
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 body[i][ID].type() == Json::stringValue)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 GetLoader()->ScheduleLoadOrthancInstanceTags
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 (GetTarget(), GetPriority(), GetSource(),
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 body[i][ID].asString(), GetRemainingCommands(), GetUserPayload());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 default:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 CloseCommand();
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 };
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 #if ORTHANC_ENABLE_DCMTK == 1
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 static void ExploreDicomDir(OrthancStone::LoadedDicomResources& instances,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 const Orthanc::ParsedDicomDir& dicomDir,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 Orthanc::ResourceType level,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 size_t index,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 const Orthanc::DicomMap& parent)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 std::string expectedType;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 switch (level)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 case Orthanc::ResourceType_Patient:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 expectedType = "PATIENT";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 case Orthanc::ResourceType_Study:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 expectedType = "STUDY";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 case Orthanc::ResourceType_Series:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 expectedType = "SERIES";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 case Orthanc::ResourceType_Instance:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 expectedType = "IMAGE";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 default:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 for (;;)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
421 std::unique_ptr<Orthanc::DicomMap> current(dicomDir.GetItem(index).Clone());
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 current->RemoveBinaryTags();
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 current->Merge(parent);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 std::string type;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 if (!current->LookupStringValue(type, Orthanc::DICOM_TAG_DIRECTORY_RECORD_TYPE, false))
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 if (type == expectedType)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 if (level == Orthanc::ResourceType_Instance)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 instances.AddResource(*current);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 size_t lower;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 if (dicomDir.LookupLower(lower, index))
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 ExploreDicomDir(instances, dicomDir, Orthanc::GetChildResourceType(level), lower, *current);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 size_t next;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 if (dicomDir.LookupNext(next, index))
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 index = next;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 return;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 #if ORTHANC_ENABLE_DCMTK == 1
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 void DicomResourcesLoader::GetDicomDirInstances(LoadedDicomResources& target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 const Orthanc::ParsedDicomDir& dicomDir)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 Orthanc::DicomMap parent;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 ExploreDicomDir(target, dicomDir, Orthanc::ResourceType_Patient, 0, parent);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 #if ORTHANC_ENABLE_DCMTK == 1
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 class DicomResourcesLoader::DicomDirHandler : public StringHandler
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 public:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 DicomDirHandler(boost::shared_ptr<DicomResourcesLoader> loader,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) :
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 StringHandler(loader, target, priority, source, userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 virtual void HandleJson(const Json::Value& body)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 virtual void HandleString(const std::string& body)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 Orthanc::ParsedDicomDir dicomDir(body);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 GetDicomDirInstances(*GetTarget(), dicomDir);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 BroadcastSuccess();
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 };
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 void DicomResourcesLoader::Handle(const HttpCommand::SuccessMessage& message)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 if (message.GetOrigin().HasPayload())
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 dynamic_cast<StringHandler&>(message.GetOrigin().GetPayload()).HandleString(message.GetAnswer());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 void DicomResourcesLoader::Handle(const OrthancRestApiCommand::SuccessMessage& message)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510 if (message.GetOrigin().HasPayload())
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 dynamic_cast<StringHandler&>(message.GetOrigin().GetPayload()).HandleString(message.GetAnswer());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 void DicomResourcesLoader::Handle(const ReadFileCommand::SuccessMessage& message)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 if (message.GetOrigin().HasPayload())
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 dynamic_cast<StringHandler&>(message.GetOrigin().GetPayload()).HandleString(message.GetContent());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 #if ORTHANC_ENABLE_DCMTK == 1
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 void DicomResourcesLoader::Handle(const ParseDicomSuccessMessage& message)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 if (message.GetOrigin().HasPayload())
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 Handler& handler = dynamic_cast<Handler&>(message.GetOrigin().GetPayload());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 std::set<Orthanc::DicomTag> ignoreTagLength;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 ignoreTagLength.insert(Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR); // Needed for RT-DOSE
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 Orthanc::DicomMap summary;
1546
94750ef63ad5 support of Orthanc framework shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1531
diff changeset
537
94750ef63ad5 support of Orthanc framework shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1531
diff changeset
538 #if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 7, 3)
1531
d3cafeef07bb fix for new interface of Orthanc::ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
539 message.GetDicom().ExtractDicomSummary(summary, ORTHANC_STONE_MAX_TAG_LENGTH, ignoreTagLength);
1546
94750ef63ad5 support of Orthanc framework shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1531
diff changeset
540 #else
94750ef63ad5 support of Orthanc framework shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1531
diff changeset
541 message.GetDicom().ExtractDicomSummary(summary, ignoreTagLength);
94750ef63ad5 support of Orthanc framework shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1531
diff changeset
542 #endif
94750ef63ad5 support of Orthanc framework shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1531
diff changeset
543
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 handler.GetTarget()->AddResource(summary);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 handler.BroadcastSuccess();
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 void DicomResourcesLoader::Handle(const OracleCommandExceptionMessage& message)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 // TODO
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 LOG(ERROR) << "Exception: " << message.GetException().What();
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 void DicomResourcesLoader::ScheduleLoadOrthancInstanceTags(boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 const std::string& instanceId,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 boost::shared_ptr<unsigned int> remainingCommands,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 boost::shared_ptr<Orthanc::IDynamicObject> userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
566 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 command->SetUri("/instances/" + instanceId + "/tags");
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 command->AcquirePayload(new OrthancInstanceTagsHandler(shared_from_this(), target, priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 source, remainingCommands, userPayload));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
572 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 lock->Schedule(GetSharedObserver(), priority, command.release());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 void DicomResourcesLoader::ScheduleLoadOrthancOneChildInstance(boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 Orthanc::ResourceType level,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 const std::string& id,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 boost::shared_ptr<unsigned int> remainingCommands,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 boost::shared_ptr<Orthanc::IDynamicObject> userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
586 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 command->SetUri("/" + GetUri(level) + "/" + id + "/instances");
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 command->AcquirePayload(new OrthancOneChildInstanceHandler(shared_from_this(), target, priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 source, remainingCommands, userPayload));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
592 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 lock->Schedule(GetSharedObserver(), priority, command.release());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 const Orthanc::IDynamicObject& DicomResourcesLoader::SuccessMessage::GetUserPayload() const
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 if (userPayload_ == NULL)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607 return *userPayload_;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611
1472
474360793956 DicomResourcesLoader::Create()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
612 boost::shared_ptr<DicomResourcesLoader> DicomResourcesLoader::Create(ILoadersContext::ILock& stone)
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 boost::shared_ptr<DicomResourcesLoader> result(new DicomResourcesLoader(stone.GetContext()));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 result->Register<HttpCommand::SuccessMessage>(stone.GetOracleObservable(), &DicomResourcesLoader::Handle);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 result->Register<OracleCommandExceptionMessage>(stone.GetOracleObservable(), &DicomResourcesLoader::Handle);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 result->Register<OrthancRestApiCommand::SuccessMessage>(stone.GetOracleObservable(), &DicomResourcesLoader::Handle);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 result->Register<ReadFileCommand::SuccessMessage>(stone.GetOracleObservable(), &DicomResourcesLoader::Handle);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 #if ORTHANC_ENABLE_DCMTK == 1
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 result->Register<ParseDicomSuccessMessage>(stone.GetOracleObservable(), &DicomResourcesLoader::Handle);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623
1472
474360793956 DicomResourcesLoader::Create()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
624 return result;
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 static void SetIncludeTags(std::map<std::string, std::string>& arguments,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629 const std::set<Orthanc::DicomTag>& includeTags)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631 if (!includeTags.empty())
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 std::string s;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634 bool first = true;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 for (std::set<Orthanc::DicomTag>::const_iterator
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 it = includeTags.begin(); it != includeTags.end(); ++it)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 if (first)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641 first = false;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
644 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645 s += ",";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 char buf[16];
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 sprintf(buf, "%04X%04X", it->GetGroup(), it->GetElement());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 s += std::string(buf);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 arguments["includefield"] = s;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657
1250
a8248b08115c LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1228
diff changeset
658 void DicomResourcesLoader::ScheduleGetDicomWeb(boost::shared_ptr<LoadedDicomResources> target,
a8248b08115c LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1228
diff changeset
659 int priority,
a8248b08115c LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1228
diff changeset
660 const DicomSource& source,
a8248b08115c LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1228
diff changeset
661 const std::string& uri,
a8248b08115c LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1228
diff changeset
662 const std::set<Orthanc::DicomTag>& includeTags,
a8248b08115c LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1228
diff changeset
663 Orthanc::IDynamicObject* userPayload)
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 boost::shared_ptr<Orthanc::IDynamicObject> protection(userPayload);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
667 if (!source.IsDicomWeb())
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
668 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, "Not a DICOMweb source");
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672 std::map<std::string, std::string> arguments, headers;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673 SetIncludeTags(arguments, includeTags);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
674
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
675 std::unique_ptr<IOracleCommand> command(
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676 source.CreateDicomWebCommand(uri, arguments, headers,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 new DicomWebHandler(shared_from_this(), target, priority, source, protection)));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
680 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681 lock->Schedule(GetSharedObserver(), priority, command.release());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
683 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
684
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 void DicomResourcesLoader::ScheduleQido(boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689 Orthanc::ResourceType level,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
690 const Orthanc::DicomMap& filter,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691 const std::set<Orthanc::DicomTag>& includeTags,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692 Orthanc::IDynamicObject* userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
694 boost::shared_ptr<Orthanc::IDynamicObject> protection(userPayload);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
696 if (!source.IsDicomWeb())
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
697 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, "Not a DICOMweb source");
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
699 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
700
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
701 std::string uri;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
702 switch (level)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
703 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
704 case Orthanc::ResourceType_Study:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705 uri = "/studies";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708 case Orthanc::ResourceType_Series:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709 uri = "/series";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 case Orthanc::ResourceType_Instance:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 uri = "/instances";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 default:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 std::set<Orthanc::DicomTag> tags;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 filter.GetTags(tags);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 std::map<std::string, std::string> arguments, headers;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 for (std::set<Orthanc::DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727 std::string s;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728 if (filter.LookupStringValue(s, *it, false /* no binary */))
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
729 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730 char buf[16];
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 sprintf(buf, "%04X%04X", it->GetGroup(), it->GetElement());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 arguments[buf] = s;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
735
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736 SetIncludeTags(arguments, includeTags);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
738 std::unique_ptr<IOracleCommand> command(
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739 source.CreateDicomWebCommand(uri, arguments, headers,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
740 new DicomWebHandler(shared_from_this(), target, priority, source, protection)));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
741
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
744 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 lock->Schedule(GetSharedObserver(), priority, command.release());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 void DicomResourcesLoader::ScheduleLoadOrthancResources(boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 Orthanc::ResourceType topLevel,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 const std::string& topId,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 Orthanc::ResourceType bottomLevel,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 Orthanc::IDynamicObject* userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 boost::shared_ptr<Orthanc::IDynamicObject> protection(userPayload);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 if (!source.IsOrthanc())
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, "Not an Orthanc source");
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765 bool ok = false;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
767 switch (topLevel)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
768 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769 case Orthanc::ResourceType_Patient:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770 ok = (bottomLevel == Orthanc::ResourceType_Patient ||
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771 bottomLevel == Orthanc::ResourceType_Study ||
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
772 bottomLevel == Orthanc::ResourceType_Series ||
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773 bottomLevel == Orthanc::ResourceType_Instance);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776 case Orthanc::ResourceType_Study:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777 ok = (bottomLevel == Orthanc::ResourceType_Study ||
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 bottomLevel == Orthanc::ResourceType_Series ||
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779 bottomLevel == Orthanc::ResourceType_Instance);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782 case Orthanc::ResourceType_Series:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
783 ok = (bottomLevel == Orthanc::ResourceType_Series ||
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
784 bottomLevel == Orthanc::ResourceType_Instance);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787 case Orthanc::ResourceType_Instance:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 ok = (bottomLevel == Orthanc::ResourceType_Instance);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 break;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 default:
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 if (!ok)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800 boost::shared_ptr<unsigned int> remainingCommands(new unsigned int(0));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802 if (topLevel == Orthanc::ResourceType_Instance)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
804 ScheduleLoadOrthancInstanceTags(target, priority, source, topId, remainingCommands, protection);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806 else if (topLevel == bottomLevel)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
807 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 ScheduleLoadOrthancOneChildInstance(target, priority, source, topLevel, topId, remainingCommands, protection);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
812 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813 command->SetUri("/" + GetUri(topLevel) + "/" + topId + "/" + GetUri(bottomLevel));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 command->AcquirePayload(new OrthancAllChildrenInstancesHandler
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 (shared_from_this(), target, priority, source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
816 remainingCommands, bottomLevel, protection));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
819 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1311
3d26447ddd28 warning fixes + doc + indentation + header files in cmake for VC++ sln browsing
Benjamin Golinvaux <bgo@osimis.io>
parents: 1299
diff changeset
820
3d26447ddd28 warning fixes + doc + indentation + header files in cmake for VC++ sln browsing
Benjamin Golinvaux <bgo@osimis.io>
parents: 1299
diff changeset
821 // GetSharedObserver() means "this" (for use as an IObserver), as a
3d26447ddd28 warning fixes + doc + indentation + header files in cmake for VC++ sln browsing
Benjamin Golinvaux <bgo@osimis.io>
parents: 1299
diff changeset
822 // shared_ptr
3d26447ddd28 warning fixes + doc + indentation + header files in cmake for VC++ sln browsing
Benjamin Golinvaux <bgo@osimis.io>
parents: 1299
diff changeset
823 // The oracle will thus call "this"
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824 lock->Schedule(GetSharedObserver(), priority, command.release());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
825 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
826 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
827 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 void DicomResourcesLoader::ScheduleLoadDicomDir(boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 const std::string& path,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834 Orthanc::IDynamicObject* userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 boost::shared_ptr<Orthanc::IDynamicObject> protection(userPayload);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
837
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
838 if (!source.IsDicomDir())
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
839 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, "Not a DICOMDIR source");
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843 if (target->GetIndexedTag() == Orthanc::DICOM_TAG_SOP_INSTANCE_UID)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 LOG(WARNING) << "If loading DICOMDIR, it is advised to index tag "
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846 << "ReferencedSopInstanceUidInFile (0004,1511)";
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
847 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
849 #if ORTHANC_ENABLE_DCMTK == 1
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
850 std::unique_ptr<ReadFileCommand> command(new ReadFileCommand(path));
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 command->AcquirePayload(new DicomDirHandler(shared_from_this(), target, priority, source, protection));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
854 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 lock->Schedule(GetSharedObserver(), priority, command.release());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857 #else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
858 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 "DCMTK is disabled, cannot load DICOMDIR");
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
861 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
863
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
864 void DicomResourcesLoader::ScheduleLoadDicomFile(boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
866 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 const std::string& path,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
868 bool includePixelData,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
869 Orthanc::IDynamicObject* userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
870 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
871 boost::shared_ptr<Orthanc::IDynamicObject> protection(userPayload);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
873 #if ORTHANC_ENABLE_DCMTK == 1
1484
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
874 std::unique_ptr<ParseDicomFromFileCommand> command(new ParseDicomFromFileCommand(source, path));
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875 command->SetPixelDataIncluded(includePixelData);
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
876 command->AcquirePayload(new Handler(shared_from_this(), target, priority, source, protection));
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
877
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
879 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
880 lock->Schedule(GetSharedObserver(), priority, command.release());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
881 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
882 #else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
883 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
884 "DCMTK is disabled, cannot load DICOM files");
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
885 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
886 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
887
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
888
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
889 bool DicomResourcesLoader::ScheduleLoadDicomFile(boost::shared_ptr<LoadedDicomResources> target,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
890 int priority,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891 const DicomSource& source,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
892 const std::string& dicomDirPath,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893 const Orthanc::DicomMap& dicomDirEntry,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894 bool includePixelData,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 Orthanc::IDynamicObject* userPayload)
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 {
1299
c38c89684d83 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1271
diff changeset
897 std::unique_ptr<Orthanc::IDynamicObject> protection(userPayload);
1228
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899 #if ORTHANC_ENABLE_DCMTK == 1
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 std::string file;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901 if (dicomDirEntry.LookupStringValue(file, Orthanc::DICOM_TAG_REFERENCED_FILE_ID, false))
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
902 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
903 ScheduleLoadDicomFile(target, priority, source, ParseDicomFromFileCommand::GetDicomDirPath(dicomDirPath, file),
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
904 includePixelData, protection.release());
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905 return true;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
906 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
907 else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
908 {
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
909 return false;
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
910 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911 #else
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
912 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913 "DCMTK is disabled, cannot load DICOM files");
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914 #endif
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915 }
c471a0aa137b adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
916 }