Mercurial > hg > orthanc-databases
annotate Framework/MySQL/MySQLParameters.h @ 283:e7678a7b10bb
back to mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 23 Apr 2021 10:02:00 +0200 |
parents | 3236894320d6 |
children | 16aac0287485 |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
193
3236894320d6
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
186
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #if ORTHANC_ENABLE_MYSQL != 1 | |
25 # error MySQL support must be enabled to use this file | |
26 #endif | |
27 | |
152 | 28 #include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" |
0 | 29 |
30 namespace OrthancDatabases | |
31 { | |
32 class MySQLParameters | |
33 { | |
34 private: | |
35 std::string host_; | |
36 std::string username_; | |
37 std::string password_; | |
38 std::string database_; | |
39 uint16_t port_; | |
40 std::string unixSocket_; | |
163
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
41 bool ssl_; |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
42 bool verifySslServerCertificates_; |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
43 std::string sslCaCertificates_; |
0 | 44 bool lock_; |
141
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
45 unsigned int maxConnectionRetries_; |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
46 unsigned int connectionRetryInterval_; |
0 | 47 |
48 void Reset(); | |
186 | 49 |
0 | 50 public: |
51 MySQLParameters(); | |
52 | |
186 | 53 MySQLParameters(const OrthancPlugins::OrthancConfiguration& pluginConfiguration, |
54 const OrthancPlugins::OrthancConfiguration& orthancConfiguration); | |
0 | 55 |
56 const std::string& GetHost() const | |
57 { | |
58 return host_; | |
59 } | |
60 | |
61 const std::string& GetUsername() const | |
62 { | |
63 return username_; | |
64 } | |
65 | |
66 const std::string& GetPassword() const | |
67 { | |
68 return password_; | |
69 } | |
70 | |
71 const std::string& GetDatabase() const | |
72 { | |
73 return database_; | |
74 } | |
75 | |
76 const std::string& GetUnixSocket() const | |
77 { | |
78 return unixSocket_; | |
79 } | |
80 | |
81 uint16_t GetPort() const | |
82 { | |
83 return port_; | |
84 } | |
85 | |
163
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
86 bool IsSsl() const |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
87 { |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
88 return ssl_; |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
89 } |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
90 |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
91 bool IsVerifyServerCertificates() const |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
92 { |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
93 return verifySslServerCertificates_; |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
94 } |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
95 |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
96 const char* GetSslCaCertificates() const |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
97 { |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
98 return sslCaCertificates_.c_str(); |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
99 } |
4d32c9c8d6c0
Added support for TLS connections
Alain Mazy <alain@mazy.be>
parents:
152
diff
changeset
|
100 |
0 | 101 void SetHost(const std::string& host); |
102 | |
103 void SetUsername(const std::string& username); | |
104 | |
105 void SetPassword(const std::string& password); | |
106 | |
107 void SetDatabase(const std::string& database); | |
108 | |
109 void SetPort(unsigned int port); | |
110 | |
111 void SetUnixSocket(const std::string& socket); | |
112 | |
113 void SetLock(bool lock) | |
114 { | |
115 lock_ = lock; | |
116 } | |
117 | |
118 bool HasLock() const | |
119 { | |
120 return lock_; | |
121 } | |
22
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
122 |
141
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
123 unsigned int GetMaxConnectionRetries() const |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
124 { |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
125 return maxConnectionRetries_; |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
126 } |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
127 |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
128 unsigned int GetConnectionRetryInterval() const |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
129 { |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
130 return connectionRetryInterval_; |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
131 } |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
132 |
22
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
133 void Format(Json::Value& target) const; |
0 | 134 }; |
135 } |