annotate OrthancFramework/Sources/DicomFormat/DicomPath.h @ 4681:c5528c7847a6

new class DicomPath
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Jun 2021 17:05:48 +0200
parents
children d38a7040474a
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 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 class DicomPath
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;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 };
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 std::vector<PrefixItem> prefix_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 Orthanc::DicomTag finalTag_;
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 static DicomTag ParseTag(const std::string& token);
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 const PrefixItem& GetLevel(size_t i) const;
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 public:
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 explicit DicomPath(const Orthanc::DicomTag& tag) :
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 finalTag_(tag)
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
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
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
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 void AddIndexedTagToPrefix(const Orthanc::DicomTag& tag,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 size_t index);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 void AddUniversalTagToPrefix(const Orthanc::DicomTag& tag);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 size_t GetPrefixLength() const
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 return prefix_.size();
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 const Orthanc::DicomTag& GetFinalTag() const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 return finalTag_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 const Orthanc::DicomTag& GetPrefixTag(size_t level) const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 return GetLevel(level).GetTag();
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 bool IsPrefixUniversal(size_t level) const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 return GetLevel(level).IsUniversal();
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 size_t GetPrefixIndex(size_t level) const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 return GetLevel(level).GetIndex();
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 std::string Format() const;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 static DicomPath Parse(const std::string& s,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 bool allowUniversal);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 };
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }