Mercurial > hg > orthanc
annotate OrthancServer/Sources/Database/ResourcesContent.h @ 5653:5e99cf9eebcf Orthanc-1.12.4
Orthanc-1.12.4
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Jun 2024 17:44:48 +0200 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
3094 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5215
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3094 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
4045 | 26 #include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h" |
3094 | 27 #include "../ServerEnumerations.h" |
28 | |
29 #include <boost/noncopyable.hpp> | |
30 #include <list> | |
31 | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
32 |
3094 | 33 namespace Orthanc |
34 { | |
35 namespace Compatibility | |
36 { | |
37 class ISetResourcesContent; | |
38 } | |
39 | |
40 class ResourcesContent : public boost::noncopyable | |
41 { | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
42 public: |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
43 class TagValue |
3094 | 44 { |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
45 private: |
3094 | 46 int64_t resourceId_; |
47 bool isIdentifier_; | |
48 DicomTag tag_; | |
49 std::string value_; | |
50 | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
51 public: |
3094 | 52 TagValue(int64_t resourceId, |
53 bool isIdentifier, | |
54 const DicomTag& tag, | |
55 const std::string& value) : | |
56 resourceId_(resourceId), | |
57 isIdentifier_(isIdentifier), | |
58 tag_(tag), | |
59 value_(value) | |
60 { | |
61 } | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
62 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
63 int64_t GetResourceId() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
64 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
65 return resourceId_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
66 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
67 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
68 bool IsIdentifier() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
69 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
70 return isIdentifier_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
71 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
72 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
73 const DicomTag& GetTag() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
74 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
75 return tag_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
76 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
77 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
78 const std::string& GetValue() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
79 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
80 return value_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
81 } |
3094 | 82 }; |
83 | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
84 class Metadata |
3094 | 85 { |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
86 private: |
3094 | 87 int64_t resourceId_; |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
88 MetadataType type_; |
3094 | 89 std::string value_; |
90 | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
91 public: |
3094 | 92 Metadata(int64_t resourceId, |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
93 MetadataType type, |
3094 | 94 const std::string& value) : |
95 resourceId_(resourceId), | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
96 type_(type), |
3094 | 97 value_(value) |
98 { | |
99 } | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
100 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
101 int64_t GetResourceId() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
102 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
103 return resourceId_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
104 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
105 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
106 MetadataType GetType() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
107 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
108 return type_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
109 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
110 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
111 const std::string& GetValue() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
112 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
113 return value_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
114 } |
3094 | 115 }; |
116 | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
117 typedef std::list<TagValue> ListTags; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
118 typedef std::list<Metadata> ListMetadata; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
119 |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
120 private: |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
121 bool isNewResource_; |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
122 ListTags tags_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
123 ListMetadata metadata_; |
3094 | 124 |
125 public: | |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
126 explicit ResourcesContent(bool isNewResource) : |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
127 isNewResource_(isNewResource) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
128 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
129 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
130 |
3094 | 131 void AddMainDicomTag(int64_t resourceId, |
132 const DicomTag& tag, | |
133 const std::string& value) | |
134 { | |
135 tags_.push_back(TagValue(resourceId, false, tag, value)); | |
136 } | |
137 | |
138 void AddIdentifierTag(int64_t resourceId, | |
139 const DicomTag& tag, | |
140 const std::string& value) | |
141 { | |
142 tags_.push_back(TagValue(resourceId, true, tag, value)); | |
143 } | |
144 | |
145 void AddMetadata(int64_t resourceId, | |
146 MetadataType metadata, | |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
147 const std::string& value); |
3094 | 148 |
149 void AddResource(int64_t resource, | |
150 ResourceType level, | |
151 const DicomMap& dicomSummary); | |
152 | |
153 // WARNING: The database should be locked with a transaction! | |
154 void Store(Compatibility::ISetResourcesContent& target) const; | |
155 | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
156 const ListTags& GetListTags() const |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
157 { |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
158 return tags_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
159 } |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
160 |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
161 const ListMetadata& GetListMetadata() const |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
162 { |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
163 return metadata_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
164 } |
3094 | 165 }; |
166 } |