File tree Expand file tree Collapse file tree 4 files changed +14
-15
lines changed Expand file tree Collapse file tree 4 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 7
7
*/
8
8
#pragma once
9
9
10
+ #include < chrono>
10
11
#include < memory>
11
- #include < sysrepo-cpp/Session.hpp>
12
+ #include < string>
13
+ #include < sysrepo-cpp/Enum.hpp>
12
14
13
15
struct sr_conn_ctx_s ;
14
16
@@ -42,7 +44,7 @@ class Connection {
42
44
friend Session;
43
45
44
46
private:
45
- Connection (std::shared_ptr<sr_conn_ctx_s> ctx);
47
+ explicit Connection (std::shared_ptr<sr_conn_ctx_s> ctx);
46
48
std::shared_ptr<sr_conn_ctx_s> ctx;
47
49
};
48
50
}
Original file line number Diff line number Diff line change 7
7
*/
8
8
#pragma once
9
9
10
- #include < chrono>
11
10
#include < iosfwd>
12
- #include < memory>
13
11
#include < optional>
14
12
#include < libyang-cpp/Context.hpp>
15
13
#include < libyang-cpp/DataNode.hpp>
16
- #include < sysrepo-cpp/Enum .hpp>
14
+ #include < sysrepo-cpp/Connection .hpp>
17
15
#include < sysrepo-cpp/Subscription.hpp>
18
16
19
- struct sr_conn_ctx_s ;
20
17
struct sr_session_ctx_s ;
21
18
22
19
namespace sysrepo {
@@ -176,10 +173,10 @@ class Session {
176
173
friend Session wrapUnmanagedSession (sr_session_ctx_s* session);
177
174
friend sr_session_ctx_s* getRawSession (Session sess);
178
175
179
- Session (sr_session_ctx_s* sess, std::shared_ptr<sr_conn_ctx_s> conn);
176
+ Session (sr_session_ctx_s* sess, Connection conn);
180
177
explicit Session (sr_session_ctx_s* unmanagedSession, const unmanaged_tag);
181
178
182
- std::shared_ptr<sr_conn_ctx_s> m_conn;
179
+ Connection m_conn;
183
180
std::shared_ptr<sr_session_ctx_s> m_sess;
184
181
};
185
182
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ Session Connection::sessionStart(sysrepo::Datastore datastore)
54
54
auto res = sr_session_start (ctx.get (), toDatastore (datastore), &sess);
55
55
56
56
throwIfError (res, " Couldn't start sysrepo session" );
57
- return Session{sess, ctx };
57
+ return Session{sess, * this };
58
58
}
59
59
60
60
/* *
Original file line number Diff line number Diff line change @@ -81,11 +81,11 @@ std::optional<std::string> constructXPathFilter(const std::optional<std::variant
81
81
*
82
82
* Internal use only.
83
83
*/
84
- Session::Session (sr_session_ctx_s* sess, std::shared_ptr<sr_conn_ctx_s> conn)
85
- : m_conn(conn)
86
- // The connection `conn` is saved here in the deleter (as a capture). This means that copies of this shared_ptr will
87
- // automatically hold a reference to `conn `.
88
- , m_sess(sess, [extend_connection_lifetime = conn ] (auto * sess) {
84
+ Session::Session (sr_session_ctx_s* sess, Connection conn)
85
+ : m_conn(std::move( conn) )
86
+ // The connection is saved here in the deleter (as a capture). This means that copies of this shared_ptr will
87
+ // automatically hold a reference to `m_conn `.
88
+ , m_sess(sess, [extend_connection_lifetime = m_conn ] (auto * sess) {
89
89
sr_session_stop (sess);
90
90
})
91
91
{
@@ -944,7 +944,7 @@ void Session::setOriginatorName(const std::string& originatorName)
944
944
*/
945
945
Connection Session::getConnection ()
946
946
{
947
- return Connection{ m_conn} ;
947
+ return m_conn;
948
948
}
949
949
950
950
/* *
You can’t perform that action at this time.
0 commit comments