make settings_pack moveable (#982)
This commit is contained in:
parent
bd4827db35
commit
1bae47479b
|
@ -1752,7 +1752,7 @@ int main(int argc, char* argv[])
|
|||
cache_size = (cache_size == 0) ? -1 : 0;
|
||||
settings_pack p;
|
||||
p.set_int(settings_pack::cache_size, cache_size);
|
||||
ses.apply_settings(p);
|
||||
ses.apply_settings(std::move(p));
|
||||
}
|
||||
if (c == 'h')
|
||||
{
|
||||
|
|
|
@ -158,7 +158,7 @@ namespace libtorrent
|
|||
// nat-pmp) and default plugins (ut_metadata, ut_pex and smart_ban). The
|
||||
// default is to start those features. If you do not want them to start,
|
||||
// pass 0 as the flags parameter.
|
||||
session(settings_pack const& pack = settings_pack()
|
||||
session(settings_pack pack = settings_pack()
|
||||
, int flags = start_default_features | add_default_plugins)
|
||||
: session_handle(nullptr)
|
||||
{
|
||||
|
@ -187,7 +187,7 @@ namespace libtorrent
|
|||
// call session::abort() and save the session_proxy first, then
|
||||
// destruct the session object, then sync with the io_service, then
|
||||
// destruct the session_proxy object.
|
||||
session(settings_pack const& pack
|
||||
session(settings_pack pack
|
||||
, io_service& ios
|
||||
, int flags = start_default_features | add_default_plugins)
|
||||
: session_handle(nullptr)
|
||||
|
@ -215,7 +215,7 @@ namespace libtorrent
|
|||
pack.set_bool(settings_pack::enable_dht, false);
|
||||
}
|
||||
|
||||
start(flags, pack, nullptr);
|
||||
start(flags, std::move(pack), nullptr);
|
||||
}
|
||||
|
||||
TORRENT_DEPRECATED
|
||||
|
@ -247,7 +247,7 @@ namespace libtorrent
|
|||
pack.set_bool(settings_pack::enable_lsd, false);
|
||||
pack.set_bool(settings_pack::enable_dht, false);
|
||||
}
|
||||
start(flags, pack, nullptr);
|
||||
start(flags, std::move(pack), nullptr);
|
||||
}
|
||||
#endif // TORRENT_NO_DEPRECATE
|
||||
|
||||
|
@ -281,7 +281,7 @@ namespace libtorrent
|
|||
|
||||
private:
|
||||
|
||||
void start(int flags, settings_pack const& pack, io_service* ios);
|
||||
void start(int flags, settings_pack pack, io_service* ios);
|
||||
|
||||
// data shared between the main thread
|
||||
// and the working thread
|
||||
|
|
|
@ -791,7 +791,7 @@ namespace libtorrent
|
|||
// Applies the settings specified by the settings_pack ``s``. This is an
|
||||
// asynchronous operation that will return immediately and actually apply
|
||||
// the settings to the main thread of libtorrent some time later.
|
||||
void apply_settings(settings_pack const& s);
|
||||
void apply_settings(settings_pack s);
|
||||
settings_pack get_settings() const;
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
|
|
@ -85,6 +85,12 @@ namespace libtorrent
|
|||
{
|
||||
friend TORRENT_EXTRA_EXPORT void apply_pack(settings_pack const* pack, aux::session_settings& sett, aux::session_impl* ses);
|
||||
|
||||
settings_pack() = default;
|
||||
settings_pack(settings_pack const&) = default;
|
||||
settings_pack(settings_pack&&) = default;
|
||||
settings_pack& operator=(settings_pack const&) = default;
|
||||
settings_pack& operator=(settings_pack&&) = default;
|
||||
|
||||
void set_str(int name, std::string val);
|
||||
void set_int(int name, int val);
|
||||
void set_bool(int name, bool val);
|
||||
|
|
|
@ -322,7 +322,7 @@ namespace libtorrent
|
|||
// configurations this will give a link error
|
||||
void TORRENT_EXPORT TORRENT_CFG() {}
|
||||
|
||||
void session::start(int flags, settings_pack const& pack, io_service* ios)
|
||||
void session::start(int flags, settings_pack pack, io_service* ios)
|
||||
{
|
||||
bool const internal_executor = ios == nullptr;
|
||||
|
||||
|
@ -347,7 +347,7 @@ namespace libtorrent
|
|||
TORRENT_UNUSED(flags);
|
||||
#endif
|
||||
|
||||
m_impl->start_session(pack);
|
||||
m_impl->start_session(std::move(pack));
|
||||
|
||||
if (internal_executor)
|
||||
{
|
||||
|
|
|
@ -436,14 +436,14 @@ namespace libtorrent
|
|||
{
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_dht, true);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
void session_handle::stop_dht()
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_dht, false);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
#endif // TORRENT_NO_DEPRECATE
|
||||
|
||||
|
@ -700,7 +700,7 @@ namespace libtorrent
|
|||
{
|
||||
settings_pack p;
|
||||
p.set_str(settings_pack::peer_fingerprint, id.to_string());
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -762,9 +762,9 @@ namespace libtorrent
|
|||
#ifndef TORRENT_NO_DEPRECATE
|
||||
void session_handle::use_interfaces(char const* interfaces)
|
||||
{
|
||||
settings_pack pack;
|
||||
pack.set_str(settings_pack::outgoing_interfaces, interfaces);
|
||||
apply_settings(pack);
|
||||
settings_pack p;
|
||||
p.set_str(settings_pack::outgoing_interfaces, interfaces);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
void session_handle::listen_on(
|
||||
|
@ -783,7 +783,7 @@ namespace libtorrent
|
|||
p.set_str(settings_pack::listen_interfaces, interfaces_str);
|
||||
p.set_int(settings_pack::max_retry_port_bind, port_range.second - port_range.first);
|
||||
p.set_bool(settings_pack::listen_system_port_fallback, (flags & session::listen_no_system_port) == 0);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -811,13 +811,13 @@ namespace libtorrent
|
|||
|
||||
void session_handle::set_pe_settings(pe_settings const& r)
|
||||
{
|
||||
settings_pack pack;
|
||||
pack.set_bool(settings_pack::prefer_rc4, r.prefer_rc4);
|
||||
pack.set_int(settings_pack::out_enc_policy, r.out_enc_policy);
|
||||
pack.set_int(settings_pack::in_enc_policy, r.in_enc_policy);
|
||||
pack.set_int(settings_pack::allowed_enc_level, r.allowed_enc_level);
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::prefer_rc4, r.prefer_rc4);
|
||||
p.set_int(settings_pack::out_enc_policy, r.out_enc_policy);
|
||||
p.set_int(settings_pack::in_enc_policy, r.in_enc_policy);
|
||||
p.set_int(settings_pack::allowed_enc_level, r.allowed_enc_level);
|
||||
|
||||
apply_settings(pack);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
pe_settings session_handle::get_pe_settings() const
|
||||
|
@ -833,7 +833,7 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
|
||||
void session_handle::apply_settings(settings_pack const& s)
|
||||
void session_handle::apply_settings(settings_pack s)
|
||||
{
|
||||
TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::out_enc_policy)
|
||||
|| s.get_int(settings_pack::out_enc_policy)
|
||||
|
@ -845,7 +845,7 @@ namespace libtorrent
|
|||
|| s.get_int(settings_pack::allowed_enc_level)
|
||||
<= settings_pack::pe_both);
|
||||
|
||||
boost::shared_ptr<settings_pack> copy = boost::make_shared<settings_pack>(s);
|
||||
boost::shared_ptr<settings_pack> copy = boost::make_shared<settings_pack>(std::move(s));
|
||||
async_call(&session_impl::apply_settings_pack, copy);
|
||||
}
|
||||
|
||||
|
@ -875,16 +875,16 @@ namespace libtorrent
|
|||
|
||||
void session_handle::set_proxy(proxy_settings const& s)
|
||||
{
|
||||
settings_pack pack;
|
||||
pack.set_str(settings_pack::proxy_hostname, s.hostname);
|
||||
pack.set_str(settings_pack::proxy_username, s.username);
|
||||
pack.set_str(settings_pack::proxy_password, s.password);
|
||||
pack.set_int(settings_pack::proxy_type, s.type);
|
||||
pack.set_int(settings_pack::proxy_port, s.port);
|
||||
pack.set_bool(settings_pack::proxy_hostnames,s.proxy_hostnames);
|
||||
pack.set_bool(settings_pack::proxy_peer_connections, s.proxy_peer_connections);
|
||||
settings_pack p;
|
||||
p.set_str(settings_pack::proxy_hostname, s.hostname);
|
||||
p.set_str(settings_pack::proxy_username, s.username);
|
||||
p.set_str(settings_pack::proxy_password, s.password);
|
||||
p.set_int(settings_pack::proxy_type, s.type);
|
||||
p.set_int(settings_pack::proxy_port, s.port);
|
||||
p.set_bool(settings_pack::proxy_hostnames,s.proxy_hostnames);
|
||||
p.set_bool(settings_pack::proxy_peer_connections, s.proxy_peer_connections);
|
||||
|
||||
apply_settings(pack);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
proxy_settings session_handle::proxy() const
|
||||
|
@ -1044,7 +1044,7 @@ namespace libtorrent
|
|||
|
||||
settings_pack p;
|
||||
p.set_int(settings_pack::alert_mask, m);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
size_t session_handle::set_alert_queue_size_limit(size_t queue_size_limit_)
|
||||
|
@ -1056,7 +1056,7 @@ namespace libtorrent
|
|||
{
|
||||
settings_pack p;
|
||||
p.set_int(settings_pack::alert_mask, m);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
std::uint32_t session_handle::get_alert_mask() const
|
||||
|
@ -1068,42 +1068,42 @@ namespace libtorrent
|
|||
{
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_lsd, true);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
void session_handle::stop_lsd()
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_lsd, false);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
void session_handle::start_upnp()
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_upnp, true);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
void session_handle::stop_upnp()
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_upnp, false);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
void session_handle::start_natpmp()
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_natpmp, true);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
|
||||
void session_handle::stop_natpmp()
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_natpmp, false);
|
||||
apply_settings(p);
|
||||
apply_settings(std::move(p));
|
||||
}
|
||||
#endif // TORRENT_NO_DEPRECATE
|
||||
|
||||
|
|
Loading…
Reference in New Issue