1 | // |
2 | // Session.cpp |
3 | // |
4 | // Library: Data |
5 | // Package: DataCore |
6 | // Module: Session |
7 | // |
8 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | |
15 | #include "Poco/Data/Session.h" |
16 | #include "Poco/Data/SessionFactory.h" |
17 | #include "Poco/String.h" |
18 | #include "Poco/URI.h" |
19 | #include <algorithm> |
20 | |
21 | |
22 | namespace Poco { |
23 | namespace Data { |
24 | |
25 | |
26 | Session::Session(Poco::AutoPtr<SessionImpl> pImpl): |
27 | _pImpl(pImpl), |
28 | _statementCreator(pImpl) |
29 | { |
30 | poco_check_ptr (pImpl.get()); |
31 | } |
32 | |
33 | |
34 | Session::Session(const std::string& rConnector, |
35 | const std::string& connectionString, |
36 | std::size_t timeout) |
37 | { |
38 | Session newSession(SessionFactory::instance().create(rConnector, connectionString, timeout)); |
39 | swap(newSession); |
40 | } |
41 | |
42 | |
43 | Session::Session(const std::string& connection, |
44 | std::size_t timeout) |
45 | { |
46 | Session newSession(SessionFactory::instance().create(connection, timeout)); |
47 | swap(newSession); |
48 | } |
49 | |
50 | |
51 | Session::Session(const Session& other): _pImpl(other._pImpl), |
52 | _statementCreator(other._pImpl) |
53 | { |
54 | } |
55 | |
56 | |
57 | Session::~Session() |
58 | { |
59 | } |
60 | |
61 | |
62 | Session& Session::operator = (const Session& other) |
63 | { |
64 | Session tmp(other); |
65 | swap(tmp); |
66 | return *this; |
67 | } |
68 | |
69 | |
70 | void Session::swap(Session& other) |
71 | { |
72 | using std::swap; |
73 | swap(_statementCreator, other._statementCreator); |
74 | swap(_pImpl, other._pImpl); |
75 | } |
76 | |
77 | |
78 | } } // namespace Poco::Data |
79 | |