Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
201210cf
Commit
201210cf
authored
7 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
neighbor/Plugin: std::unique_ptr<NeighborExplorer>
parent
cd6de3b2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
20 deletions
+20
-20
Glue.cxx
src/neighbor/Glue.cxx
+5
-9
Glue.hxx
src/neighbor/Glue.hxx
+6
-5
NeighborPlugin.hxx
src/neighbor/NeighborPlugin.hxx
+5
-2
SmbclientNeighborPlugin.cxx
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
+2
-2
UpnpNeighborPlugin.cxx
src/neighbor/plugins/UpnpNeighborPlugin.cxx
+2
-2
No files found.
src/neighbor/Glue.cxx
View file @
201210cf
...
...
@@ -30,14 +30,10 @@
#include <stdexcept>
NeighborGlue
::
Explorer
::~
Explorer
()
noexcept
{
delete
explorer
;
}
NeighborGlue
::
NeighborGlue
()
noexcept
{}
NeighborGlue
::~
NeighborGlue
()
noexcept
{}
static
NeighborExplorer
*
static
std
::
unique_ptr
<
NeighborExplorer
>
CreateNeighborExplorer
(
EventLoop
&
loop
,
NeighborListener
&
listener
,
const
ConfigBlock
&
block
)
{
...
...
@@ -59,9 +55,9 @@ NeighborGlue::Init(EventLoop &loop, NeighborListener &listener)
for
(
const
auto
*
block
=
config_get_block
(
ConfigBlockOption
::
NEIGHBORS
);
block
!=
nullptr
;
block
=
block
->
next
)
{
try
{
auto
*
explorer
=
CreateNeighborExplorer
(
loop
,
listener
,
*
block
);
explorers
.
emplace_front
(
explorer
);
explorers
.
emplace_front
(
CreateNeighborExplorer
(
loop
,
listener
,
*
block
)
);
}
catch
(...)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Line %i: "
,
block
->
line
));
...
...
This diff is collapsed.
Click to expand it.
src/neighbor/Glue.hxx
View file @
201210cf
...
...
@@ -25,6 +25,7 @@
#include "thread/Mutex.hxx"
#include <forward_list>
#include <memory>
class
EventLoop
;
class
NeighborExplorer
;
...
...
@@ -36,13 +37,13 @@ struct NeighborInfo;
*/
class
NeighborGlue
{
struct
Explorer
{
NeighborExplorer
*
const
explorer
;
std
::
unique_ptr
<
NeighborExplorer
>
explorer
;
Explorer
(
NeighborExplorer
*
_explorer
)
noexcept
:
explorer
(
_explorer
)
{}
template
<
typename
E
>
Explorer
(
E
&&
_explorer
)
noexcept
:
explorer
(
std
::
forward
<
E
>
(
_explorer
))
{}
Explorer
(
const
Explorer
&
)
=
delete
;
~
Explorer
()
noexcept
;
};
Mutex
mutex
;
...
...
@@ -52,7 +53,7 @@ class NeighborGlue {
public
:
typedef
std
::
forward_list
<
NeighborInfo
>
List
;
NeighborGlue
()
=
defaul
t
;
NeighborGlue
()
noexcep
t
;
NeighborGlue
(
const
NeighborGlue
&
)
=
delete
;
~
NeighborGlue
()
noexcept
;
...
...
This diff is collapsed.
Click to expand it.
src/neighbor/NeighborPlugin.hxx
View file @
201210cf
...
...
@@ -20,6 +20,8 @@
#ifndef MPD_NEIGHBOR_PLUGIN_HXX
#define MPD_NEIGHBOR_PLUGIN_HXX
#include <memory>
struct
ConfigBlock
;
class
EventLoop
;
class
NeighborListener
;
...
...
@@ -31,8 +33,9 @@ struct NeighborPlugin {
/**
* Allocates and configures a #NeighborExplorer instance.
*/
NeighborExplorer
*
(
*
create
)(
EventLoop
&
loop
,
NeighborListener
&
listener
,
const
ConfigBlock
&
block
);
std
::
unique_ptr
<
NeighborExplorer
>
(
*
create
)(
EventLoop
&
loop
,
NeighborListener
&
listener
,
const
ConfigBlock
&
block
);
};
#endif
This diff is collapsed.
Click to expand it.
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
View file @
201210cf
...
...
@@ -252,14 +252,14 @@ SmbclientNeighborExplorer::ThreadFunc()
mutex
.
unlock
();
}
static
NeighborExplorer
*
static
std
::
unique_ptr
<
NeighborExplorer
>
smbclient_neighbor_create
(
gcc_unused
EventLoop
&
loop
,
NeighborListener
&
listener
,
gcc_unused
const
ConfigBlock
&
block
)
{
SmbclientInit
();
return
new
SmbclientNeighborExplorer
(
listener
);
return
std
::
make_unique
<
SmbclientNeighborExplorer
>
(
listener
);
}
const
NeighborPlugin
smbclient_neighbor_plugin
=
{
...
...
This diff is collapsed.
Click to expand it.
src/neighbor/plugins/UpnpNeighborPlugin.cxx
View file @
201210cf
...
...
@@ -127,12 +127,12 @@ UpnpNeighborExplorer::LostUPnP(const ContentDirectoryService &service)
listener
.
LostNeighbor
(
n
);
}
static
NeighborExplorer
*
static
std
::
unique_ptr
<
NeighborExplorer
>
upnp_neighbor_create
(
EventLoop
&
event_loop
,
NeighborListener
&
listener
,
gcc_unused
const
ConfigBlock
&
block
)
{
return
new
UpnpNeighborExplorer
(
event_loop
,
listener
);
return
std
::
make_unique
<
UpnpNeighborExplorer
>
(
event_loop
,
listener
);
}
const
NeighborPlugin
upnp_neighbor_plugin
=
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment