Mercurial > hg > orthanc
annotate OrthancServer/Sources/DicomInstanceToStore.h @ 4721:cf4a80a7e1a2
back to mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 24 Jun 2021 09:16:03 +0200 |
parents | 8f9090b137f1 |
children | f0038043fb97 7053502fbf97 |
rev | line source |
---|---|
1003 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 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 |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
1003 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
4045 | 36 #include "../../OrthancFramework/Sources/DicomFormat/DicomMap.h" |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
37 #include "DicomInstanceOrigin.h" |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
38 #include "ServerEnumerations.h" |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
39 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
40 #include <boost/shared_ptr.hpp> |
1003 | 41 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
42 class DcmDataset; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
43 |
1003 | 44 namespace Orthanc |
45 { | |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4506
diff
changeset
|
46 class ImageAccessor; |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
47 class ParsedDicomFile; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
48 |
3836 | 49 class DicomInstanceToStore : public boost::noncopyable |
1003 | 50 { |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
51 public: |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
52 typedef std::map<std::pair<ResourceType, MetadataType>, std::string> MetadataMap; |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
53 |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
54 private: |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
55 class FromBuffer; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
56 class FromParsedDicomFile; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
57 class FromDcmDataset; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
58 |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
59 MetadataMap metadata_; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
60 DicomInstanceOrigin origin_; |
1003 | 61 |
62 public: | |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
63 virtual ~DicomInstanceToStore() |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
64 { |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
65 } |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
66 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
67 // WARNING: The source in the factory methods is *not* copied and |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
68 // must *not* be deallocated as long as this wrapper object is alive |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
69 static DicomInstanceToStore* CreateFromBuffer(const void* buffer, |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
70 size_t size); |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
71 |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
72 static DicomInstanceToStore* CreateFromBuffer(const std::string& buffer); |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
73 |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
74 static DicomInstanceToStore* CreateFromParsedDicomFile(ParsedDicomFile& dicom); |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
75 |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
76 static DicomInstanceToStore* CreateFromDcmDataset(DcmDataset& dataset); |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
77 |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3836
diff
changeset
|
78 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
79 |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
80 void SetOrigin(const DicomInstanceOrigin& origin) |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
81 { |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
82 origin_ = origin; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
83 } |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
84 |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
85 const DicomInstanceOrigin& GetOrigin() const |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
86 { |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
87 return origin_; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
88 } |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
89 |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
90 const MetadataMap& GetMetadata() const |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
91 { |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
92 return metadata_; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
93 } |
1003 | 94 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
95 void ClearMetadata() |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
96 { |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
97 metadata_.clear(); |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
98 } |
1003 | 99 |
4506
ac69c9f76c71
refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4505
diff
changeset
|
100 // This function is notably used by modify/anonymize operations |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
101 void AddMetadata(ResourceType level, |
1003 | 102 MetadataType metadata, |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
103 const std::string& value) |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
104 { |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
105 metadata_[std::make_pair(level, metadata)] = value; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
106 } |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
107 |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4506
diff
changeset
|
108 bool LookupTransferSyntax(DicomTransferSyntax& result) const; |
2898
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
109 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
110 virtual ParsedDicomFile& GetParsedDicomFile() const = 0; |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3847
diff
changeset
|
111 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
112 virtual const void* GetBufferData() const = 0; |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4506
diff
changeset
|
113 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
114 virtual size_t GetBufferSize() const = 0; |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4506
diff
changeset
|
115 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
116 virtual bool HasPixelData() const; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
117 |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
118 virtual void GetSummary(DicomMap& summary) const; |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4506
diff
changeset
|
119 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
120 virtual void GetDicomAsJson(Json::Value& dicomAsJson) const; |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4506
diff
changeset
|
121 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
122 virtual void DatasetToJson(Json::Value& target, |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
123 DicomToJsonFormat format, |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
124 DicomToJsonFlags flags, |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
125 unsigned int maxStringLength) const; |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
126 |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
127 virtual unsigned int GetFramesCount() const; |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4506
diff
changeset
|
128 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
129 virtual ImageAccessor* DecodeFrame(unsigned int frame) const; |
1003 | 130 }; |
131 } |