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
Jan 02, 2018
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 @@
...
@@ -30,14 +30,10 @@
#include <stdexcept>
#include <stdexcept>
NeighborGlue
::
Explorer
::~
Explorer
()
noexcept
NeighborGlue
::
NeighborGlue
()
noexcept
{}
{
delete
explorer
;
}
NeighborGlue
::~
NeighborGlue
()
noexcept
{}
NeighborGlue
::~
NeighborGlue
()
noexcept
{}
static
NeighborExplorer
*
static
std
::
unique_ptr
<
NeighborExplorer
>
CreateNeighborExplorer
(
EventLoop
&
loop
,
NeighborListener
&
listener
,
CreateNeighborExplorer
(
EventLoop
&
loop
,
NeighborListener
&
listener
,
const
ConfigBlock
&
block
)
const
ConfigBlock
&
block
)
{
{
...
@@ -59,9 +55,9 @@ NeighborGlue::Init(EventLoop &loop, NeighborListener &listener)
...
@@ -59,9 +55,9 @@ NeighborGlue::Init(EventLoop &loop, NeighborListener &listener)
for
(
const
auto
*
block
=
config_get_block
(
ConfigBlockOption
::
NEIGHBORS
);
for
(
const
auto
*
block
=
config_get_block
(
ConfigBlockOption
::
NEIGHBORS
);
block
!=
nullptr
;
block
=
block
->
next
)
{
block
!=
nullptr
;
block
=
block
->
next
)
{
try
{
try
{
auto
*
explorer
=
explorers
.
emplace_front
(
CreateNeighborExplorer
(
loop
,
CreateNeighborExplorer
(
loop
,
listener
,
*
block
);
listener
,
explorers
.
emplace_front
(
explorer
);
*
block
)
);
}
catch
(...)
{
}
catch
(...)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Line %i: "
,
std
::
throw_with_nested
(
FormatRuntimeError
(
"Line %i: "
,
block
->
line
));
block
->
line
));
...
...
src/neighbor/Glue.hxx
View file @
201210cf
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "thread/Mutex.hxx"
#include "thread/Mutex.hxx"
#include <forward_list>
#include <forward_list>
#include <memory>
class
EventLoop
;
class
EventLoop
;
class
NeighborExplorer
;
class
NeighborExplorer
;
...
@@ -36,13 +37,13 @@ struct NeighborInfo;
...
@@ -36,13 +37,13 @@ struct NeighborInfo;
*/
*/
class
NeighborGlue
{
class
NeighborGlue
{
struct
Explorer
{
struct
Explorer
{
NeighborExplorer
*
const
explorer
;
std
::
unique_ptr
<
NeighborExplorer
>
explorer
;
Explorer
(
NeighborExplorer
*
_explorer
)
noexcept
template
<
typename
E
>
:
explorer
(
_explorer
)
{}
Explorer
(
E
&&
_explorer
)
noexcept
:
explorer
(
std
::
forward
<
E
>
(
_explorer
))
{}
Explorer
(
const
Explorer
&
)
=
delete
;
Explorer
(
const
Explorer
&
)
=
delete
;
~
Explorer
()
noexcept
;
};
};
Mutex
mutex
;
Mutex
mutex
;
...
@@ -52,7 +53,7 @@ class NeighborGlue {
...
@@ -52,7 +53,7 @@ class NeighborGlue {
public
:
public
:
typedef
std
::
forward_list
<
NeighborInfo
>
List
;
typedef
std
::
forward_list
<
NeighborInfo
>
List
;
NeighborGlue
()
=
defaul
t
;
NeighborGlue
()
noexcep
t
;
NeighborGlue
(
const
NeighborGlue
&
)
=
delete
;
NeighborGlue
(
const
NeighborGlue
&
)
=
delete
;
~
NeighborGlue
()
noexcept
;
~
NeighborGlue
()
noexcept
;
...
...
src/neighbor/NeighborPlugin.hxx
View file @
201210cf
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
#ifndef MPD_NEIGHBOR_PLUGIN_HXX
#ifndef MPD_NEIGHBOR_PLUGIN_HXX
#define MPD_NEIGHBOR_PLUGIN_HXX
#define MPD_NEIGHBOR_PLUGIN_HXX
#include <memory>
struct
ConfigBlock
;
struct
ConfigBlock
;
class
EventLoop
;
class
EventLoop
;
class
NeighborListener
;
class
NeighborListener
;
...
@@ -31,8 +33,9 @@ struct NeighborPlugin {
...
@@ -31,8 +33,9 @@ struct NeighborPlugin {
/**
/**
* Allocates and configures a #NeighborExplorer instance.
* Allocates and configures a #NeighborExplorer instance.
*/
*/
NeighborExplorer
*
(
*
create
)(
EventLoop
&
loop
,
NeighborListener
&
listener
,
std
::
unique_ptr
<
NeighborExplorer
>
(
*
create
)(
EventLoop
&
loop
,
const
ConfigBlock
&
block
);
NeighborListener
&
listener
,
const
ConfigBlock
&
block
);
};
};
#endif
#endif
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
View file @
201210cf
...
@@ -252,14 +252,14 @@ SmbclientNeighborExplorer::ThreadFunc()
...
@@ -252,14 +252,14 @@ SmbclientNeighborExplorer::ThreadFunc()
mutex
.
unlock
();
mutex
.
unlock
();
}
}
static
NeighborExplorer
*
static
std
::
unique_ptr
<
NeighborExplorer
>
smbclient_neighbor_create
(
gcc_unused
EventLoop
&
loop
,
smbclient_neighbor_create
(
gcc_unused
EventLoop
&
loop
,
NeighborListener
&
listener
,
NeighborListener
&
listener
,
gcc_unused
const
ConfigBlock
&
block
)
gcc_unused
const
ConfigBlock
&
block
)
{
{
SmbclientInit
();
SmbclientInit
();
return
new
SmbclientNeighborExplorer
(
listener
);
return
std
::
make_unique
<
SmbclientNeighborExplorer
>
(
listener
);
}
}
const
NeighborPlugin
smbclient_neighbor_plugin
=
{
const
NeighborPlugin
smbclient_neighbor_plugin
=
{
...
...
src/neighbor/plugins/UpnpNeighborPlugin.cxx
View file @
201210cf
...
@@ -127,12 +127,12 @@ UpnpNeighborExplorer::LostUPnP(const ContentDirectoryService &service)
...
@@ -127,12 +127,12 @@ UpnpNeighborExplorer::LostUPnP(const ContentDirectoryService &service)
listener
.
LostNeighbor
(
n
);
listener
.
LostNeighbor
(
n
);
}
}
static
NeighborExplorer
*
static
std
::
unique_ptr
<
NeighborExplorer
>
upnp_neighbor_create
(
EventLoop
&
event_loop
,
upnp_neighbor_create
(
EventLoop
&
event_loop
,
NeighborListener
&
listener
,
NeighborListener
&
listener
,
gcc_unused
const
ConfigBlock
&
block
)
gcc_unused
const
ConfigBlock
&
block
)
{
{
return
new
UpnpNeighborExplorer
(
event_loop
,
listener
);
return
std
::
make_unique
<
UpnpNeighborExplorer
>
(
event_loop
,
listener
);
}
}
const
NeighborPlugin
upnp_neighbor_plugin
=
{
const
NeighborPlugin
upnp_neighbor_plugin
=
{
...
...
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