| 1 | // |
|---|---|
| 2 | // PooledSessionImpl.h |
| 3 | // |
| 4 | // Library: SQL |
| 5 | // Package: SessionPooling |
| 6 | // Module: PooledSessionImpl |
| 7 | // |
| 8 | // Definition of the PooledSessionImpl class. |
| 9 | // |
| 10 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
| 11 | // and Contributors. |
| 12 | // |
| 13 | // SPDX-License-Identifier: BSL-1.0 |
| 14 | // |
| 15 | |
| 16 | |
| 17 | #ifndef SQL_PooledSessionImpl_INCLUDED |
| 18 | #define SQL_PooledSessionImpl_INCLUDED |
| 19 | |
| 20 | |
| 21 | #include "Poco/SQL/SQL.h" |
| 22 | #include "Poco/SQL/SessionImpl.h" |
| 23 | #include "Poco/SQL/StatementImpl.h" |
| 24 | #include "Poco/SQL/PooledSessionHolder.h" |
| 25 | #include "Poco/AutoPtr.h" |
| 26 | |
| 27 | |
| 28 | namespace Poco { |
| 29 | namespace SQL { |
| 30 | |
| 31 | |
| 32 | class SessionPool; |
| 33 | |
| 34 | |
| 35 | class Poco_SQL_API PooledSessionImpl: public SessionImpl |
| 36 | /// PooledSessionImpl is a decorator created by |
| 37 | /// SessionPool that adds session pool |
| 38 | /// management to SessionImpl objects. |
| 39 | { |
| 40 | public: |
| 41 | PooledSessionImpl(PooledSessionHolder::Ptr pHolder); |
| 42 | /// Creates the PooledSessionImpl. |
| 43 | |
| 44 | ~PooledSessionImpl(); |
| 45 | /// Destroys the PooledSessionImpl. |
| 46 | |
| 47 | // SessionImpl |
| 48 | StatementImpl::Ptr createStatementImpl(); |
| 49 | void begin(); |
| 50 | void commit(); |
| 51 | void rollback(); |
| 52 | void open(const std::string& connect = ""); |
| 53 | void close(); |
| 54 | void reset(); |
| 55 | bool isConnected() const; |
| 56 | void setConnectionTimeout(std::size_t timeout); |
| 57 | std::size_t getConnectionTimeout() const; |
| 58 | bool canTransact() const; |
| 59 | bool isTransaction() const; |
| 60 | void setTransactionIsolation(Poco::UInt32); |
| 61 | Poco::UInt32 getTransactionIsolation() const; |
| 62 | bool hasTransactionIsolation(Poco::UInt32) const; |
| 63 | bool isTransactionIsolation(Poco::UInt32) const; |
| 64 | const std::string& connectorName() const; |
| 65 | void setFeature(const std::string& name, bool state); |
| 66 | bool getFeature(const std::string& name) const; |
| 67 | void setProperty(const std::string& name, const Poco::Any& value); |
| 68 | Poco::Any getProperty(const std::string& name) const; |
| 69 | |
| 70 | virtual void putBack(); |
| 71 | |
| 72 | protected: |
| 73 | SessionImpl::Ptr access() const; |
| 74 | /// Updates the last access timestamp, |
| 75 | /// verifies validity of the session |
| 76 | /// and returns the session if it is valid. |
| 77 | /// |
| 78 | /// Throws an SessionUnavailableException if the |
| 79 | /// session is no longer valid. |
| 80 | |
| 81 | SessionImpl::Ptr impl() const; |
| 82 | /// Returns a pointer to the SessionImpl. |
| 83 | |
| 84 | private: |
| 85 | mutable PooledSessionHolder::Ptr _pHolder; |
| 86 | }; |
| 87 | |
| 88 | |
| 89 | // |
| 90 | // inlines |
| 91 | // |
| 92 | inline SessionImpl::Ptr PooledSessionImpl::impl() const |
| 93 | { |
| 94 | return _pHolder->session(); |
| 95 | } |
| 96 | |
| 97 | |
| 98 | } } // namespace Poco::SQL |
| 99 | |
| 100 | |
| 101 | #endif // Data_PooledSessionImpl_INCLUDED |
| 102 |