annotate OrthancServer/Search/DicomTagConstraint.h @ 4541:73ea4f52965c Orthanc-1.7.1

close branch
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Mar 2021 16:52:17 +0100
parents 94f4a18a79cc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #pragma once
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../ServerEnumerations.h"
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../../Core/DicomFormat/DicomMap.h"
3073
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
38 #include "DatabaseConstraint.h"
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #include <boost/shared_ptr.hpp>
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 namespace Orthanc
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 class DicomTagConstraint : public boost::noncopyable
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 private:
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 class NormalizedString;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 class RegularExpression;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 DicomTag tag_;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 ConstraintType constraintType_;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 std::set<std::string> values_;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 bool caseSensitive_;
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
54 bool mandatory_;
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 boost::shared_ptr<RegularExpression> regex_;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
3055
71ac4f28176f compatibility layer seems to be working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3029
diff changeset
58 void AssignSingleValue(const std::string& value);
71ac4f28176f compatibility layer seems to be working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3029
diff changeset
59
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 public:
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 DicomTagConstraint(const DicomTag& tag,
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 ConstraintType type,
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 const std::string& value,
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
64 bool caseSensitive,
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
65 bool mandatory);
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
67 // For list search
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 DicomTagConstraint(const DicomTag& tag,
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 ConstraintType type,
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
70 bool caseSensitive,
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
71 bool mandatory);
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
3055
71ac4f28176f compatibility layer seems to be working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3029
diff changeset
73 DicomTagConstraint(const DatabaseConstraint& constraint);
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 const DicomTag& GetTag() const
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 return tag_;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 ConstraintType GetConstraintType() const
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 return constraintType_;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 bool IsCaseSensitive() const
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 return caseSensitive_;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
90 void SetCaseSensitive(bool caseSensitive)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
91 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
92 caseSensitive_ = caseSensitive;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
93 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
94
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
95 bool IsMandatory() const
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
96 {
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
97 return mandatory_;
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
98 }
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
99
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 void AddValue(const std::string& value);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 const std::string& GetValue() const;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 const std::set<std::string>& GetValues() const
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 return values_;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 bool IsMatch(const std::string& value);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 bool IsMatch(const DicomMap& value);
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
112
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
113 std::string Format() const;
3073
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
114
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
115 DatabaseConstraint ConvertToDatabaseConstraint(ResourceType level,
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
116 DicomTagType tagType) const;
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 };
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }