comparison OrthancServer/OrthancRestApi.cpp @ 656:08eca5d86aad

fixes to cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Nov 2013 11:19:31 +0100
parents 3a74026fc1b1
children 95b4c6d89c42
comparison
equal deleted inserted replaced
655:93adc693cc60 656:08eca5d86aad
314 context.GetIndex().LogExportedResource(stripped, remote); 314 context.GetIndex().LogExportedResource(stripped, remote);
315 315
316 std::list<std::string> tmp; 316 std::list<std::string> tmp;
317 context.GetIndex().GetChildInstances(tmp, stripped); 317 context.GetIndex().GetChildInstances(tmp, stripped);
318 instances.merge(tmp); 318 instances.merge(tmp);
319 assert(tmp.size() == 0); 319 assert(tmp.empty());
320 } 320 }
321 } 321 }
322 else 322 else
323 { 323 {
324 // Neither a string, nor a list of strings. Bad request. 324 // Neither a string, nor a list of strings. Bad request.
343 343
344 DicomUserConnection connection; 344 DicomUserConnection connection;
345 ConnectToModalityUsingSymbolicName(connection, remote); 345 ConnectToModalityUsingSymbolicName(connection, remote);
346 346
347 for (std::list<std::string>::const_iterator 347 for (std::list<std::string>::const_iterator
348 it = instances.begin(); it != instances.end(); it++) 348 it = instances.begin(); it != instances.end(); ++it)
349 { 349 {
350 LOG(INFO) << "Sending resource " << *it << " to modality \"" << remote << "\""; 350 LOG(INFO) << "Sending resource " << *it << " to modality \"" << remote << "\"";
351 351
352 std::string dicom; 352 std::string dicom;
353 context.ReadFile(dicom, *it, FileContentType_Dicom); 353 context.ReadFile(dicom, *it, FileContentType_Dicom);
985 { 985 {
986 RETRIEVE_MODALITIES(call); 986 RETRIEVE_MODALITIES(call);
987 987
988 Json::Value result = Json::arrayValue; 988 Json::Value result = Json::arrayValue;
989 for (OrthancRestApi::SetOfStrings::const_iterator 989 for (OrthancRestApi::SetOfStrings::const_iterator
990 it = modalities.begin(); it != modalities.end(); it++) 990 it = modalities.begin(); it != modalities.end(); ++it)
991 { 991 {
992 result.append(*it); 992 result.append(*it);
993 } 993 }
994 994
995 call.GetOutput().AnswerJson(result); 995 call.GetOutput().AnswerJson(result);
1049 { 1049 {
1050 toModify.RemovePrivateTags(); 1050 toModify.RemovePrivateTags();
1051 } 1051 }
1052 1052
1053 for (Removals::const_iterator it = removals.begin(); 1053 for (Removals::const_iterator it = removals.begin();
1054 it != removals.end(); it++) 1054 it != removals.end(); ++it)
1055 { 1055 {
1056 toModify.Remove(*it); 1056 toModify.Remove(*it);
1057 } 1057 }
1058 1058
1059 for (Replacements::const_iterator it = replacements.begin(); 1059 for (Replacements::const_iterator it = replacements.begin();
1060 it != replacements.end(); it++) 1060 it != replacements.end(); ++it)
1061 { 1061 {
1062 toModify.Replace(it->first, it->second, mode); 1062 toModify.Replace(it->first, it->second, mode);
1063 } 1063 }
1064 1064
1065 // A new SOP instance UID is automatically generated 1065 // A new SOP instance UID is automatically generated
1268 Removals toKeep; 1268 Removals toKeep;
1269 ParseRemovals(toKeep, keepPart); 1269 ParseRemovals(toKeep, keepPart);
1270 1270
1271 SetupAnonymization(removals, replacements); 1271 SetupAnonymization(removals, replacements);
1272 1272
1273 for (Removals::iterator it = toKeep.begin(); it != toKeep.end(); it++) 1273 for (Removals::iterator it = toKeep.begin(); it != toKeep.end(); ++it)
1274 { 1274 {
1275 if (*it == DICOM_TAG_PATIENT_ID) 1275 if (*it == DICOM_TAG_PATIENT_ID)
1276 { 1276 {
1277 keepPatientId = true; 1277 keepPatientId = true;
1278 } 1278 }
1282 1282
1283 Removals additionalRemovals; 1283 Removals additionalRemovals;
1284 ParseRemovals(additionalRemovals, removalsPart); 1284 ParseRemovals(additionalRemovals, removalsPart);
1285 1285
1286 for (Removals::iterator it = additionalRemovals.begin(); 1286 for (Removals::iterator it = additionalRemovals.begin();
1287 it != additionalRemovals.end(); it++) 1287 it != additionalRemovals.end(); ++it)
1288 { 1288 {
1289 removals.insert(*it); 1289 removals.insert(*it);
1290 } 1290 }
1291 1291
1292 ParseReplacements(replacements, replacementsPart); 1292 ParseReplacements(replacements, replacementsPart);
1395 1395
1396 Instances instances; 1396 Instances instances;
1397 std::string id = call.GetUriComponent("id", ""); 1397 std::string id = call.GetUriComponent("id", "");
1398 context.GetIndex().GetChildInstances(instances, id); 1398 context.GetIndex().GetChildInstances(instances, id);
1399 1399
1400 if (instances.size() == 0) 1400 if (instances.empty())
1401 { 1401 {
1402 return; 1402 return;
1403 } 1403 }
1404
1405 1404
1406 /** 1405 /**
1407 * Loop over all the instances of the resource. 1406 * Loop over all the instances of the resource.
1408 **/ 1407 **/
1409 1408
1410 UidMap uidMap; 1409 UidMap uidMap;
1411 for (Instances::const_iterator it = instances.begin(); 1410 for (Instances::const_iterator it = instances.begin();
1412 it != instances.end(); it++) 1411 it != instances.end(); ++it)
1413 { 1412 {
1414 LOG(INFO) << "Modifying instance " << *it; 1413 LOG(INFO) << "Modifying instance " << *it;
1415 ParsedDicomFile& original = context.GetDicomFile(*it); 1414 ParsedDicomFile& original = context.GetDicomFile(*it);
1416 1415
1417 DicomInstanceHasher originalHasher = original.GetHasher(); 1416 DicomInstanceHasher originalHasher = original.GetHasher();
1660 if (context.GetIndex().ListAvailableMetadata(metadata, publicId)) 1659 if (context.GetIndex().ListAvailableMetadata(metadata, publicId))
1661 { 1660 {
1662 Json::Value result = Json::arrayValue; 1661 Json::Value result = Json::arrayValue;
1663 1662
1664 for (std::list<MetadataType>::const_iterator 1663 for (std::list<MetadataType>::const_iterator
1665 it = metadata.begin(); it != metadata.end(); it++) 1664 it = metadata.begin(); it != metadata.end(); ++it)
1666 { 1665 {
1667 result.append(EnumerationToString(*it)); 1666 result.append(EnumerationToString(*it));
1668 } 1667 }
1669 1668
1670 call.GetOutput().AnswerJson(result); 1669 call.GetOutput().AnswerJson(result);
1748 { 1747 {
1749 RETRIEVE_PEERS(call); 1748 RETRIEVE_PEERS(call);
1750 1749
1751 Json::Value result = Json::arrayValue; 1750 Json::Value result = Json::arrayValue;
1752 for (OrthancRestApi::SetOfStrings::const_iterator 1751 for (OrthancRestApi::SetOfStrings::const_iterator
1753 it = peers.begin(); it != peers.end(); it++) 1752 it = peers.begin(); it != peers.end(); ++it)
1754 { 1753 {
1755 result.append(*it); 1754 result.append(*it);
1756 } 1755 }
1757 1756
1758 call.GetOutput().AnswerJson(result); 1757 call.GetOutput().AnswerJson(result);
1796 client.SetUrl(url + "instances"); 1795 client.SetUrl(url + "instances");
1797 client.SetMethod(HttpMethod_Post); 1796 client.SetMethod(HttpMethod_Post);
1798 1797
1799 // Loop over the instances that are to be sent 1798 // Loop over the instances that are to be sent
1800 for (std::list<std::string>::const_iterator 1799 for (std::list<std::string>::const_iterator
1801 it = instances.begin(); it != instances.end(); it++) 1800 it = instances.begin(); it != instances.end(); ++it)
1802 { 1801 {
1803 LOG(INFO) << "Sending resource " << *it << " to peer \"" << remote << "\""; 1802 LOG(INFO) << "Sending resource " << *it << " to peer \"" << remote << "\"";
1804 1803
1805 context.ReadFile(client.AccessPostData(), *it, FileContentType_Dicom); 1804 context.ReadFile(client.AccessPostData(), *it, FileContentType_Dicom);
1806 1805