diff 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
line wrap: on
line diff
--- a/OrthancServer/Search/LookupIdentifierQuery.h	Mon Oct 26 16:58:11 2015 +0100
+++ b/OrthancServer/Search/LookupIdentifierQuery.h	Mon Oct 26 17:33:55 2015 +0100
@@ -62,13 +62,15 @@
 
   class LookupIdentifierQuery : public boost::noncopyable
   {
-  private:
-    struct Constraint
+  public:
+    class Constraint
     {
+    private:
       DicomTag                  tag_;
       IdentifierConstraintType  type_;
       std::string               value_;
 
+    public:
       Constraint(const DicomTag& tag,
                  IdentifierConstraintType type,
                  const std::string& value) : 
@@ -77,15 +79,52 @@
         value_(value)
       {
       }
+
+      const DicomTag& GetTag() const
+      {
+        return tag_;
+      }
+
+      IdentifierConstraintType GetType() const
+      {
+        return type_;
+      }
+      
+      const std::string& GetValue() const
+      {
+        return value_;
+      }
     };
 
-    typedef std::vector<Constraint*>  Constraints;
+
+  private:
+    class Union
+    {
+    private:
+      std::vector<Constraint*>  union_;
+
+    public:
+      ~Union();
+
+      void Add(const Constraint& constraint);
+
+      size_t GetSize() const
+      {
+        return union_.size();
+      }
+
+      const Constraint&  GetConstraint(size_t i) const
+      {
+        return *union_[i];
+      }
+    };
+
+
+    typedef std::vector<Union*>  Constraints;
 
     ResourceType  level_;
     Constraints   constraints_;
 
-    void CheckIndex(size_t index) const;
-
     static std::string NormalizeIdentifier(const std::string& value);
 
   public:
@@ -95,12 +134,17 @@
 
     ~LookupIdentifierQuery();
 
-    bool IsIdentifier(const DicomTag& tag) const;
+    bool IsIdentifier(const DicomTag& tag)
+    {
+      return IsIdentifier(tag, level_);
+    }
 
     void AddConstraint(DicomTag tag,
                        IdentifierConstraintType type,
                        const std::string& value);
 
+    void AddDisjunction(const std::list<Constraint>& constraints);
+
     ResourceType GetLevel() const
     {
       return level_;
@@ -111,19 +155,16 @@
       return constraints_.size();
     }
 
-    const DicomTag& GetTag(size_t index) const;
+    // The database must be locked
+    void Apply(std::list<std::string>& result,
+               IDatabaseWrapper& database);
 
-    IdentifierConstraintType  GetType(size_t index) const;
-
-    const std::string& GetValue(size_t index) const;
+    static bool IsIdentifier(const DicomTag& tag,
+                             ResourceType level);
 
     static void StoreIdentifiers(IDatabaseWrapper& database,
                                  int64_t resource,
                                  ResourceType level,
                                  const DicomMap& map);
-
-    // The database must be locked
-    void Apply(std::list<std::string>& result,
-               IDatabaseWrapper& database);
   };
 }