comparison OrthancServer/ServerIndex.cpp @ 656:08eca5d86aad

fixes to cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Nov 2013 11:19:31 +0100
parents fb49bf72ac2d
children 3bdb5db8e839 2d0a347e8cfc
comparison
equal deleted inserted replaced
655:93adc693cc60 656:08eca5d86aad
89 89
90 void CommitFilesToRemove() 90 void CommitFilesToRemove()
91 { 91 {
92 for (std::list<std::string>::iterator 92 for (std::list<std::string>::iterator
93 it = pendingFilesToRemove_.begin(); 93 it = pendingFilesToRemove_.begin();
94 it != pendingFilesToRemove_.end(); it++) 94 it != pendingFilesToRemove_.end(); ++it)
95 { 95 {
96 context_.RemoveFile(*it); 96 context_.RemoveFile(*it);
97 } 97 }
98 } 98 }
99 99
288 288
289 static void ComputeExpectedNumberOfInstances(DatabaseWrapper& db, 289 static void ComputeExpectedNumberOfInstances(DatabaseWrapper& db,
290 int64_t series, 290 int64_t series,
291 const DicomMap& dicomSummary) 291 const DicomMap& dicomSummary)
292 { 292 {
293 const DicomValue* value; 293 try
294 const DicomValue* value2; 294 {
295 const DicomValue* value;
296 const DicomValue* value2;
295 297
296 try
297 {
298 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL && 298 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL &&
299 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS)) != NULL) 299 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS)) != NULL)
300 { 300 {
301 // Patch for series with temporal positions thanks to Will Ryder 301 // Patch for series with temporal positions thanks to Will Ryder
302 int64_t imagesInAcquisition = boost::lexical_cast<int64_t>(value->AsString()); 302 int64_t imagesInAcquisition = boost::lexical_cast<int64_t>(value->AsString());
405 } 405 }
406 406
407 // Ensure there is enough room in the storage for the new instance 407 // Ensure there is enough room in the storage for the new instance
408 uint64_t instanceSize = 0; 408 uint64_t instanceSize = 0;
409 for (Attachments::const_iterator it = attachments.begin(); 409 for (Attachments::const_iterator it = attachments.begin();
410 it != attachments.end(); it++) 410 it != attachments.end(); ++it)
411 { 411 {
412 instanceSize += it->GetCompressedSize(); 412 instanceSize += it->GetCompressedSize();
413 } 413 }
414 414
415 Recycle(instanceSize, hasher.HashPatient()); 415 Recycle(instanceSize, hasher.HashPatient());
510 assert(series != -1); 510 assert(series != -1);
511 assert(instance != -1); 511 assert(instance != -1);
512 512
513 // Attach the files to the newly created instance 513 // Attach the files to the newly created instance
514 for (Attachments::const_iterator it = attachments.begin(); 514 for (Attachments::const_iterator it = attachments.begin();
515 it != attachments.end(); it++) 515 it != attachments.end(); ++it)
516 { 516 {
517 db_->AddAttachment(instance, *it); 517 db_->AddAttachment(instance, *it);
518 } 518 }
519 519
520 // Attach the metadata 520 // Attach the metadata
591 591
592 size_t expected; 592 size_t expected;
593 try 593 try
594 { 594 {
595 expected = boost::lexical_cast<size_t>(s); 595 expected = boost::lexical_cast<size_t>(s);
596 if (expected < 0)
597 {
598 return SeriesStatus_Unknown;
599 }
600 } 596 }
601 catch (boost::bad_lexical_cast&) 597 catch (boost::bad_lexical_cast&)
602 { 598 {
603 return SeriesStatus_Unknown; 599 return SeriesStatus_Unknown;
604 } 600 }
607 std::list<int64_t> children; 603 std::list<int64_t> children;
608 db_->GetChildrenInternalId(children, id); 604 db_->GetChildrenInternalId(children, id);
609 605
610 std::set<size_t> instances; 606 std::set<size_t> instances;
611 for (std::list<int64_t>::const_iterator 607 for (std::list<int64_t>::const_iterator
612 it = children.begin(); it != children.end(); it++) 608 it = children.begin(); it != children.end(); ++it)
613 { 609 {
614 // Get the index of this instance in the series 610 // Get the index of this instance in the series
615 s = db_->GetMetadata(*it, MetadataType_Instance_IndexInSeries); 611 s = db_->GetMetadata(*it, MetadataType_Instance_IndexInSeries);
616 size_t index; 612 size_t index;
617 try 613 try
621 catch (boost::bad_lexical_cast&) 617 catch (boost::bad_lexical_cast&)
622 { 618 {
623 return SeriesStatus_Unknown; 619 return SeriesStatus_Unknown;
624 } 620 }
625 621
626 if (index <= 0 || index > expected) 622 if (!(index > 0 && index <= expected))
627 { 623 {
628 // Out-of-range instance index 624 // Out-of-range instance index
629 return SeriesStatus_Inconsistent; 625 return SeriesStatus_Inconsistent;
630 } 626 }
631 627
713 if (type != ResourceType_Instance) 709 if (type != ResourceType_Instance)
714 { 710 {
715 Json::Value c = Json::arrayValue; 711 Json::Value c = Json::arrayValue;
716 712
717 for (std::list<std::string>::const_iterator 713 for (std::list<std::string>::const_iterator
718 it = children.begin(); it != children.end(); it++) 714 it = children.begin(); it != children.end(); ++it)
719 { 715 {
720 c.append(*it); 716 c.append(*it);
721 } 717 }
722 718
723 switch (type) 719 switch (type)
1151 else 1147 else
1152 { 1148 {
1153 // Tag all the children of this resource as to be explored 1149 // Tag all the children of this resource as to be explored
1154 db_->GetChildrenInternalId(tmp, resource); 1150 db_->GetChildrenInternalId(tmp, resource);
1155 for (std::list<int64_t>::const_iterator 1151 for (std::list<int64_t>::const_iterator
1156 it = tmp.begin(); it != tmp.end(); it++) 1152 it = tmp.begin(); it != tmp.end(); ++it)
1157 { 1153 {
1158 toExplore.push(*it); 1154 toExplore.push(*it);
1159 } 1155 }
1160 } 1156 }
1161 } 1157 }
1330 { 1326 {
1331 std::list<FileContentType> f; 1327 std::list<FileContentType> f;
1332 db_->ListAvailableAttachments(f, resource); 1328 db_->ListAvailableAttachments(f, resource);
1333 1329
1334 for (std::list<FileContentType>::const_iterator 1330 for (std::list<FileContentType>::const_iterator
1335 it = f.begin(); it != f.end(); it++) 1331 it = f.begin(); it != f.end(); ++it)
1336 { 1332 {
1337 FileInfo attachment; 1333 FileInfo attachment;
1338 if (db_->LookupAttachment(attachment, resource, *it)) 1334 if (db_->LookupAttachment(attachment, resource, *it))
1339 { 1335 {
1340 compressedSize += attachment.GetCompressedSize(); 1336 compressedSize += attachment.GetCompressedSize();
1362 1358
1363 // Tag all the children of this resource as to be explored 1359 // Tag all the children of this resource as to be explored
1364 std::list<int64_t> tmp; 1360 std::list<int64_t> tmp;
1365 db_->GetChildrenInternalId(tmp, resource); 1361 db_->GetChildrenInternalId(tmp, resource);
1366 for (std::list<int64_t>::const_iterator 1362 for (std::list<int64_t>::const_iterator
1367 it = tmp.begin(); it != tmp.end(); it++) 1363 it = tmp.begin(); it != tmp.end(); ++it)
1368 { 1364 {
1369 toExplore.push(*it); 1365 toExplore.push(*it);
1370 } 1366 }
1371 } 1367 }
1372 } 1368 }
1532 1528
1533 std::list<int64_t> id; 1529 std::list<int64_t> id;
1534 db_->LookupTagValue(id, tag, value); 1530 db_->LookupTagValue(id, tag, value);
1535 1531
1536 for (std::list<int64_t>::const_iterator 1532 for (std::list<int64_t>::const_iterator
1537 it = id.begin(); it != id.end(); it++) 1533 it = id.begin(); it != id.end(); ++it)
1538 { 1534 {
1539 if (db_->GetResourceType(*it) == type) 1535 if (db_->GetResourceType(*it) == type)
1540 { 1536 {
1541 result.push_back(db_->GetPublicId(*it)); 1537 result.push_back(db_->GetPublicId(*it));
1542 } 1538 }
1554 1550
1555 std::list<int64_t> id; 1551 std::list<int64_t> id;
1556 db_->LookupTagValue(id, tag, value); 1552 db_->LookupTagValue(id, tag, value);
1557 1553
1558 for (std::list<int64_t>::const_iterator 1554 for (std::list<int64_t>::const_iterator
1559 it = id.begin(); it != id.end(); it++) 1555 it = id.begin(); it != id.end(); ++it)
1560 { 1556 {
1561 result.push_back(db_->GetPublicId(*it)); 1557 result.push_back(db_->GetPublicId(*it));
1562 } 1558 }
1563 } 1559 }
1564 1560
1572 1568
1573 std::list<int64_t> id; 1569 std::list<int64_t> id;
1574 db_->LookupTagValue(id, value); 1570 db_->LookupTagValue(id, value);
1575 1571
1576 for (std::list<int64_t>::const_iterator 1572 for (std::list<int64_t>::const_iterator
1577 it = id.begin(); it != id.end(); it++) 1573 it = id.begin(); it != id.end(); ++it)
1578 { 1574 {
1579 result.push_back(db_->GetPublicId(*it)); 1575 result.push_back(db_->GetPublicId(*it));
1580 } 1576 }
1581 } 1577 }
1582 } 1578 }