Mercurial > hg > orthanc-databases
comparison Framework/Common/DatabaseManager.h @ 501:594859656a06 large-queries
Added support for ExtendedApiV1: /changes
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 11 Apr 2024 18:52:42 +0200 |
parents | f0976163dbe1 |
children | 2ab3d45c0b3c |
comparison
equal
deleted
inserted
replaced
500:c27071770c04 | 501:594859656a06 |
---|---|
21 | 21 |
22 | 22 |
23 #pragma once | 23 #pragma once |
24 | 24 |
25 #include "IDatabaseFactory.h" | 25 #include "IDatabaseFactory.h" |
26 #include "StatementLocation.h" | 26 #include "StatementId.h" |
27 | 27 |
28 #include <Compatibility.h> // For std::unique_ptr<> | 28 #include <Compatibility.h> // For std::unique_ptr<> |
29 #include <Enumerations.h> | 29 #include <Enumerations.h> |
30 | 30 |
31 #include <memory> | 31 #include <memory> |
46 * the latter gets lost. | 46 * the latter gets lost. |
47 **/ | 47 **/ |
48 class DatabaseManager : public boost::noncopyable | 48 class DatabaseManager : public boost::noncopyable |
49 { | 49 { |
50 private: | 50 private: |
51 typedef std::map<StatementLocation, IPrecompiledStatement*> CachedStatements; | 51 typedef std::map<StatementId, IPrecompiledStatement*> CachedStatements; |
52 | 52 |
53 std::unique_ptr<IDatabaseFactory> factory_; | 53 std::unique_ptr<IDatabaseFactory> factory_; |
54 std::unique_ptr<IDatabase> database_; | 54 std::unique_ptr<IDatabase> database_; |
55 std::unique_ptr<ITransaction> transaction_; | 55 std::unique_ptr<ITransaction> transaction_; |
56 CachedStatements cachedStatements_; | 56 CachedStatements cachedStatements_; |
57 Dialect dialect_; | 57 Dialect dialect_; |
58 | 58 |
59 void CloseIfUnavailable(Orthanc::ErrorCode e); | 59 void CloseIfUnavailable(Orthanc::ErrorCode e); |
60 | 60 |
61 IPrecompiledStatement* LookupCachedStatement(const StatementLocation& location) const; | 61 IPrecompiledStatement* LookupCachedStatement(const StatementId& statementId) const; |
62 | 62 |
63 IPrecompiledStatement& CacheStatement(const StatementLocation& location, | 63 IPrecompiledStatement& CacheStatement(const StatementId& statementId, |
64 const Query& query); | 64 const Query& query); |
65 | 65 |
66 ITransaction& GetTransaction(); | 66 ITransaction& GetTransaction(); |
67 | 67 |
68 void ReleaseImplicitTransaction(); | 68 void ReleaseImplicitTransaction(); |
204 * present. | 204 * present. |
205 **/ | 205 **/ |
206 class CachedStatement : public StatementBase | 206 class CachedStatement : public StatementBase |
207 { | 207 { |
208 private: | 208 private: |
209 StatementLocation location_; | 209 StatementId statementId_; |
210 IPrecompiledStatement* statement_; | 210 IPrecompiledStatement* statement_; |
211 | 211 |
212 public: | 212 public: |
213 CachedStatement(const StatementLocation& location, | 213 CachedStatement(const StatementId& statementId, |
214 DatabaseManager& manager, | 214 DatabaseManager& manager, |
215 const std::string& sql); | 215 const std::string& sql); |
216 | 216 |
217 void Execute() | 217 void Execute() |
218 { | 218 { |