comparison Framework/Plugins/DatabaseBackendAdapterV4.cpp @ 565:373cf7d747cc find-refactoring

fix build against orthanc mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 22 Sep 2024 10:03:36 +0200
parents 7f45f23b10d0
children 77c8544bbd7d
comparison
equal deleted inserted replaced
564:3a83c434b284 565:373cf7d747cc
25 25
26 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 26 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1
27 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) 27 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0)
28 28
29 #include "IndexConnectionsPool.h" 29 #include "IndexConnectionsPool.h"
30 #include "MessagesToolbox.h"
30 31
31 #include <OrthancDatabasePlugin.pb.h> // Include protobuf messages 32 #include <OrthancDatabasePlugin.pb.h> // Include protobuf messages
32 33
33 #include <Logging.h> 34 #include <Logging.h>
34 #include <OrthancException.h> 35 #include <OrthancException.h>
95 { 96 {
96 private: 97 private:
97 Orthanc::DatabasePluginMessages::DeleteAttachment::Response* deleteAttachment_; 98 Orthanc::DatabasePluginMessages::DeleteAttachment::Response* deleteAttachment_;
98 Orthanc::DatabasePluginMessages::DeleteResource::Response* deleteResource_; 99 Orthanc::DatabasePluginMessages::DeleteResource::Response* deleteResource_;
99 Orthanc::DatabasePluginMessages::GetChanges::Response* getChanges_; 100 Orthanc::DatabasePluginMessages::GetChanges::Response* getChanges_;
100 Orthanc::DatabasePluginMessages::GetChangesExtended::Response* getChangesExtended_;
101 Orthanc::DatabasePluginMessages::GetExportedResources::Response* getExportedResources_; 101 Orthanc::DatabasePluginMessages::GetExportedResources::Response* getExportedResources_;
102 Orthanc::DatabasePluginMessages::GetLastChange::Response* getLastChange_; 102 Orthanc::DatabasePluginMessages::GetLastChange::Response* getLastChange_;
103 Orthanc::DatabasePluginMessages::GetLastExportedResource::Response* getLastExportedResource_; 103 Orthanc::DatabasePluginMessages::GetLastExportedResource::Response* getLastExportedResource_;
104 Orthanc::DatabasePluginMessages::GetMainDicomTags::Response* getMainDicomTags_; 104 Orthanc::DatabasePluginMessages::GetMainDicomTags::Response* getMainDicomTags_;
105 Orthanc::DatabasePluginMessages::LookupAttachment::Response* lookupAttachment_; 105 Orthanc::DatabasePluginMessages::LookupAttachment::Response* lookupAttachment_;
106 Orthanc::DatabasePluginMessages::LookupResources::Response* lookupResources_; 106 Orthanc::DatabasePluginMessages::LookupResources::Response* lookupResources_;
107 107
108 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
109 Orthanc::DatabasePluginMessages::GetChangesExtended::Response* getChangesExtended_;
110 #endif
111
108 void Clear() 112 void Clear()
109 { 113 {
110 deleteAttachment_ = NULL; 114 deleteAttachment_ = NULL;
111 deleteResource_ = NULL; 115 deleteResource_ = NULL;
112 getChanges_ = NULL; 116 getChanges_ = NULL;
113 getChangesExtended_ = NULL;
114 getExportedResources_ = NULL; 117 getExportedResources_ = NULL;
115 getLastChange_ = NULL; 118 getLastChange_ = NULL;
116 getLastExportedResource_ = NULL; 119 getLastExportedResource_ = NULL;
117 getMainDicomTags_ = NULL; 120 getMainDicomTags_ = NULL;
118 lookupAttachment_ = NULL; 121 lookupAttachment_ = NULL;
119 lookupResources_ = NULL; 122 lookupResources_ = NULL;
123
124 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
125 getChangesExtended_ = NULL;
126 #endif
120 } 127 }
121 128
122 public: 129 public:
123 Output(Orthanc::DatabasePluginMessages::DeleteAttachment::Response& deleteAttachment) 130 Output(Orthanc::DatabasePluginMessages::DeleteAttachment::Response& deleteAttachment)
124 { 131 {
136 { 143 {
137 Clear(); 144 Clear();
138 getChanges_ = &getChanges; 145 getChanges_ = &getChanges;
139 } 146 }
140 147
148 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
141 Output(Orthanc::DatabasePluginMessages::GetChangesExtended::Response& getChangesExtended) 149 Output(Orthanc::DatabasePluginMessages::GetChangesExtended::Response& getChangesExtended)
142 { 150 {
143 Clear(); 151 Clear();
144 getChangesExtended_ = &getChangesExtended; 152 getChangesExtended_ = &getChangesExtended;
145 } 153 }
154 #endif
146 155
147 Output(Orthanc::DatabasePluginMessages::GetExportedResources::Response& getExportedResources) 156 Output(Orthanc::DatabasePluginMessages::GetExportedResources::Response& getExportedResources)
148 { 157 {
149 Clear(); 158 Clear();
150 getExportedResources_ = &getExportedResources; 159 getExportedResources_ = &getExportedResources;
294 303
295 if (getChanges_ != NULL) 304 if (getChanges_ != NULL)
296 { 305 {
297 change = getChanges_->add_changes(); 306 change = getChanges_->add_changes();
298 } 307 }
308 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
299 else if (getChangesExtended_ != NULL) 309 else if (getChangesExtended_ != NULL)
300 { 310 {
301 change = getChangesExtended_->add_changes(); 311 change = getChangesExtended_->add_changes();
302 } 312 }
313 #endif
303 else if (getLastChange_ != NULL) 314 else if (getLastChange_ != NULL)
304 { 315 {
305 if (getLastChange_->found()) 316 if (getLastChange_->found())
306 { 317 {
307 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 318 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
427 response.mutable_get_system_information()->set_supports_increment_global_property(accessor.GetBackend().HasAtomicIncrementGlobalProperty()); 438 response.mutable_get_system_information()->set_supports_increment_global_property(accessor.GetBackend().HasAtomicIncrementGlobalProperty());
428 response.mutable_get_system_information()->set_has_update_and_get_statistics(accessor.GetBackend().HasUpdateAndGetStatistics()); 439 response.mutable_get_system_information()->set_has_update_and_get_statistics(accessor.GetBackend().HasUpdateAndGetStatistics());
429 response.mutable_get_system_information()->set_has_measure_latency(accessor.GetBackend().HasMeasureLatency()); 440 response.mutable_get_system_information()->set_has_measure_latency(accessor.GetBackend().HasMeasureLatency());
430 #endif 441 #endif
431 442
432 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5) 443 #if ORTHANC_PLUGINS_HAS_INTEGRATED_FIND == 1
433 response.mutable_get_system_information()->set_supports_find(accessor.GetBackend().HasFindSupport()); 444 response.mutable_get_system_information()->set_supports_find(accessor.GetBackend().HasFindSupport());
434 response.mutable_get_system_information()->set_has_extended_changes(accessor.GetBackend().HasExtendedChanges()); 445 response.mutable_get_system_information()->set_has_extended_changes(accessor.GetBackend().HasExtendedChanges());
435 #endif 446 #endif
436 447
437 break; 448 break;
775 backend.GetChanges(output, done, manager, request.get_changes().since(), request.get_changes().limit()); 786 backend.GetChanges(output, done, manager, request.get_changes().since(), request.get_changes().limit());
776 787
777 response.mutable_get_changes()->set_done(done); 788 response.mutable_get_changes()->set_done(done);
778 break; 789 break;
779 } 790 }
780 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5) 791 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
781 case Orthanc::DatabasePluginMessages::OPERATION_GET_CHANGES_EXTENDED: 792 case Orthanc::DatabasePluginMessages::OPERATION_GET_CHANGES_EXTENDED:
782 { 793 {
783 Output output(*response.mutable_get_changes_extended()); 794 Output output(*response.mutable_get_changes_extended());
784 795
785 bool done; 796 bool done;
1302 } 1313 }
1303 1314
1304 break; 1315 break;
1305 } 1316 }
1306 1317
1318 #if ORTHANC_PLUGINS_HAS_INTEGRATED_FIND == 1
1307 case Orthanc::DatabasePluginMessages::OPERATION_FIND: 1319 case Orthanc::DatabasePluginMessages::OPERATION_FIND:
1308 { 1320 {
1309 backend.ExecuteFind(response, manager, request.find()); 1321 backend.ExecuteFind(response, manager, request.find());
1310 break; 1322 break;
1311 } 1323 }
1324 #endif
1312 1325
1313 default: 1326 default:
1314 LOG(ERROR) << "Not implemented transaction operation from protobuf: " << request.operation(); 1327 LOG(ERROR) << "Not implemented transaction operation from protobuf: " << request.operation();
1315 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 1328 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
1316 } 1329 }