comparison OrthancServer/Sources/Database/FindResponse.cpp @ 5565:def06a42e5ef find-refactoring

Updated FindRequest & FindResponse definitions
author Alain Mazy <am@orthanc.team>
date Tue, 23 Apr 2024 13:07:38 +0200
parents 12d8a1a266e9
children b0b5546f1b9f
comparison
equal deleted inserted replaced
5554:12d8a1a266e9 5565:def06a42e5ef
112 throw OrthancException(ErrorCode_NotImplemented); 112 throw OrthancException(ErrorCode_NotImplemented);
113 } 113 }
114 } 114 }
115 115
116 116
117 FindResponse::Item::Item(ResourceType level, 117 FindResponse::Item::Item(FindRequest::ResponseContent responseContent,
118 ResourceType level,
118 DicomMap* dicomMap /* takes ownership */) : 119 DicomMap* dicomMap /* takes ownership */) :
120 responseContent_(responseContent),
119 level_(level), 121 level_(level),
120 dicomMap_(dicomMap) 122 dicomMap_(dicomMap)
121 { 123 {
122 if (dicomMap == NULL) 124 if (dicomMap == NULL)
123 { 125 {
129 } 131 }
130 } 132 }
131 133
132 134
133 void FindResponse::Item::AddMetadata(MetadataType metadata, 135 void FindResponse::Item::AddMetadata(MetadataType metadata,
134 const std::string& value) 136 const std::string& value,
137 int64_t revision)
135 { 138 {
136 if (metadata_.find(metadata) != metadata_.end()) 139 if (metadata_.find(metadata) != metadata_.end())
137 { 140 {
138 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present 141 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present
139 } 142 }
140 else 143 else
141 { 144 {
142 metadata_[metadata] = value; 145 metadata_[metadata] = StringWithRevision(value, revision);
143 } 146 }
144 } 147 }
145 148
146 149
147 bool FindResponse::Item::LookupMetadata(std::string& value, 150 bool FindResponse::Item::LookupMetadata(std::string& value,
151 int64_t revision,
148 MetadataType metadata) const 152 MetadataType metadata) const
149 { 153 {
150 std::map<MetadataType, std::string>::const_iterator found = metadata_.find(metadata); 154 std::map<MetadataType, StringWithRevision>::const_iterator found = metadata_.find(metadata);
151 155
152 if (found == metadata_.end()) 156 if (found == metadata_.end())
153 { 157 {
154 return false; 158 return false;
155 } 159 }
156 else 160 else
157 { 161 {
158 value = found->second; 162 value = found->second.GetValue();
163 revision = found->second.GetRevision();
159 return true; 164 return true;
160 } 165 }
161 } 166 }
162 167
163 168
164 void FindResponse::Item::ListMetadata(std::set<MetadataType> target) const 169 void FindResponse::Item::ListMetadata(std::set<MetadataType>& target) const
165 { 170 {
166 target.clear(); 171 target.clear();
167 172
168 for (std::map<MetadataType, std::string>::const_iterator it = metadata_.begin(); it != metadata_.end(); ++it) 173 for (std::map<MetadataType, StringWithRevision>::const_iterator it = metadata_.begin(); it != metadata_.end(); ++it)
169 { 174 {
170 target.insert(it->first); 175 target.insert(it->first);
171 } 176 }
172 } 177 }
173 178