comparison Framework/Plugins/DatabaseBackendAdapterV3.cpp @ 373:be7de633695c db-protobuf

started DatabaseBackendAdapterV4
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 Mar 2023 12:47:54 +0200
parents 16aac0287485
children 4a3985088723
comparison
equal deleted inserted replaced
372:b5e2c1e48828 373:be7de633695c
1986 1986
1987 void DatabaseBackendAdapterV3::Register(IndexBackend* backend, 1987 void DatabaseBackendAdapterV3::Register(IndexBackend* backend,
1988 size_t countConnections, 1988 size_t countConnections,
1989 unsigned int maxDatabaseRetries) 1989 unsigned int maxDatabaseRetries)
1990 { 1990 {
1991 std::unique_ptr<IndexBackend> protection(backend);
1992
1991 if (isBackendInUse_) 1993 if (isBackendInUse_)
1992 { 1994 {
1993 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 1995 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
1994 } 1996 }
1995 1997
2069 params.setGlobalProperty = SetGlobalProperty; 2071 params.setGlobalProperty = SetGlobalProperty;
2070 params.setMetadata = SetMetadata; 2072 params.setMetadata = SetMetadata;
2071 params.setProtectedPatient = SetProtectedPatient; 2073 params.setProtectedPatient = SetProtectedPatient;
2072 params.setResourcesContent = SetResourcesContent; 2074 params.setResourcesContent = SetResourcesContent;
2073 2075
2074 OrthancPluginContext* context = backend->GetContext(); 2076 OrthancPluginContext* context = protection->GetContext();
2075 2077
2076 if (OrthancPluginRegisterDatabaseBackendV3( 2078 if (OrthancPluginRegisterDatabaseBackendV3(
2077 context, &params, sizeof(params), maxDatabaseRetries, 2079 context, &params, sizeof(params), maxDatabaseRetries,
2078 new Adapter(backend, countConnections)) != OrthancPluginErrorCode_Success) 2080 new Adapter(protection.release(), countConnections)) != OrthancPluginErrorCode_Success)
2079 { 2081 {
2082 delete backend;
2080 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to register the database backend"); 2083 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to register the database backend");
2081 } 2084 }
2082 2085
2083 backend->SetOutputFactory(new Factory); 2086 backend->SetOutputFactory(new Factory);
2084 2087