152
|
1 /**
|
|
2 * Orthanc - A Lightweight, RESTful DICOM Store
|
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
|
|
4 * Department, University Hospital of Liege, Belgium
|
397
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
|
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
|
152
|
7 *
|
|
8 * This program is free software: you can redistribute it and/or
|
|
9 * modify it under the terms of the GNU General Public License as
|
|
10 * published by the Free Software Foundation, either version 3 of the
|
|
11 * License, or (at your option) any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful, but
|
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
16 * General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20 **/
|
|
21
|
|
22
|
|
23 #pragma once
|
|
24
|
|
25 #if !defined(ORTHANC_BUILDING_SERVER_LIBRARY)
|
|
26 # error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined
|
|
27 #endif
|
|
28
|
|
29 #if ORTHANC_BUILDING_SERVER_LIBRARY == 1
|
|
30 # include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h"
|
|
31 #else
|
|
32 // This is for the "orthanc-databases" project to reuse this file
|
|
33 # include <DicomFormat/DicomMap.h>
|
|
34 #endif
|
|
35
|
|
36 #define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 0
|
|
37
|
|
38 #if ORTHANC_ENABLE_PLUGINS == 1
|
|
39 # include <orthanc/OrthancCDatabasePlugin.h>
|
|
40 # if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
|
|
41 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 2)
|
|
42 # undef ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT
|
|
43 # define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 1
|
|
44 # endif
|
|
45 # endif
|
|
46 #endif
|
|
47
|
|
48 namespace Orthanc
|
|
49 {
|
|
50 enum ConstraintType
|
|
51 {
|
|
52 ConstraintType_Equal,
|
|
53 ConstraintType_SmallerOrEqual,
|
|
54 ConstraintType_GreaterOrEqual,
|
|
55 ConstraintType_Wildcard,
|
|
56 ConstraintType_List
|
|
57 };
|
|
58
|
|
59 namespace Plugins
|
|
60 {
|
|
61 #if ORTHANC_ENABLE_PLUGINS == 1
|
|
62 OrthancPluginResourceType Convert(ResourceType type);
|
|
63 #endif
|
|
64
|
|
65 #if ORTHANC_ENABLE_PLUGINS == 1
|
|
66 ResourceType Convert(OrthancPluginResourceType type);
|
|
67 #endif
|
|
68
|
|
69 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
|
|
70 OrthancPluginConstraintType Convert(ConstraintType constraint);
|
|
71 #endif
|
|
72
|
|
73 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
|
|
74 ConstraintType Convert(OrthancPluginConstraintType constraint);
|
|
75 #endif
|
|
76 }
|
|
77
|
|
78
|
|
79 // This class is also used by the "orthanc-databases" project
|
|
80 class DatabaseConstraint
|
|
81 {
|
|
82 private:
|
|
83 ResourceType level_;
|
|
84 DicomTag tag_;
|
|
85 bool isIdentifier_;
|
|
86 ConstraintType constraintType_;
|
|
87 std::vector<std::string> values_;
|
|
88 bool caseSensitive_;
|
|
89 bool mandatory_;
|
|
90
|
|
91 public:
|
|
92 DatabaseConstraint(ResourceType level,
|
|
93 const DicomTag& tag,
|
|
94 bool isIdentifier,
|
|
95 ConstraintType type,
|
|
96 const std::vector<std::string>& values,
|
|
97 bool caseSensitive,
|
|
98 bool mandatory);
|
|
99
|
|
100 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
|
170
|
101 explicit DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint);
|
152
|
102 #endif
|
|
103
|
|
104 ResourceType GetLevel() const
|
|
105 {
|
|
106 return level_;
|
|
107 }
|
|
108
|
|
109 const DicomTag& GetTag() const
|
|
110 {
|
|
111 return tag_;
|
|
112 }
|
|
113
|
|
114 bool IsIdentifier() const
|
|
115 {
|
|
116 return isIdentifier_;
|
|
117 }
|
|
118
|
|
119 ConstraintType GetConstraintType() const
|
|
120 {
|
|
121 return constraintType_;
|
|
122 }
|
|
123
|
|
124 size_t GetValuesCount() const
|
|
125 {
|
|
126 return values_.size();
|
|
127 }
|
|
128
|
|
129 const std::string& GetValue(size_t index) const;
|
|
130
|
|
131 const std::string& GetSingleValue() const;
|
|
132
|
|
133 bool IsCaseSensitive() const
|
|
134 {
|
|
135 return caseSensitive_;
|
|
136 }
|
|
137
|
|
138 bool IsMandatory() const
|
|
139 {
|
|
140 return mandatory_;
|
|
141 }
|
|
142
|
|
143 bool IsMatch(const DicomMap& dicom) const;
|
|
144
|
|
145 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
|
|
146 void EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
|
|
147 std::vector<const char*>& tmpValues) const;
|
|
148 #endif
|
|
149 };
|
|
150 }
|