Mercurial > hg > orthanc-databases
comparison Framework/SQLite/SQLiteDatabase.cpp @ 237:35598014f140
refactoring to remove GlobalProperties.cpp
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 08 Apr 2021 19:09:04 +0200 |
parents | b40b30075c51 |
children | 33fa478c119a |
comparison
equal
deleted
inserted
replaced
236:d1d2edbbe6fb | 237:35598014f140 |
---|---|
46 | 46 |
47 namespace | 47 namespace |
48 { | 48 { |
49 class SQLiteImplicitTransaction : public ImplicitTransaction | 49 class SQLiteImplicitTransaction : public ImplicitTransaction |
50 { | 50 { |
51 private: | |
52 SQLiteDatabase& db_; | |
53 | |
51 protected: | 54 protected: |
52 virtual IResult* ExecuteInternal(IPrecompiledStatement& statement, | 55 virtual IResult* ExecuteInternal(IPrecompiledStatement& statement, |
53 const Dictionary& parameters) ORTHANC_OVERRIDE | 56 const Dictionary& parameters) ORTHANC_OVERRIDE |
54 { | 57 { |
55 return dynamic_cast<SQLiteStatement&>(statement).Execute(*this, parameters); | 58 return dynamic_cast<SQLiteStatement&>(statement).Execute(*this, parameters); |
58 virtual void ExecuteWithoutResultInternal(IPrecompiledStatement& statement, | 61 virtual void ExecuteWithoutResultInternal(IPrecompiledStatement& statement, |
59 const Dictionary& parameters) ORTHANC_OVERRIDE | 62 const Dictionary& parameters) ORTHANC_OVERRIDE |
60 { | 63 { |
61 dynamic_cast<SQLiteStatement&>(statement).ExecuteWithoutResult(*this, parameters); | 64 dynamic_cast<SQLiteStatement&>(statement).ExecuteWithoutResult(*this, parameters); |
62 } | 65 } |
66 | |
67 public: | |
68 SQLiteImplicitTransaction(SQLiteDatabase& db) : | |
69 db_(db) | |
70 { | |
71 } | |
72 | |
73 virtual bool DoesTableExist(const std::string& name) ORTHANC_OVERRIDE | |
74 { | |
75 return db_.GetObject().DoesTableExist(name.c_str()); | |
76 } | |
77 | |
78 virtual bool DoesTriggerExist(const std::string& name) ORTHANC_OVERRIDE | |
79 { | |
80 return false; | |
81 } | |
82 | |
83 virtual void ExecuteMultiLines(const std::string& query) ORTHANC_OVERRIDE | |
84 { | |
85 db_.GetObject().Execute(query); | |
86 } | |
63 }; | 87 }; |
64 } | 88 } |
65 | 89 |
66 ITransaction* SQLiteDatabase::CreateTransaction(TransactionType type) | 90 ITransaction* SQLiteDatabase::CreateTransaction(TransactionType type) |
67 { | 91 { |
68 switch (type) | 92 switch (type) |
69 { | 93 { |
70 case TransactionType_Implicit: | 94 case TransactionType_Implicit: |
71 return new SQLiteImplicitTransaction; | 95 return new SQLiteImplicitTransaction(*this); |
72 | 96 |
73 case TransactionType_ReadOnly: | 97 case TransactionType_ReadOnly: |
74 case TransactionType_ReadWrite: | 98 case TransactionType_ReadWrite: |
75 return new SQLiteTransaction(*this); | 99 return new SQLiteTransaction(*this); |
76 | 100 |