Mercurial > hg > orthanc
comparison OrthancServer/Search/DicomTagConstraint.cpp @ 3025:039a9d262d64 db-changes
preparing to speed up find in databases
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 17 Dec 2018 17:05:28 +0100 |
parents | 1723cbba55c7 |
children | fd587cf51a89 |
comparison
equal
deleted
inserted
replaced
3024:ef17a587e10d | 3025:039a9d262d64 |
---|---|
95 | 95 |
96 | 96 |
97 DicomTagConstraint::DicomTagConstraint(const DicomTag& tag, | 97 DicomTagConstraint::DicomTagConstraint(const DicomTag& tag, |
98 ConstraintType type, | 98 ConstraintType type, |
99 const std::string& value, | 99 const std::string& value, |
100 bool caseSensitive) : | 100 bool caseSensitive, |
101 hasTagInfo_(false), | 101 bool mandatory) : |
102 tagType_(DicomTagType_Generic), // Dummy initialization | |
103 level_(ResourceType_Patient), // Dummy initialization | |
104 tag_(tag), | 102 tag_(tag), |
105 constraintType_(type), | 103 constraintType_(type), |
106 caseSensitive_(caseSensitive) | 104 caseSensitive_(caseSensitive), |
105 mandatory_(mandatory) | |
107 { | 106 { |
108 if (type == ConstraintType_Equal || | 107 if (type == ConstraintType_Equal || |
109 type == ConstraintType_SmallerOrEqual || | 108 type == ConstraintType_SmallerOrEqual || |
110 type == ConstraintType_GreaterOrEqual || | 109 type == ConstraintType_GreaterOrEqual || |
111 type == ConstraintType_Wildcard) | 110 type == ConstraintType_Wildcard) |
126 } | 125 } |
127 | 126 |
128 | 127 |
129 DicomTagConstraint::DicomTagConstraint(const DicomTag& tag, | 128 DicomTagConstraint::DicomTagConstraint(const DicomTag& tag, |
130 ConstraintType type, | 129 ConstraintType type, |
131 bool caseSensitive) : | 130 bool caseSensitive, |
132 hasTagInfo_(false), | 131 bool mandatory) : |
133 tagType_(DicomTagType_Generic), // Dummy initialization | |
134 level_(ResourceType_Patient), // Dummy initialization | |
135 tag_(tag), | 132 tag_(tag), |
136 constraintType_(type), | 133 constraintType_(type), |
137 caseSensitive_(caseSensitive) | 134 caseSensitive_(caseSensitive), |
135 mandatory_(mandatory) | |
138 { | 136 { |
139 if (type != ConstraintType_List) | 137 if (type != ConstraintType_List) |
140 { | 138 { |
141 throw OrthancException(ErrorCode_ParameterOutOfRange); | 139 throw OrthancException(ErrorCode_ParameterOutOfRange); |
142 } | |
143 } | |
144 | |
145 | |
146 void DicomTagConstraint::SetTagInfo(DicomTagType tagType, | |
147 ResourceType level) | |
148 { | |
149 hasTagInfo_ = true; | |
150 tagType_ = tagType; | |
151 level_ = level; | |
152 } | |
153 | |
154 | |
155 DicomTagType DicomTagConstraint::GetTagType() const | |
156 { | |
157 if (!hasTagInfo_) | |
158 { | |
159 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
160 } | |
161 else | |
162 { | |
163 return tagType_; | |
164 } | |
165 } | |
166 | |
167 | |
168 const ResourceType DicomTagConstraint::GetLevel() const | |
169 { | |
170 if (!hasTagInfo_) | |
171 { | |
172 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
173 } | |
174 else | |
175 { | |
176 return level_; | |
177 } | 140 } |
178 } | 141 } |
179 | 142 |
180 | 143 |
181 void DicomTagConstraint::AddValue(const std::string& value) | 144 void DicomTagConstraint::AddValue(const std::string& value) |
266 bool DicomTagConstraint::IsMatch(const DicomMap& value) | 229 bool DicomTagConstraint::IsMatch(const DicomMap& value) |
267 { | 230 { |
268 const DicomValue* tmp = value.TestAndGetValue(tag_); | 231 const DicomValue* tmp = value.TestAndGetValue(tag_); |
269 | 232 |
270 if (tmp == NULL || | 233 if (tmp == NULL || |
271 tmp->IsNull() || | 234 tmp->IsNull()) |
272 tmp->IsBinary()) | 235 { |
236 if (mandatory_) | |
237 { | |
238 return false; | |
239 } | |
240 else | |
241 { | |
242 return true; | |
243 } | |
244 } | |
245 else if (tmp->IsBinary()) | |
273 { | 246 { |
274 return false; | 247 return false; |
275 } | 248 } |
276 else | 249 else |
277 { | 250 { |