1 | // |
2 | // SessionImpl.h |
3 | // |
4 | // Definition of the SessionImpl class. |
5 | // |
6 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
7 | // and Contributors. |
8 | // |
9 | // SPDX-License-Identifier: BSL-1.0 |
10 | // |
11 | |
12 | |
13 | #ifndef SQL_Test_SessionImpl_INCLUDED |
14 | #define SQL_Test_SessionImpl_INCLUDED |
15 | |
16 | |
17 | #include "Poco/SQL/AbstractSessionImpl.h" |
18 | #include "Poco/SQL/StatementImpl.h" |
19 | #include "Poco/SharedPtr.h" |
20 | #include "Binder.h" |
21 | |
22 | |
23 | namespace Poco { |
24 | namespace SQL { |
25 | namespace Test { |
26 | |
27 | |
28 | class SessionImpl: public Poco::SQL::AbstractSessionImpl<SessionImpl> |
29 | /// A no-op implementation of SessionImpl for testing. |
30 | { |
31 | public: |
32 | SessionImpl(const std::string& init, |
33 | std::size_t timeout = LOGIN_TIMEOUT_DEFAULT); |
34 | /// Creates the SessionImpl. Opens a connection to the database. |
35 | |
36 | ~SessionImpl(); |
37 | /// Destroys the SessionImpl. |
38 | |
39 | StatementImpl::Ptr createStatementImpl(); |
40 | /// Returns an test StatementImpl. |
41 | |
42 | void open(const std::string& connectionString = "" ); |
43 | /// Opens the session. |
44 | |
45 | void close(); |
46 | /// Closes the session. |
47 | |
48 | void reset(); |
49 | /// Reset connection with dababase and clears session state, but without disconnecting |
50 | |
51 | bool isConnected() const; |
52 | /// Returns true if session is connected to the database, |
53 | /// false otherwise. |
54 | |
55 | void setConnectionTimeout(std::size_t timeout); |
56 | /// Sets the session connection timeout value. |
57 | |
58 | std::size_t getConnectionTimeout() const; |
59 | /// Returns the session connection timeout value. |
60 | |
61 | void begin(); |
62 | /// Starts a transaction. |
63 | |
64 | void commit(); |
65 | /// Commits and ends a transaction. |
66 | |
67 | void rollback(); |
68 | /// Aborts a transaction. |
69 | |
70 | bool canTransact() const; |
71 | /// Returns true if session has transaction capabilities. |
72 | |
73 | bool isTransaction() const; |
74 | /// Returns true iff a transaction is a transaction is in progress, false otherwise. |
75 | |
76 | void setTransactionIsolation(Poco::UInt32); |
77 | /// Sets the transaction isolation level. |
78 | |
79 | Poco::UInt32 getTransactionIsolation() const; |
80 | /// Returns the transaction isolation level. |
81 | |
82 | bool hasTransactionIsolation(Poco::UInt32) const; |
83 | /// Returns true iff the transaction isolation level corresponding |
84 | /// to the supplied bitmask is supported. |
85 | |
86 | bool isTransactionIsolation(Poco::UInt32) const; |
87 | /// Returns true iff the transaction isolation level corresponds |
88 | /// to the supplied bitmask. |
89 | |
90 | const std::string& connectorName() const; |
91 | /// Returns the name of the connector. |
92 | |
93 | void setConnected(const std::string& name, bool value); |
94 | bool getConnected(const std::string& name) const; |
95 | /// Sets/gets the connected property. |
96 | /// This is normally done by implementation |
97 | /// when a database connection loss is detected. |
98 | |
99 | void setF(const std::string& name, bool value); |
100 | bool getF(const std::string& name) const; |
101 | void setP(const std::string& name, const Poco::Any& value); |
102 | Poco::Any getP(const std::string& name) const; |
103 | |
104 | private: |
105 | bool _f; |
106 | Poco::Any _p; |
107 | bool _connected; |
108 | std::string _connectionString; |
109 | }; |
110 | |
111 | |
112 | } } } // namespace Poco::SQL::Test |
113 | |
114 | |
115 | #endif // Data_Test_SessionImpl_INCLUDED |
116 | |