comparison OrthancServer/Sources/Search/DatabaseConstraint.cpp @ 5680:68fc5af30c03

added container class DatabaseConstraints
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Jul 2024 10:09:57 +0200
parents f7adfb22e20e
children 77875b51cf95
comparison
equal deleted inserted replaced
5678:e47ac5e133b1 5680:68fc5af30c03
243 constraint.type = Plugins::Convert(constraintType_); 243 constraint.type = Plugins::Convert(constraintType_);
244 constraint.valuesCount = values_.size(); 244 constraint.valuesCount = values_.size();
245 constraint.values = (tmpValues.empty() ? NULL : &tmpValues[0]); 245 constraint.values = (tmpValues.empty() ? NULL : &tmpValues[0]);
246 } 246 }
247 #endif 247 #endif
248
249
250 void DatabaseConstraints::Clear()
251 {
252 for (size_t i = 0; i < constraints_.size(); i++)
253 {
254 assert(constraints_[i] != NULL);
255 delete constraints_[i];
256 }
257
258 constraints_.clear();
259 }
260
261
262 void DatabaseConstraints::AddConstraint(DatabaseConstraint* constraint)
263 {
264 if (constraint == NULL)
265 {
266 throw OrthancException(ErrorCode_NullPointer);
267 }
268 else
269 {
270 constraints_.push_back(constraint);
271 }
272 }
273
274
275 const DatabaseConstraint& DatabaseConstraints::GetConstraint(size_t index) const
276 {
277 if (index >= constraints_.size())
278 {
279 throw OrthancException(ErrorCode_ParameterOutOfRange);
280 }
281 else
282 {
283 assert(constraints_[index] != NULL);
284 return *constraints_[index];
285 }
286 }
248 } 287 }