comparison OrthancServer/Sources/Search/DatabaseConstraint.h @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents OrthancServer/Search/DatabaseConstraint.h@94f4a18a79cc
children 05b8fd21089c
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
11 *
12 * In addition, as a special exception, the copyright holders of this
13 * program give permission to link the code of its release with the
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
15 * that use the same license as the "OpenSSL" library), and distribute
16 * the linked executables. You must obey the GNU General Public License
17 * in all respects for all of the code used other than "OpenSSL". If you
18 * modify file(s) with this exception, you may extend this exception to
19 * your version of the file(s), but you are not obligated to do so. If
20 * you do not wish to do so, delete this exception statement from your
21 * version. If you delete this exception statement from all source files
22 * in the program, then also delete it here.
23 *
24 * This program is distributed in the hope that it will be useful, but
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 **/
32
33
34 #pragma once
35
36 #include "../../Core/DicomFormat/DicomMap.h"
37 #include "../ServerEnumerations.h"
38
39 #define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 0
40
41 #if ORTHANC_ENABLE_PLUGINS == 1
42 # include <orthanc/OrthancCDatabasePlugin.h>
43 # if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
44 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 2)
45 # undef ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT
46 # define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 1
47 # endif
48 # endif
49 #endif
50
51 namespace Orthanc
52 {
53 namespace Plugins
54 {
55 #if ORTHANC_ENABLE_PLUGINS == 1
56 OrthancPluginResourceType Convert(ResourceType type);
57 #endif
58
59 #if ORTHANC_ENABLE_PLUGINS == 1
60 ResourceType Convert(OrthancPluginResourceType type);
61 #endif
62
63 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
64 OrthancPluginConstraintType Convert(ConstraintType constraint);
65 #endif
66
67 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
68 ConstraintType Convert(OrthancPluginConstraintType constraint);
69 #endif
70 }
71
72
73 // This class is also used by the "orthanc-databases" project
74 class DatabaseConstraint
75 {
76 private:
77 ResourceType level_;
78 DicomTag tag_;
79 bool isIdentifier_;
80 ConstraintType constraintType_;
81 std::vector<std::string> values_;
82 bool caseSensitive_;
83 bool mandatory_;
84
85 public:
86 DatabaseConstraint(ResourceType level,
87 const DicomTag& tag,
88 bool isIdentifier,
89 ConstraintType type,
90 const std::vector<std::string>& values,
91 bool caseSensitive,
92 bool mandatory);
93
94 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
95 DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint);
96 #endif
97
98 ResourceType GetLevel() const
99 {
100 return level_;
101 }
102
103 const DicomTag& GetTag() const
104 {
105 return tag_;
106 }
107
108 bool IsIdentifier() const
109 {
110 return isIdentifier_;
111 }
112
113 ConstraintType GetConstraintType() const
114 {
115 return constraintType_;
116 }
117
118 size_t GetValuesCount() const
119 {
120 return values_.size();
121 }
122
123 const std::string& GetValue(size_t index) const;
124
125 const std::string& GetSingleValue() const;
126
127 bool IsCaseSensitive() const
128 {
129 return caseSensitive_;
130 }
131
132 bool IsMandatory() const
133 {
134 return mandatory_;
135 }
136
137 bool IsMatch(const DicomMap& dicom) const;
138
139 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
140 void EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
141 std::vector<const char*>& tmpValues) const;
142 #endif
143 };
144 }