comparison OrthancServer/Search/LookupIdentifierQuery.cpp @ 2696:1b736d151ea1 jobs

renames
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 03 Jul 2018 15:07:41 +0200
parents 878b59270859
children e583478e0c6c
comparison
equal deleted inserted replaced
2695:c4ee0bedb51b 2696:1b736d151ea1
44 44
45 namespace Orthanc 45 namespace Orthanc
46 { 46 {
47 LookupIdentifierQuery::Disjunction::~Disjunction() 47 LookupIdentifierQuery::Disjunction::~Disjunction()
48 { 48 {
49 for (size_t i = 0; i < disjunction_.size(); i++) 49 for (size_t i = 0; i < constraints_.size(); i++)
50 { 50 {
51 delete disjunction_[i]; 51 delete constraints_[i];
52 } 52 }
53 } 53 }
54 54
55 55
56 void LookupIdentifierQuery::Disjunction::Add(const DicomTag& tag, 56 void LookupIdentifierQuery::Disjunction::Add(const DicomTag& tag,
57 IdentifierConstraintType type, 57 IdentifierConstraintType type,
58 const std::string& value) 58 const std::string& value)
59 { 59 {
60 disjunction_.push_back(new Constraint(tag, type, value)); 60 constraints_.push_back(new Constraint(tag, type, value));
61 } 61 }
62 62
63 63
64 LookupIdentifierQuery::~LookupIdentifierQuery() 64 LookupIdentifierQuery::~LookupIdentifierQuery()
65 { 65 {
66 for (Constraints::iterator it = constraints_.begin(); 66 for (Disjuntions::iterator it = disjuntions_.begin();
67 it != constraints_.end(); ++it) 67 it != disjuntions_.end(); ++it)
68 { 68 {
69 delete *it; 69 delete *it;
70 } 70 }
71 } 71 }
72 72
74 void LookupIdentifierQuery::AddConstraint(DicomTag tag, 74 void LookupIdentifierQuery::AddConstraint(DicomTag tag,
75 IdentifierConstraintType type, 75 IdentifierConstraintType type,
76 const std::string& value) 76 const std::string& value)
77 { 77 {
78 assert(IsIdentifier(tag)); 78 assert(IsIdentifier(tag));
79 constraints_.push_back(new Disjunction); 79 disjuntions_.push_back(new Disjunction);
80 constraints_.back()->Add(tag, type, value); 80 disjuntions_.back()->Add(tag, type, value);
81 } 81 }
82 82
83 83
84 LookupIdentifierQuery::Disjunction& LookupIdentifierQuery::AddDisjunction() 84 LookupIdentifierQuery::Disjunction& LookupIdentifierQuery::AddDisjunction()
85 { 85 {
86 constraints_.push_back(new Disjunction); 86 disjuntions_.push_back(new Disjunction);
87 return *constraints_.back(); 87 return *disjuntions_.back();
88 } 88 }
89 89
90 90
91 void LookupIdentifierQuery::Apply(std::list<std::string>& result, 91 void LookupIdentifierQuery::Apply(std::list<std::string>& result,
92 IDatabaseWrapper& database) 92 IDatabaseWrapper& database)
103 { 103 {
104 for (size_t i = 0; i < GetSize(); i++) 104 for (size_t i = 0; i < GetSize(); i++)
105 { 105 {
106 std::list<int64_t> a; 106 std::list<int64_t> a;
107 107
108 for (size_t j = 0; j < constraints_[i]->GetSize(); j++) 108 for (size_t j = 0; j < disjuntions_[i]->GetSize(); j++)
109 { 109 {
110 const Constraint& constraint = constraints_[i]->GetConstraint(j); 110 const Constraint& constraint = disjuntions_[i]->GetConstraint(j);
111 std::list<int64_t> b; 111 std::list<int64_t> b;
112 database.LookupIdentifier(b, level_, constraint.GetTag(), constraint.GetType(), constraint.GetValue()); 112 database.LookupIdentifier(b, level_, constraint.GetTag(), constraint.GetType(), constraint.GetValue());
113 113
114 a.splice(a.end(), b); 114 a.splice(a.end(), b);
115 } 115 }
120 120
121 121
122 void LookupIdentifierQuery::Print(std::ostream& s) const 122 void LookupIdentifierQuery::Print(std::ostream& s) const
123 { 123 {
124 s << "Constraint: " << std::endl; 124 s << "Constraint: " << std::endl;
125 for (Constraints::const_iterator 125 for (Disjuntions::const_iterator
126 it = constraints_.begin(); it != constraints_.end(); ++it) 126 it = disjuntions_.begin(); it != disjuntions_.end(); ++it)
127 { 127 {
128 if (it == constraints_.begin()) 128 if (it == disjuntions_.begin())
129 s << " "; 129 s << " ";
130 else 130 else
131 s << "OR "; 131 s << "OR ";
132 132
133 for (size_t j = 0; j < (*it)->GetSize(); j++) 133 for (size_t j = 0; j < (*it)->GetSize(); j++)