comparison OrthancServer/Sources/Search/DatabaseConstraint.h @ 5809:023a99146dd0 attach-custom-data

merged find-refactoring -> attach-custom-data
author Alain Mazy <am@orthanc.team>
date Tue, 24 Sep 2024 12:53:43 +0200
parents e2771185dad6
children
comparison
equal deleted inserted replaced
5808:63c025cf6958 5809:023a99146dd0
21 **/ 21 **/
22 22
23 23
24 #pragma once 24 #pragma once
25 25
26 #if !defined(ORTHANC_BUILDING_SERVER_LIBRARY) 26 #include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h"
27 # error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined 27 #include "../ServerEnumerations.h"
28 #endif
29
30 #if ORTHANC_BUILDING_SERVER_LIBRARY == 1
31 # include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h"
32 #else
33 // This is for the "orthanc-databases" project to reuse this file
34 # include <DicomFormat/DicomMap.h>
35 #endif
36
37 #define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 0
38 28
39 #if ORTHANC_ENABLE_PLUGINS == 1 29 #if ORTHANC_ENABLE_PLUGINS == 1
40 # include <orthanc/OrthancCDatabasePlugin.h> 30 # include "../../Plugins/Include/orthanc/OrthancCDatabasePlugin.h"
41 # if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
42 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 2)
43 # undef ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT
44 # define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 1
45 # endif
46 # endif
47 #endif 31 #endif
48
49 #include <deque>
50 32
51 namespace Orthanc 33 namespace Orthanc
52 { 34 {
53 enum ConstraintType
54 {
55 ConstraintType_Equal,
56 ConstraintType_SmallerOrEqual,
57 ConstraintType_GreaterOrEqual,
58 ConstraintType_Wildcard,
59 ConstraintType_List
60 };
61
62 namespace Plugins
63 {
64 #if ORTHANC_ENABLE_PLUGINS == 1
65 OrthancPluginResourceType Convert(ResourceType type);
66 #endif
67
68 #if ORTHANC_ENABLE_PLUGINS == 1
69 ResourceType Convert(OrthancPluginResourceType type);
70 #endif
71
72 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
73 OrthancPluginConstraintType Convert(ConstraintType constraint);
74 #endif
75
76 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
77 ConstraintType Convert(OrthancPluginConstraintType constraint);
78 #endif
79 }
80
81
82 // This class is also used by the "orthanc-databases" project
83 class DatabaseConstraint : public boost::noncopyable 35 class DatabaseConstraint : public boost::noncopyable
84 { 36 {
85 private: 37 private:
86 ResourceType level_; 38 ResourceType level_;
87 DicomTag tag_; 39 DicomTag tag_;
97 bool isIdentifier, 49 bool isIdentifier,
98 ConstraintType type, 50 ConstraintType type,
99 const std::vector<std::string>& values, 51 const std::vector<std::string>& values,
100 bool caseSensitive, 52 bool caseSensitive,
101 bool mandatory); 53 bool mandatory);
102
103 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
104 explicit DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint);
105 #endif
106 54
107 ResourceType GetLevel() const 55 ResourceType GetLevel() const
108 { 56 {
109 return level_; 57 return level_;
110 } 58 }
143 return mandatory_; 91 return mandatory_;
144 } 92 }
145 93
146 bool IsMatch(const DicomMap& dicom) const; 94 bool IsMatch(const DicomMap& dicom) const;
147 95
148 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 96 #if ORTHANC_ENABLE_PLUGINS == 1
149 void EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint, 97 void EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
150 std::vector<const char*>& tmpValues) const; 98 std::vector<const char*>& tmpValues) const;
151 #endif 99 #endif
152 }; 100 };
153
154
155 class DatabaseConstraints : public boost::noncopyable
156 {
157 private:
158 std::deque<DatabaseConstraint*> constraints_;
159
160 public:
161 ~DatabaseConstraints()
162 {
163 Clear();
164 }
165
166 void Clear();
167
168 void AddConstraint(DatabaseConstraint* constraint); // Takes ownership
169
170 bool IsEmpty() const
171 {
172 return constraints_.empty();
173 }
174
175 size_t GetSize() const
176 {
177 return constraints_.size();
178 }
179
180 const DatabaseConstraint& GetConstraint(size_t index) const;
181 };
182 } 101 }