annotate OrthancFramework/Sources/DicomFormat/DicomPath.h @ 4845:02d77189d8ba received-instance-callback

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