annotate OrthancServer/DicomInstanceToStore.h @ 2518:63d2cc0fb40a

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Mar 2018 14:41:41 +0200
parents 878b59270859
children c691fcf66071
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1815
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1285
diff changeset
4 * Department, University Hospital of Liege, Belgium
2447
878b59270859 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #pragma once
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
36 #include "../Core/DicomParsing/ParsedDicomFile.h"
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "ServerIndex.h"
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
38 #include "../Core/OrthancException.h"
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
39 #include "../Core/RestApi/RestApiCall.h"
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 class DicomInstanceToStore
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 private:
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
46 template <typename T>
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
47 class SmartContainer
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
48 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
49 private:
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
50 T* content_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
51 bool toDelete_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
52 bool isReadOnly_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
53
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
54 void Deallocate()
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
55 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
56 if (content_ && toDelete_)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
57 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
58 delete content_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
59 toDelete_ = false;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
60 content_ = NULL;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
61 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
62 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
63
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
64 public:
1303
bba8a47922d1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
65 SmartContainer() : content_(NULL), toDelete_(false), isReadOnly_(true)
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
66 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
67 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
68
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
69 ~SmartContainer()
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
70 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
71 Deallocate();
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
72 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
73
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
74 void Allocate()
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
75 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
76 Deallocate();
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
77 content_ = new T;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
78 toDelete_ = true;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
79 isReadOnly_ = false;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
80 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
81
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
82 void TakeOwnership(T* content)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
83 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
84 if (content == NULL)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
85 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
86 throw OrthancException(ErrorCode_ParameterOutOfRange);
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
87 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
88
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
89 Deallocate();
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
90 content_ = content;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
91 toDelete_ = true;
1005
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
92 isReadOnly_ = false;
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
93 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
94
1005
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
95 void SetReference(T& content) // Read and write assign, without transfering ownership
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
96 {
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
97 Deallocate();
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
98 content_ = &content;
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
99 toDelete_ = false;
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
100 isReadOnly_ = false;
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
101 }
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
102
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
103 void SetConstReference(const T& content) // Read-only assign, without transfering ownership
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
104 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
105 Deallocate();
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
106 content_ = &const_cast<T&>(content);
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
107 toDelete_ = false;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
108 isReadOnly_ = true;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
109 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
110
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
111 bool HasContent() const
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
112 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
113 return content_ != NULL;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
114 }
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
116 T& GetContent()
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
117 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
118 if (content_ == NULL)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
119 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
120 throw OrthancException(ErrorCode_BadSequenceOfCalls);
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
121 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
122
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
123 if (isReadOnly_)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
124 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
125 throw OrthancException(ErrorCode_ReadOnly);
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
126 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
127
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
128 return *content_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
129 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
130
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
131 const T& GetConstContent() const
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
132 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
133 if (content_ == NULL)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
134 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
135 throw OrthancException(ErrorCode_BadSequenceOfCalls);
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
136 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
137
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
138 return *content_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
139 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
140 };
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
141
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
142
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
143 SmartContainer<std::string> buffer_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
144 SmartContainer<ParsedDicomFile> parsed_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
145 SmartContainer<DicomMap> summary_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
146 SmartContainer<Json::Value> json_;
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
148 RequestOrigin origin_;
1573
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
149 std::string remoteIp_;
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
150 std::string dicomRemoteAet_;
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
151 std::string dicomCalledAet_;
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
152 std::string httpUsername_;
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 ServerIndex::MetadataMap metadata_;
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 void ComputeMissingInformation();
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 public:
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
158 DicomInstanceToStore() : origin_(RequestOrigin_Unknown)
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
159 {
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
160 }
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
161
1573
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
162 void SetDicomProtocolOrigin(const char* remoteIp,
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
163 const char* remoteAet,
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
164 const char* calledAet);
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
165
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
166 void SetRestOrigin(const RestApiCall& call);
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
167
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
168 void SetHttpOrigin(const char* remoteIp,
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
169 const char* username);
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
170
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
171 void SetLuaOrigin();
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
172
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
173 void SetPluginsOrigin();
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
174
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
175 RequestOrigin GetRequestOrigin() const
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
176 {
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
177 return origin_;
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
178 }
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
179
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
180 const char* GetRemoteAet() const;
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
181
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
182 void SetBuffer(const std::string& dicom)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
183 {
1005
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
184 buffer_.SetConstReference(dicom);
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
185 }
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 void SetParsedDicomFile(ParsedDicomFile& parsed)
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 {
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
189 parsed_.SetReference(parsed);
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 }
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 void SetSummary(const DicomMap& summary)
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
1005
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
194 summary_.SetConstReference(summary);
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 }
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 void SetJson(const Json::Value& json)
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 {
1005
84b6d7bca6db refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1004
diff changeset
199 json_.SetConstReference(json);
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 }
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
202 void AddMetadata(ResourceType level,
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 MetadataType metadata,
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 const std::string& value);
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 const ServerIndex::MetadataMap& GetMetadata() const
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 return metadata_;
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 }
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
211 ServerIndex::MetadataMap& GetMetadata()
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
212 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
213 return metadata_;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
214 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
215
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
216 const char* GetBufferData();
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 size_t GetBufferSize();
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
219
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
220 const DicomMap& GetSummary();
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
221
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
222 const Json::Value& GetJson();
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
223
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1303
diff changeset
224 void GetOriginInformation(Json::Value& result) const;
2189
c4b3259c8bce New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
225
c4b3259c8bce New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
226 bool LookupTransferSyntax(std::string& result);
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 };
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 }