annotate OrthancServer/Search/LookupResource.cpp @ 1749:99f4a05f39fa db-changes

various types of constraints
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 27 Oct 2015 10:54:51 +0100
parents
children 55d52567bebb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1749
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "../PrecompiledHeadersServer.h"
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "LookupResource.h"
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../../Core/OrthancException.h"
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 namespace Orthanc
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 LookupResource::Level::Level(ResourceType level)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 const DicomTag* tags = NULL;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 size_t size;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 LookupIdentifierQuery::LoadIdentifiers(tags, size, level);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 for (size_t i = 0; i < size; i++)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 identifiers_.insert(tags[i]);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 DicomMap::LoadMainDicomTags(tags, size, level);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 for (size_t i = 0; i < size; i++)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 if (identifiers_.find(tags[i]) == identifiers_.end())
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 mainTags_.insert(tags[i]);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 LookupResource::Level::~Level()
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 for (Constraints::iterator it = mainTagsConstraints_.begin();
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 it != mainTagsConstraints_.end(); ++it)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 delete *it;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 for (Constraints::iterator it = identifiersConstraints_.begin();
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 it != identifiersConstraints_.end(); ++it)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 delete *it;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 bool LookupResource::Level::Add(std::auto_ptr<IFindConstraint>& constraint)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 if (identifiers_.find(constraint->GetTag()) != identifiers_.end())
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 identifiersConstraints_.push_back(constraint.release());
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 return true;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 else if (mainTags_.find(constraint->GetTag()) != mainTags_.end())
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 mainTagsConstraints_.push_back(constraint.release());
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 return true;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 else
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 return false;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 LookupResource::LookupResource(ResourceType level) : level_(level)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 switch (level)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 case ResourceType_Patient:
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 levels_[ResourceType_Patient] = new Level(ResourceType_Patient);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 break;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 case ResourceType_Study:
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 levels_[ResourceType_Study] = new Level(ResourceType_Study);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 // Do not add "break" here
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 case ResourceType_Series:
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 levels_[ResourceType_Series] = new Level(ResourceType_Series);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 // Do not add "break" here
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 case ResourceType_Instance:
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 levels_[ResourceType_Instance] = new Level(ResourceType_Instance);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 break;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 default:
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 throw OrthancException(ErrorCode_InternalError);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 LookupResource::~LookupResource()
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 for (Levels::iterator it = levels_.begin();
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 it != levels_.end(); ++it)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 delete it->second;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 for (Constraints::iterator it = unoptimizedConstraints_.begin();
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 it != unoptimizedConstraints_.end(); ++it)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 delete *it;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 bool LookupResource::AddInternal(ResourceType level,
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 std::auto_ptr<IFindConstraint>& constraint)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 Levels::iterator it = levels_.find(level);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 if (it != levels_.end())
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 if (it->second->Add(constraint))
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 return true;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 return false;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 void LookupResource::Add(IFindConstraint* constraint)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 std::auto_ptr<IFindConstraint> c(constraint);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 if (!AddInternal(ResourceType_Patient, c) &&
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 !AddInternal(ResourceType_Study, c) &&
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 !AddInternal(ResourceType_Series, c) &&
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 !AddInternal(ResourceType_Instance, c))
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 unoptimizedConstraints_.push_back(c.release());
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 static int64_t ChooseOneInstance(IDatabaseWrapper& database,
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 int64_t parent,
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 ResourceType type)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 for (;;)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 if (type == ResourceType_Instance)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 return parent;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 std::list<int64_t> children;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 database.GetChildrenInternalId(children, parent);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 if (children.empty())
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 throw OrthancException(ErrorCode_InternalError);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 parent = children.front();
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 type = GetChildResourceType(type);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 }