comparison OrthancServer/Search/LookupIdentifierQuery.h @ 1748:92203f713205 db-changes

IFindConstraint
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Oct 2015 17:33:55 +0100
parents ca69082ab200
children 99f4a05f39fa
comparison
equal deleted inserted replaced
1747:ca69082ab200 1748:92203f713205
60 * method "NormalizeIdentifier()". 60 * method "NormalizeIdentifier()".
61 **/ 61 **/
62 62
63 class LookupIdentifierQuery : public boost::noncopyable 63 class LookupIdentifierQuery : public boost::noncopyable
64 { 64 {
65 private: 65 public:
66 struct Constraint 66 class Constraint
67 { 67 {
68 private:
68 DicomTag tag_; 69 DicomTag tag_;
69 IdentifierConstraintType type_; 70 IdentifierConstraintType type_;
70 std::string value_; 71 std::string value_;
71 72
73 public:
72 Constraint(const DicomTag& tag, 74 Constraint(const DicomTag& tag,
73 IdentifierConstraintType type, 75 IdentifierConstraintType type,
74 const std::string& value) : 76 const std::string& value) :
75 tag_(tag), 77 tag_(tag),
76 type_(type), 78 type_(type),
77 value_(value) 79 value_(value)
78 { 80 {
79 } 81 }
82
83 const DicomTag& GetTag() const
84 {
85 return tag_;
86 }
87
88 IdentifierConstraintType GetType() const
89 {
90 return type_;
91 }
92
93 const std::string& GetValue() const
94 {
95 return value_;
96 }
80 }; 97 };
81 98
82 typedef std::vector<Constraint*> Constraints; 99
100 private:
101 class Union
102 {
103 private:
104 std::vector<Constraint*> union_;
105
106 public:
107 ~Union();
108
109 void Add(const Constraint& constraint);
110
111 size_t GetSize() const
112 {
113 return union_.size();
114 }
115
116 const Constraint& GetConstraint(size_t i) const
117 {
118 return *union_[i];
119 }
120 };
121
122
123 typedef std::vector<Union*> Constraints;
83 124
84 ResourceType level_; 125 ResourceType level_;
85 Constraints constraints_; 126 Constraints constraints_;
86
87 void CheckIndex(size_t index) const;
88 127
89 static std::string NormalizeIdentifier(const std::string& value); 128 static std::string NormalizeIdentifier(const std::string& value);
90 129
91 public: 130 public:
92 LookupIdentifierQuery(ResourceType level) : level_(level) 131 LookupIdentifierQuery(ResourceType level) : level_(level)
93 { 132 {
94 } 133 }
95 134
96 ~LookupIdentifierQuery(); 135 ~LookupIdentifierQuery();
97 136
98 bool IsIdentifier(const DicomTag& tag) const; 137 bool IsIdentifier(const DicomTag& tag)
138 {
139 return IsIdentifier(tag, level_);
140 }
99 141
100 void AddConstraint(DicomTag tag, 142 void AddConstraint(DicomTag tag,
101 IdentifierConstraintType type, 143 IdentifierConstraintType type,
102 const std::string& value); 144 const std::string& value);
145
146 void AddDisjunction(const std::list<Constraint>& constraints);
103 147
104 ResourceType GetLevel() const 148 ResourceType GetLevel() const
105 { 149 {
106 return level_; 150 return level_;
107 } 151 }
109 size_t GetSize() const 153 size_t GetSize() const
110 { 154 {
111 return constraints_.size(); 155 return constraints_.size();
112 } 156 }
113 157
114 const DicomTag& GetTag(size_t index) const; 158 // The database must be locked
159 void Apply(std::list<std::string>& result,
160 IDatabaseWrapper& database);
115 161
116 IdentifierConstraintType GetType(size_t index) const; 162 static bool IsIdentifier(const DicomTag& tag,
117 163 ResourceType level);
118 const std::string& GetValue(size_t index) const;
119 164
120 static void StoreIdentifiers(IDatabaseWrapper& database, 165 static void StoreIdentifiers(IDatabaseWrapper& database,
121 int64_t resource, 166 int64_t resource,
122 ResourceType level, 167 ResourceType level,
123 const DicomMap& map); 168 const DicomMap& map);
124
125 // The database must be locked
126 void Apply(std::list<std::string>& result,
127 IDatabaseWrapper& database);
128 }; 169 };
129 } 170 }