Mercurial > hg > orthanc
annotate OrthancServer/Sources/Database/ResourcesContent.h @ 5018:eb8ca3403983 lua-heart-beat
fix: lock mutex when accessing state in HeartBeatThread
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 14 Jun 2022 17:19:16 +0200 |
parents | 6eff25f70121 |
children | 0ea402b4d901 |
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 | |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3094 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU General Public License as | |
10 * published by the Free Software Foundation, either version 3 of the | |
11 * License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #pragma once | |
24 | |
4045 | 25 #include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h" |
3094 | 26 #include "../ServerEnumerations.h" |
27 | |
28 #include <boost/noncopyable.hpp> | |
29 #include <list> | |
30 | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
31 |
3094 | 32 namespace Orthanc |
33 { | |
34 namespace Compatibility | |
35 { | |
36 class ISetResourcesContent; | |
37 } | |
38 | |
39 class ResourcesContent : public boost::noncopyable | |
40 { | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
41 public: |
3094 | 42 struct TagValue |
43 { | |
44 int64_t resourceId_; | |
45 bool isIdentifier_; | |
46 DicomTag tag_; | |
47 std::string value_; | |
48 | |
49 TagValue(int64_t resourceId, | |
50 bool isIdentifier, | |
51 const DicomTag& tag, | |
52 const std::string& value) : | |
53 resourceId_(resourceId), | |
54 isIdentifier_(isIdentifier), | |
55 tag_(tag), | |
56 value_(value) | |
57 { | |
58 } | |
59 }; | |
60 | |
61 struct Metadata | |
62 { | |
63 int64_t resourceId_; | |
64 MetadataType metadata_; | |
65 std::string value_; | |
66 | |
67 Metadata(int64_t resourceId, | |
68 MetadataType metadata, | |
69 const std::string& value) : | |
70 resourceId_(resourceId), | |
71 metadata_(metadata), | |
72 value_(value) | |
73 { | |
74 } | |
75 }; | |
76 | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
77 typedef std::list<TagValue> ListTags; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
78 typedef std::list<Metadata> ListMetadata; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
79 |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
80 private: |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
81 bool isNewResource_; |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
82 ListTags tags_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
83 ListMetadata metadata_; |
3094 | 84 |
85 public: | |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
86 explicit ResourcesContent(bool isNewResource) : |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
87 isNewResource_(isNewResource) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
88 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
89 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
90 |
3094 | 91 void AddMainDicomTag(int64_t resourceId, |
92 const DicomTag& tag, | |
93 const std::string& value) | |
94 { | |
95 tags_.push_back(TagValue(resourceId, false, tag, value)); | |
96 } | |
97 | |
98 void AddIdentifierTag(int64_t resourceId, | |
99 const DicomTag& tag, | |
100 const std::string& value) | |
101 { | |
102 tags_.push_back(TagValue(resourceId, true, tag, value)); | |
103 } | |
104 | |
105 void AddMetadata(int64_t resourceId, | |
106 MetadataType metadata, | |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
107 const std::string& value); |
3094 | 108 |
109 void AddResource(int64_t resource, | |
110 ResourceType level, | |
111 const DicomMap& dicomSummary); | |
112 | |
113 // WARNING: The database should be locked with a transaction! | |
114 void Store(Compatibility::ISetResourcesContent& target) const; | |
115 | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
116 const ListTags& GetListTags() const |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
117 { |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
118 return tags_; |
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 |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
121 const ListMetadata& GetListMetadata() const |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
122 { |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
123 return metadata_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
124 } |
3094 | 125 }; |
126 } |