annotate OrthancFramework/Sources/DicomFormat/DicomPath.h @ 4792:434843934307 storage-cache

Added a StorageCache in the StorageAccessor
author Alain Mazy <am@osimis.io>
date Thu, 30 Sep 2021 12:14:19 +0200
parents e17fdc43ef6c
children 7053502fbf97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Lesser General Public License for more details.
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * License along with this program. If not, see
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * <http://www.gnu.org/licenses/>.
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "../OrthancFramework.h"
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../DicomFormat/DicomTag.h"
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <vector>
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace Orthanc
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
4682
d38a7040474a FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4681
diff changeset
32 class ORTHANC_PUBLIC DicomPath
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 private:
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 class PrefixItem
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 private:
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 DicomTag tag_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 bool isUniversal_; // Matches any index
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 size_t index_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 PrefixItem(DicomTag tag,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 bool isUniversal,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 size_t index);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 public:
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 static PrefixItem CreateUniversal(const DicomTag& tag)
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 return PrefixItem(tag, true, 0 /* dummy value */);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 static PrefixItem CreateIndexed(const DicomTag& tag,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 size_t index)
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 return PrefixItem(tag, false, index);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 const DicomTag& GetTag() const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 return tag_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 bool IsUniversal() const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 return isUniversal_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 size_t GetIndex() const;
4689
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
69
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
70 void SetIndex(size_t index);
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 };
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 std::vector<PrefixItem> prefix_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 Orthanc::DicomTag finalTag_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 static DicomTag ParseTag(const std::string& token);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 const PrefixItem& GetLevel(size_t i) const;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 public:
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4689
diff changeset
81 explicit DicomPath(const Orthanc::DicomTag& tag);
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 DicomPath(const Orthanc::DicomTag& sequence,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 size_t index,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 const Orthanc::DicomTag& tag);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 DicomPath(const Orthanc::DicomTag& sequence1,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 size_t index1,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 const Orthanc::DicomTag& sequence2,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 size_t index2,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 const Orthanc::DicomTag& tag);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 DicomPath(const Orthanc::DicomTag& sequence1,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 size_t index1,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 const Orthanc::DicomTag& sequence2,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 size_t index2,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 const Orthanc::DicomTag& sequence3,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 size_t index3,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 const Orthanc::DicomTag& tag);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
101 DicomPath(const std::vector<Orthanc::DicomTag>& parentTags,
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4689
diff changeset
102 const std::vector<size_t>& parentIndexes,
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
103 const Orthanc::DicomTag& finalTag);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
104
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 void AddIndexedTagToPrefix(const Orthanc::DicomTag& tag,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 size_t index);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 void AddUniversalTagToPrefix(const Orthanc::DicomTag& tag);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4689
diff changeset
110 size_t GetPrefixLength() const;
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4689
diff changeset
112 const Orthanc::DicomTag& GetFinalTag() const;
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4689
diff changeset
114 const Orthanc::DicomTag& GetPrefixTag(size_t level) const;
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4689
diff changeset
116 bool IsPrefixUniversal(size_t level) const;
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4689
diff changeset
118 size_t GetPrefixIndex(size_t level) const;
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
4682
d38a7040474a FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4681
diff changeset
120 bool HasUniversal() const;
d38a7040474a FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4681
diff changeset
121
4689
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
122 // This method is used for an optimization in Stone
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
123 // (cf. "DicomStructureSet.cpp")
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
124 void SetPrefixIndex(size_t level,
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
125 size_t index);
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
126
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 std::string Format() const;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
4682
d38a7040474a FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4681
diff changeset
129 static DicomPath Parse(const std::string& s);
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
130
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
131 static bool IsMatch(const DicomPath& pattern,
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
132 const DicomPath& path);
4735
e17fdc43ef6c optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
133
e17fdc43ef6c optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
134 static bool IsMatch(const DicomPath& pattern,
e17fdc43ef6c optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
135 const std::vector<Orthanc::DicomTag>& prefixTags,
e17fdc43ef6c optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
136 const std::vector<size_t>& prefixIndexes,
e17fdc43ef6c optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
137 const DicomTag& finalTag);
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 };
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 }