annotate OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.h @ 5493:b3ebe249ed5b pg-transactions

At startup, when using a database plugin, display the latency to access the DB
author Alain Mazy <am@osimis.io>
date Mon, 15 Jan 2024 18:25:08 +0100
parents 176bc05f85f4
children 4dd50c4b985a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #if ORTHANC_ENABLE_PLUGINS == 1
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "../../../OrthancFramework/Sources/SharedLibrary.h"
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include "../../Sources/Database/IDatabaseWrapper.h"
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include "../Include/orthanc/OrthancCPlugin.h"
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include "PluginsErrorDictionary.h"
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace Orthanc
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 class OrthancPluginDatabaseV4 : public IDatabaseWrapper
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 private:
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 class Transaction;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 SharedLibrary& library_;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 PluginsErrorDictionary& errorDictionary_;
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
41 _OrthancPluginRegisterDatabaseBackendV4 definition_;
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 std::string serverIdentifier_;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 bool open_;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 unsigned int databaseVersion_;
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5220
diff changeset
45 IDatabaseWrapper::Capabilities dbCapabilities_;
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 void CheckSuccess(OrthancPluginErrorCode code) const;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 public:
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 OrthancPluginDatabaseV4(SharedLibrary& library,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 PluginsErrorDictionary& errorDictionary,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 const _OrthancPluginRegisterDatabaseBackendV4& database,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 const std::string& serverIdentifier);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 virtual ~OrthancPluginDatabaseV4();
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
57 const _OrthancPluginRegisterDatabaseBackendV4& GetDefinition() const
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
58 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
59 return definition_;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
60 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
61
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
62 PluginsErrorDictionary& GetErrorDictionary() const
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
63 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
64 return errorDictionary_;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
65 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
66
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
67 const std::string& GetServerIdentifier() const
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
68 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
69 return serverIdentifier_;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
70 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
71
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 virtual void Open() ORTHANC_OVERRIDE;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 virtual void Close() ORTHANC_OVERRIDE;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 const SharedLibrary& GetSharedLibrary() const
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 return library_;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 virtual void FlushToDisk() ORTHANC_OVERRIDE;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 virtual IDatabaseWrapper::ITransaction* StartTransaction(TransactionType type,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 IDatabaseListener& listener)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 ORTHANC_OVERRIDE;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 virtual unsigned int GetDatabaseVersion() ORTHANC_OVERRIDE;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 virtual void Upgrade(unsigned int targetVersion,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 IStorageArea& storageArea) ORTHANC_OVERRIDE;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
5493
b3ebe249ed5b At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
92 virtual uint64_t MeasureLatency() ORTHANC_OVERRIDE;
b3ebe249ed5b At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
93
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5220
diff changeset
94 virtual const IDatabaseWrapper::Capabilities& GetDatabaseCapabilities() const ORTHANC_OVERRIDE;
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 };
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 #endif