comparison OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.h @ 5811:a451777236fb attach-custom-data tip

advanced storage: fix + customizable path
author Alain Mazy <am@orthanc.team>
date Tue, 24 Sep 2024 17:52:45 +0200
parents 1f6642c04541
children
comparison
equal deleted inserted replaced
5810:1f6642c04541 5811:a451777236fb
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium 6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium 7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
8 * 8 *
9 * This program is free software: you can redistribute it and/or 9 * This program is free software: you can redistribute it and/or
10 * modify it under the terms of the GNU Affero General Public License 10 * modify it under the terms of the GNU General Public License as
11 * as published by the Free Software Foundation, either version 3 of 11 * published by the Free Software Foundation, either version 3 of the
12 * the License, or (at your option) any later version. 12 * License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, but 14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Affero General Public License for more details. 17 * General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU Affero General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 **/ 21 **/
22 22
23 23
24
25 #pragma once 24 #pragma once
26 25
27 #include "IndexBackend.h" 26 #if ORTHANC_ENABLE_PLUGINS == 1
28 27
28 #include "../../../OrthancFramework/Sources/SharedLibrary.h"
29 #include "../../Sources/Database/IDatabaseWrapper.h"
30 #include "../Include/orthanc/OrthancCPlugin.h"
31 #include "PluginsErrorDictionary.h"
29 32
30 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 33 namespace Orthanc
31 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) 34 {
32 35 class OrthancPluginDatabaseV4 : public IDatabaseWrapper
33 namespace OrthancDatabases
34 {
35 /**
36 * @brief Bridge between C and C++ database engines.
37 *
38 * Class creating the bridge between the C low-level primitives for
39 * custom database engines, and the high-level IDatabaseBackend C++
40 * interface, through ProtocolBuffers for Orthanc >= 1.12.0.
41 **/
42 class DatabaseBackendAdapterV4
43 { 36 {
44 private: 37 private:
45 // This class cannot be instantiated 38 class Transaction;
46 DatabaseBackendAdapterV4() 39
40 SharedLibrary& library_;
41 PluginsErrorDictionary& errorDictionary_;
42 _OrthancPluginRegisterDatabaseBackendV4 definition_;
43 std::string serverIdentifier_;
44 bool open_;
45 unsigned int databaseVersion_;
46 IDatabaseWrapper::Capabilities dbCapabilities_;
47
48 void CheckSuccess(OrthancPluginErrorCode code) const;
49
50 public:
51 OrthancPluginDatabaseV4(SharedLibrary& library,
52 PluginsErrorDictionary& errorDictionary,
53 const _OrthancPluginRegisterDatabaseBackendV4& database,
54 const std::string& serverIdentifier);
55
56 virtual ~OrthancPluginDatabaseV4();
57
58 const _OrthancPluginRegisterDatabaseBackendV4& GetDefinition() const
47 { 59 {
60 return definition_;
48 } 61 }
49 62
50 public: 63 PluginsErrorDictionary& GetErrorDictionary() const
51 static void Register(IndexBackend* backend, 64 {
52 size_t countConnections, 65 return errorDictionary_;
53 unsigned int maxDatabaseRetries); 66 }
54 67
55 static void Finalize(); 68 const std::string& GetServerIdentifier() const
69 {
70 return serverIdentifier_;
71 }
72
73 virtual void Open() ORTHANC_OVERRIDE;
74
75 virtual void Close() ORTHANC_OVERRIDE;
76
77 const SharedLibrary& GetSharedLibrary() const
78 {
79 return library_;
80 }
81
82 virtual void FlushToDisk() ORTHANC_OVERRIDE;
83
84 virtual IDatabaseWrapper::ITransaction* StartTransaction(TransactionType type,
85 IDatabaseListener& listener)
86 ORTHANC_OVERRIDE;
87
88 virtual unsigned int GetDatabaseVersion() ORTHANC_OVERRIDE;
89
90 virtual void Upgrade(unsigned int targetVersion,
91 IStorageArea& storageArea) ORTHANC_OVERRIDE;
92
93 virtual uint64_t MeasureLatency() ORTHANC_OVERRIDE;
94
95 virtual const Capabilities GetDatabaseCapabilities() const ORTHANC_OVERRIDE;
96
97 virtual bool HasIntegratedFind() const ORTHANC_OVERRIDE;
56 }; 98 };
57 } 99 }
58 100
59 # endif
60 #endif 101 #endif