annotate OrthancServer/DicomProtocol/DicomFindAnswers.cpp @ 2116:2fabd1073728

prevent registering two tags with the same symbolic name
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 31 Oct 2016 15:42:18 +0100
parents 8e67325eaa3f
children 9329ba17a069
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
4 * Department, University Hospital of Liege, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
10 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
11 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
12 * program give permission to link the code of its release with the
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
15 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
19 * you do not wish to do so, delete this exception statement from your
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
20 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
21 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
33 #include "../PrecompiledHeadersServer.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "DicomFindAnswers.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../FromDcmtkBridge.h"
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
37 #include "../ToDcmtkBridge.h"
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
38 #include "../../Core/OrthancException.h"
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
39
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
40 #include <memory>
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
41 #include <dcmtk/dcmdata/dcfilefo.h>
1847
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
42 #include <boost/noncopyable.hpp>
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
43
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
45 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
1847
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
47 class DicomFindAnswers::Answer : public boost::noncopyable
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
48 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
49 private:
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
50 ParsedDicomFile* dicom_;
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
51 DicomMap* map_;
1797
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
52
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
53 void CleanupDicom(bool isWorklist)
1797
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
54 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
55 if (isWorklist &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
56 dicom_ != NULL)
1797
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
57 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
58 // These lines are necessary when serving worklists, otherwise
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
59 // Orthanc does not behave as "wlmscpfs"
1797
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
60 dicom_->Remove(DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID);
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
61 dicom_->Remove(DICOM_TAG_SOP_INSTANCE_UID);
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
62 }
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
63 }
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
64
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
65 public:
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
66 Answer(bool isWorklist,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
67 ParsedDicomFile& dicom) :
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
68 dicom_(dicom.Clone()),
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
69 map_(NULL)
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
70 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
71 CleanupDicom(isWorklist);
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
72 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
73
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
74 Answer(bool isWorklist,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
75 const void* dicom,
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
76 size_t size) :
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
77 dicom_(new ParsedDicomFile(dicom, size)),
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
78 map_(NULL)
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
79 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
80 CleanupDicom(isWorklist);
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
81 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
82
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
83 Answer(const DicomMap& map) :
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
84 dicom_(NULL),
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
85 map_(map.Clone())
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
86 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
87 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
88
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
89 ~Answer()
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
90 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
91 if (dicom_ != NULL)
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
92 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
93 delete dicom_;
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
94 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
95
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
96 if (map_ != NULL)
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
97 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
98 delete map_;
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
99 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
100 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
101
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
102 ParsedDicomFile& GetDicomFile()
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
103 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
104 if (dicom_ == NULL)
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
105 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
106 assert(map_ != NULL);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
107 dicom_ = new ParsedDicomFile(*map_);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
108 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
109
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
110 return *dicom_;
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
111 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
112
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
113 DcmDataset* ExtractDcmDataset() const
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
114 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
115 if (dicom_ != NULL)
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
116 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
117 return new DcmDataset(*dicom_->GetDcmtkObject().getDataset());
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
118 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
119 else
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
120 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
121 assert(map_ != NULL);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
122 return ToDcmtkBridge::Convert(*map_);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
123 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
124 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
125 };
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
126
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
127
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
128 void DicomFindAnswers::SetWorklist(bool isWorklist)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
129 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
130 if (answers_.empty())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
131 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
132 isWorklist_ = isWorklist;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
133 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
134 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
135 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
136 // This set of answers is not empty anymore, cannot change its type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
137 throw OrthancException(ErrorCode_BadSequenceOfCalls);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
138 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
139 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
140
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
141
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 void DicomFindAnswers::Clear()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
144 for (size_t i = 0; i < answers_.size(); i++)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
146 assert(answers_[i] != NULL);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
147 delete answers_[i];
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
149
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
150 answers_.clear();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
153
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 void DicomFindAnswers::Reserve(size_t size)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
156 if (size > answers_.size())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
158 answers_.reserve(size);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
162
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
163 void DicomFindAnswers::Add(const DicomMap& map)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
164 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
165 answers_.push_back(new Answer(map));
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
166 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
167
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
168
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
169 void DicomFindAnswers::Add(ParsedDicomFile& dicom)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
170 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
171 answers_.push_back(new Answer(isWorklist_, dicom));
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
172 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
173
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
174
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
175 void DicomFindAnswers::Add(const void* dicom,
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
176 size_t size)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
177 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
178 answers_.push_back(new Answer(isWorklist_, dicom, size));
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
179 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
180
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
181
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
182 DicomFindAnswers::Answer& DicomFindAnswers::GetAnswerInternal(size_t index) const
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
183 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
184 if (index < answers_.size())
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
185 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
186 return *answers_.at(index);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
187 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
188 else
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
189 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
190 throw OrthancException(ErrorCode_ParameterOutOfRange);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
191 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
192 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
193
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
194
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
195 ParsedDicomFile& DicomFindAnswers::GetAnswer(size_t index) const
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
196 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
197 return GetAnswerInternal(index).GetDicomFile();
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
198 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
199
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
200
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
201 DcmDataset* DicomFindAnswers::ExtractDcmDataset(size_t index) const
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
202 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
203 return GetAnswerInternal(index).ExtractDcmDataset();
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
204 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
205
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
206
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
207 void DicomFindAnswers::ToJson(Json::Value& target,
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
208 size_t index,
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
209 bool simplify) const
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
210 {
1860
c7d70f659190 DicomToJsonFormat_Simple -> DicomToJsonFormat_Human
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1847
diff changeset
211 DicomToJsonFormat format = (simplify ? DicomToJsonFormat_Human : DicomToJsonFormat_Full);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
212 GetAnswer(index).ToJson(target, format, DicomToJsonFlags_None, 0);
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
213 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
214
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
215
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
216 void DicomFindAnswers::ToJson(Json::Value& target,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
217 bool simplify) const
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 target = Json::arrayValue;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 for (size_t i = 0; i < GetSize(); i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
223 Json::Value answer;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
224 ToJson(answer, i, simplify);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 target.append(answer);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 }