comparison Plugins/Samples/ModalityWorklists/Plugin.cpp @ 2214:b1d93286b315

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 10 Dec 2016 11:24:58 +0100
parents 27106f7e3759
children 028214a95194
comparison
equal deleted inserted replaced
2213:95d1d758abb7 2214:b1d93286b315
32 32
33 33
34 /** 34 /**
35 * This is the main function for matching a DICOM worklist against a query. 35 * This is the main function for matching a DICOM worklist against a query.
36 **/ 36 **/
37 static void MatchWorklist(OrthancPluginWorklistAnswers* answers, 37 static void MatchWorklist(OrthancPluginWorklistAnswers* answers,
38 const OrthancPluginWorklistQuery* query, 38 const OrthancPluginWorklistQuery* query,
39 const OrthancPlugins::FindMatcher& matcher,
39 const std::string& path) 40 const std::string& path)
40 { 41 {
41 OrthancPlugins::MemoryBuffer dicom(context_); 42 OrthancPlugins::MemoryBuffer dicom(context_);
42 dicom.ReadFile(path); 43 dicom.ReadFile(path);
43 44
44 if (OrthancPluginWorklistIsMatch(context_, query, dicom.GetData(), dicom.GetSize())) 45 if (matcher.IsMatch(dicom))
45 { 46 {
46 // This DICOM file matches the worklist query, add it to the answers 47 // This DICOM file matches the worklist query, add it to the answers
47 OrthancPluginErrorCode code = OrthancPluginWorklistAddAnswer 48 OrthancPluginErrorCode code = OrthancPluginWorklistAddAnswer
48 (context_, answers, query, dicom.GetData(), dicom.GetSize()); 49 (context_, answers, query, dicom.GetData(), dicom.GetSize());
49 50
75 76
76 OrthancPlugins::LogInfo(context_, "Received worklist query from remote modality " + 77 OrthancPlugins::LogInfo(context_, "Received worklist query from remote modality " +
77 std::string(remoteAet) + ":\n" + json.toStyledString()); 78 std::string(remoteAet) + ":\n" + json.toStyledString());
78 } 79 }
79 80
81 OrthancPlugins::FindMatcher matcher(context_, query);
82
80 fs::path source(folder_); 83 fs::path source(folder_);
81 fs::directory_iterator end; 84 fs::directory_iterator end;
82 85
83 try 86 try
84 { 87 {
92 std::string extension = fs::extension(it->path()); 95 std::string extension = fs::extension(it->path());
93 std::transform(extension.begin(), extension.end(), extension.begin(), tolower); // Convert to lowercase 96 std::transform(extension.begin(), extension.end(), extension.begin(), tolower); // Convert to lowercase
94 97
95 if (extension == ".wl") 98 if (extension == ".wl")
96 { 99 {
97 MatchWorklist(answers, query, it->path().string()); 100 MatchWorklist(answers, query, matcher, it->path().string());
98 } 101 }
99 } 102 }
100 } 103 }
101 } 104 }
102 catch (fs::filesystem_error&) 105 catch (fs::filesystem_error&)