comparison OrthancServer/Sources/ServerIndex.cpp @ 4588:94147ce2f097 db-changes

fix build on os x
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Mar 2021 17:15:01 +0100
parents 888868a5dc4e
children bec74e29f86b
comparison
equal deleted inserted replaced
4587:888868a5dc4e 4588:94147ce2f097
385 return publicId_; 385 return publicId_;
386 } 386 }
387 }; 387 };
388 388
389 389
390 class ServerIndex::MainDicomTagsRegistry : public boost::noncopyable
391 {
392 private:
393 class TagInfo
394 {
395 private:
396 ResourceType level_;
397 DicomTagType type_;
398
399 public:
400 TagInfo()
401 {
402 }
403
404 TagInfo(ResourceType level,
405 DicomTagType type) :
406 level_(level),
407 type_(type)
408 {
409 }
410
411 ResourceType GetLevel() const
412 {
413 return level_;
414 }
415
416 DicomTagType GetType() const
417 {
418 return type_;
419 }
420 };
421
422 typedef std::map<DicomTag, TagInfo> Registry;
423
424
425 Registry registry_;
426
427 void LoadTags(ResourceType level)
428 {
429 {
430 const DicomTag* tags = NULL;
431 size_t size;
432
433 ServerToolbox::LoadIdentifiers(tags, size, level);
434
435 for (size_t i = 0; i < size; i++)
436 {
437 if (registry_.find(tags[i]) == registry_.end())
438 {
439 registry_[tags[i]] = TagInfo(level, DicomTagType_Identifier);
440 }
441 else
442 {
443 // These patient-level tags are copied in the study level
444 assert(level == ResourceType_Study &&
445 (tags[i] == DICOM_TAG_PATIENT_ID ||
446 tags[i] == DICOM_TAG_PATIENT_NAME ||
447 tags[i] == DICOM_TAG_PATIENT_BIRTH_DATE));
448 }
449 }
450 }
451
452 {
453 std::set<DicomTag> tags;
454 DicomMap::GetMainDicomTags(tags, level);
455
456 for (std::set<DicomTag>::const_iterator
457 tag = tags.begin(); tag != tags.end(); ++tag)
458 {
459 if (registry_.find(*tag) == registry_.end())
460 {
461 registry_[*tag] = TagInfo(level, DicomTagType_Main);
462 }
463 }
464 }
465 }
466
467 public:
468 MainDicomTagsRegistry()
469 {
470 LoadTags(ResourceType_Patient);
471 LoadTags(ResourceType_Study);
472 LoadTags(ResourceType_Series);
473 LoadTags(ResourceType_Instance);
474 }
475
476 void LookupTag(ResourceType& level,
477 DicomTagType& type,
478 const DicomTag& tag) const
479 {
480 Registry::const_iterator it = registry_.find(tag);
481
482 if (it == registry_.end())
483 {
484 // Default values
485 level = ResourceType_Instance;
486 type = DicomTagType_Generic;
487 }
488 else
489 {
490 level = it->second.GetLevel();
491 type = it->second.GetType();
492 }
493 }
494 };
495
496
497 void ServerIndex::FlushThread(ServerIndex* that, 390 void ServerIndex::FlushThread(ServerIndex* that,
498 unsigned int threadSleepGranularityMilliseconds) 391 unsigned int threadSleepGranularityMilliseconds)
499 { 392 {
500 // By default, wait for 10 seconds before flushing 393 // By default, wait for 10 seconds before flushing
501 static const unsigned int SLEEP_SECONDS = 10; 394 static const unsigned int SLEEP_SECONDS = 10;