comparison OrthancServer/LookupIdentifierQuery.cpp @ 1746:d143db00a794 db-changes

SetOfResources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Oct 2015 16:04:58 +0100
parents 38dda23c7d7d
children
comparison
equal deleted inserted replaced
1745:38dda23c7d7d 1746:d143db00a794
32 32
33 #include "PrecompiledHeadersServer.h" 33 #include "PrecompiledHeadersServer.h"
34 #include "LookupIdentifierQuery.h" 34 #include "LookupIdentifierQuery.h"
35 35
36 #include "../Core/OrthancException.h" 36 #include "../Core/OrthancException.h"
37 37 #include "SetOfResources.h"
38 38
39 #include <cassert> 39 #include <cassert>
40 40
41 41
42 42
68 static const DicomTag instanceIdentifiers[] = 68 static const DicomTag instanceIdentifiers[] =
69 { 69 {
70 DICOM_TAG_SOP_INSTANCE_UID 70 DICOM_TAG_SOP_INSTANCE_UID
71 }; 71 };
72 72
73
74 LookupIdentifierQuery::~LookupIdentifierQuery()
75 {
76 for (Constraints::iterator it = constraints_.begin();
77 it != constraints_.end(); ++it)
78 {
79 delete *it;
80 }
81 }
82
83
84
85 void LookupIdentifierQuery::CheckIndex(size_t index) const
86 {
87 if (index >= constraints_.size())
88 {
89 throw OrthancException(ErrorCode_ParameterOutOfRange);
90 }
91 }
92
93
94 static void LoadIdentifiers(const DicomTag*& tags, 73 static void LoadIdentifiers(const DicomTag*& tags,
95 size_t& size, 74 size_t& size,
96 ResourceType level) 75 ResourceType level)
97 { 76 {
98 switch (level) 77 switch (level)
117 size = sizeof(instanceIdentifiers) / sizeof(DicomTag); 96 size = sizeof(instanceIdentifiers) / sizeof(DicomTag);
118 break; 97 break;
119 98
120 default: 99 default:
121 throw OrthancException(ErrorCode_ParameterOutOfRange); 100 throw OrthancException(ErrorCode_ParameterOutOfRange);
101 }
102 }
103
104
105
106 LookupIdentifierQuery::~LookupIdentifierQuery()
107 {
108 for (Constraints::iterator it = constraints_.begin();
109 it != constraints_.end(); ++it)
110 {
111 delete *it;
112 }
113 }
114
115
116
117 void LookupIdentifierQuery::CheckIndex(size_t index) const
118 {
119 if (index >= constraints_.size())
120 {
121 throw OrthancException(ErrorCode_ParameterOutOfRange);
122 } 122 }
123 } 123 }
124 124
125 125
126 bool LookupIdentifierQuery::IsIdentifier(const DicomTag& tag) const 126 bool LookupIdentifierQuery::IsIdentifier(const DicomTag& tag) const
200 std::string s = NormalizeIdentifier(value->GetContent()); 200 std::string s = NormalizeIdentifier(value->GetContent());
201 database.SetIdentifierTag(resource, tags[i], s); 201 database.SetIdentifierTag(resource, tags[i], s);
202 } 202 }
203 } 203 }
204 } 204 }
205
206
207 void LookupIdentifierQuery::Apply(std::list<std::string>& result,
208 IDatabaseWrapper& database)
209 {
210 SetOfResources resources(database, level_);
211
212 for (size_t i = 0; i < GetSize(); i++)
213 {
214 std::list<int64_t> tmp;
215 database.LookupIdentifier(tmp, level_, GetTag(i), GetType(i), GetValue(i));
216 resources.Intersect(tmp);
217 }
218
219 resources.Flatten(result);
220 }
205 } 221 }