comparison Framework/Plugins/StorageBackend.cpp @ 195:53bd9022c58b

Support of "OrthancPluginRegisterStorageArea2()" from Orthanc SDK 1.9.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 08 Jan 2021 18:54:20 +0100
parents a51ce147dbe0
children d9ef3f16e6a2
comparison
equal deleted inserted replaced
194:a51ce147dbe0 195:53bd9022c58b
168 } 168 }
169 ORTHANC_PLUGINS_DATABASE_CATCH; 169 ORTHANC_PLUGINS_DATABASE_CATCH;
170 } 170 }
171 171
172 172
173 static OrthancPluginErrorCode StorageRead(void** content, 173 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 0)
174 int64_t* size, 174 static OrthancPluginErrorCode StorageReadWhole(OrthancPluginMemoryBuffer64 *target,
175 const char* uuid, 175 const char* uuid,
176 OrthancPluginContentType type) 176 OrthancPluginContentType type)
177 { 177 {
178 try 178 try
179 { 179 {
180 StorageAreaBuffer buffer; 180 StorageAreaBuffer buffer(context_);
181 181
182 { 182 {
183 DatabaseManager::Transaction transaction(backend_->GetManager()); 183 DatabaseManager::Transaction transaction(backend_->GetManager());
184 backend_->Read(buffer, transaction, uuid, type); 184 backend_->Read(buffer, transaction, uuid, type);
185 transaction.Commit(); 185 transaction.Commit();
186 } 186 }
187 187
188 buffer.Move(target);
189
190 return OrthancPluginErrorCode_Success;
191 }
192 ORTHANC_PLUGINS_DATABASE_CATCH;
193 }
194 #else
195 static OrthancPluginErrorCode StorageRead(void** content,
196 int64_t* size,
197 const char* uuid,
198 OrthancPluginContentType type)
199 {
200 try
201 {
202 StorageAreaBuffer buffer(context_);
203
204 {
205 DatabaseManager::Transaction transaction(backend_->GetManager());
206 backend_->Read(buffer, transaction, uuid, type);
207 transaction.Commit();
208 }
209
188 *size = buffer.GetSize(); 210 *size = buffer.GetSize();
189 *content = buffer.ReleaseData(); 211 *content = buffer.ReleaseData();
190 212
191 return OrthancPluginErrorCode_Success; 213 return OrthancPluginErrorCode_Success;
192 } 214 }
193 ORTHANC_PLUGINS_DATABASE_CATCH; 215 ORTHANC_PLUGINS_DATABASE_CATCH;
194 } 216 }
217 #endif
195 218
196 219
197 static OrthancPluginErrorCode StorageRemove(const char* uuid, 220 static OrthancPluginErrorCode StorageRemove(const char* uuid,
198 OrthancPluginContentType type) 221 OrthancPluginContentType type)
199 { 222 {
227 { 250 {
228 context_ = context; 251 context_ = context;
229 backend_.reset(backend); 252 backend_.reset(backend);
230 backend_->GetManager().Open(); 253 backend_->GetManager().Open();
231 254
255 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 0)
256 OrthancPluginRegisterStorageArea2(context_, StorageCreate, StorageReadWhole,
257 NULL /* TODO - StorageReadRange */, StorageRemove);
258 #else
232 OrthancPluginRegisterStorageArea(context_, StorageCreate, StorageRead, StorageRemove); 259 OrthancPluginRegisterStorageArea(context_, StorageCreate, StorageRead, StorageRemove);
260 #endif
233 } 261 }
234 } 262 }
235 263
236 264
237 void StorageBackend::Finalize() 265 void StorageBackend::Finalize()