annotate Resources/Orthanc/Databases/DatabaseConstraint.h @ 456:0ac99983abfa pg-transactions

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