From 02bb47dd0857cdd738c9e0665a1f22c937e6ddf0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 21 May 2019 22:41:16 +0200 Subject: [PATCH] db/simple/Song: move struct Disposer to separate header Allow forward-declaring it. --- src/db/plugins/simple/Directory.cxx | 3 ++- src/db/plugins/simple/Disposer.hxx | 29 +++++++++++++++++++++++++++++ src/db/plugins/simple/Song.cxx | 7 +++++++ src/db/plugins/simple/Song.hxx | 6 ------ 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/db/plugins/simple/Disposer.hxx diff --git a/src/db/plugins/simple/Directory.cxx b/src/db/plugins/simple/Directory.cxx index 27602afc2..62d3a6075 100644 --- a/src/db/plugins/simple/Directory.cxx +++ b/src/db/plugins/simple/Directory.cxx @@ -20,6 +20,7 @@ #include "Directory.hxx" #include "SongSort.hxx" #include "Song.hxx" +#include "Disposer.hxx" #include "Mount.hxx" #include "db/LightDirectory.hxx" #include "song/LightSong.hxx" @@ -50,7 +51,7 @@ Directory::~Directory() noexcept mounted_database.reset(); } - songs.clear_and_dispose(Song::Disposer()); + songs.clear_and_dispose(SongDisposer()); children.clear_and_dispose(DeleteDisposer()); } diff --git a/src/db/plugins/simple/Disposer.hxx b/src/db/plugins/simple/Disposer.hxx new file mode 100644 index 000000000..e72cf9040 --- /dev/null +++ b/src/db/plugins/simple/Disposer.hxx @@ -0,0 +1,29 @@ +/* + * Copyright 2003-2019 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_SONG_DISPOSER_HXX +#define MPD_SONG_DISPOSER_HXX + +struct Song; + +struct SongDisposer { + void operator()(Song *song) const noexcept; +}; + +#endif diff --git a/src/db/plugins/simple/Song.cxx b/src/db/plugins/simple/Song.cxx index a1350a077..409c2c440 100644 --- a/src/db/plugins/simple/Song.cxx +++ b/src/db/plugins/simple/Song.cxx @@ -18,6 +18,7 @@ */ #include "Song.hxx" +#include "Disposer.hxx" #include "Directory.hxx" #include "tag/Tag.hxx" #include "util/VarSize.hxx" @@ -76,6 +77,12 @@ Song::Free() noexcept DeleteVarSize(this); } +void +SongDisposer::operator()(Song *song) const noexcept +{ + song->Free(); +} + std::string Song::GetURI() const noexcept { diff --git a/src/db/plugins/simple/Song.hxx b/src/db/plugins/simple/Song.hxx index e23fabf81..34f5161ea 100644 --- a/src/db/plugins/simple/Song.hxx +++ b/src/db/plugins/simple/Song.hxx @@ -45,12 +45,6 @@ struct Song { typedef boost::intrusive::link_mode LinkMode; typedef boost::intrusive::list_member_hook Hook; - struct Disposer { - void operator()(Song *song) const noexcept { - song->Free(); - } - }; - /** * Pointers to the siblings of this directory within the * parent directory. It is unused (undefined) if this song is