Mercurial > hg > orthanc
comparison OrthancServer/ExactResourceFinder.h @ 1357:216db29c5aa9
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 13 May 2015 15:56:41 +0200 |
parents | ab9f3d5910bd |
children |
comparison
equal
deleted
inserted
replaced
1356:ab9f3d5910bd | 1357:216db29c5aa9 |
---|---|
38 | 38 |
39 namespace Orthanc | 39 namespace Orthanc |
40 { | 40 { |
41 class ExactResourceFinder : public boost::noncopyable | 41 class ExactResourceFinder : public boost::noncopyable |
42 { | 42 { |
43 public: | |
44 class IMainTagsFilter : public boost::noncopyable | |
45 { | |
46 public: | |
47 virtual ~IMainTagsFilter() | |
48 { | |
49 } | |
50 | |
51 bool Apply(const DicomMap& mainTags, | |
52 ResourceType level); | |
53 }; | |
54 | |
55 | |
56 class IInstanceFilter : public boost::noncopyable | |
57 { | |
58 public: | |
59 virtual ~IInstanceFilter() | |
60 { | |
61 } | |
62 | |
63 bool Apply(const std::string& instanceId, | |
64 const Json::Value& content); | |
65 }; | |
66 | |
67 | |
43 private: | 68 private: |
44 typedef std::map<DicomTag, std::string> Query; | 69 typedef std::map<DicomTag, std::string> Identifiers; |
45 | 70 |
46 class CandidateResources; | 71 class CandidateResources; |
47 | 72 |
48 ServerIndex& index_; | 73 ServerContext& context_; |
49 ResourceType level_; | 74 ResourceType level_; |
50 bool caseSensitive_; | 75 size_t maxResults_; |
51 bool nonMainTagsIgnored_; | 76 Identifiers identifiers_; |
52 Query query_; | 77 IMainTagsFilter *mainTagsFilter_; |
53 | 78 IInstanceFilter *instanceFilter_; |
54 static void ExtractTagsForLevel(Query& result, | |
55 Query& source, | |
56 ResourceType level); | |
57 | 79 |
58 void ApplyAtLevel(CandidateResources& candidates, | 80 void ApplyAtLevel(CandidateResources& candidates, |
59 ResourceType level); | 81 ResourceType level); |
60 | 82 |
61 public: | 83 public: |
62 ExactResourceFinder(ServerIndex& index); | 84 ExactResourceFinder(ServerContext& context); |
63 | |
64 bool IsCaseSensitive() const | |
65 { | |
66 return caseSensitive_; | |
67 } | |
68 | |
69 void SetCaseSensitive(bool sensitive) | |
70 { | |
71 caseSensitive_ = sensitive; | |
72 } | |
73 | |
74 bool NonMainTagsIgnored() const | |
75 { | |
76 return nonMainTagsIgnored_; | |
77 } | |
78 | |
79 void SetNonMainTagsIgnored(bool ignored) | |
80 { | |
81 nonMainTagsIgnored_ = ignored; | |
82 } | |
83 | 85 |
84 ResourceType GetLevel() const | 86 ResourceType GetLevel() const |
85 { | 87 { |
86 return level_; | 88 return level_; |
87 } | 89 } |
89 void SetLevel(ResourceType level) | 91 void SetLevel(ResourceType level) |
90 { | 92 { |
91 level_ = level; | 93 level_ = level; |
92 } | 94 } |
93 | 95 |
94 void AddTag(const DicomTag& tag, | 96 void SetIdentifier(const DicomTag& tag, |
95 const std::string& value) | 97 const std::string& value); |
98 | |
99 void SetMainTagsFilter(IMainTagsFilter& filter) | |
96 { | 100 { |
97 query_.insert(std::make_pair(tag, value)); | 101 mainTagsFilter_ = &filter; |
98 } | 102 } |
99 | 103 |
100 void AddTag(const std::string& tag, | 104 void SetInstanceFilter(IInstanceFilter& filter) |
101 const std::string& value); | 105 { |
106 instanceFilter_ = &filter; | |
107 } | |
102 | 108 |
103 void Apply(std::list<std::string>& result); | 109 void SetMaxResults(size_t value) |
110 { | |
111 maxResults_ = value; | |
112 } | |
113 | |
114 size_t GetMaxResults() const | |
115 { | |
116 return maxResults_; | |
117 } | |
118 | |
119 // Returns "true" iff. all the matching resources have been | |
120 // returned. Will be "false" if the results were truncated by | |
121 // "SetMaxResults()". | |
122 bool Apply(std::list<std::string>& result); | |
104 }; | 123 }; |
105 | 124 |
106 } | 125 } |