MPD: db/plugins/simple/Song.hxx Source File

MPD 0.20.18

Song.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_SONG_HXX
21 #define MPD_SONG_HXX
22
23 #include "check.h"
24 #include "Chrono.hxx"
25 #include "tag/Tag.hxx"
26 #include "Compiler.h"
27
28 #include <boost/intrusive/list.hpp>
29
30 #include <string>
31
32 #include <time.h>
33
34 struct LightSong;
35 struct Directory;
36 class DetachedSong;
37 class Storage;
38 class ArchiveFile;
39
44 struct Song {
45 static constexpr auto link_mode = boost::intrusive::normal_link;
46 typedef boost::intrusive::link_mode<link_mode> LinkMode;
47 typedef boost::intrusive::list_member_hook<LinkMode> Hook;
48
49 struct Disposer {
50 void operator()(Song *song) const {
51 song->Free();
52 }
53 };
54
63 Hook siblings;
64
65 Tag tag;
66
71 Directory *const parent;
72
73 time_t mtime;
74
78 SongTime start_time;
79
84 SongTime end_time;
85
89 char uri[sizeof(int)];
90
91 Song(const char *_uri, size_t uri_length, Directory &parent);
92 ~Song();
93
94 gcc_malloc
95 static Song *NewFrom(DetachedSong &&other, Directory &parent);
96
98 gcc_malloc
99 static Song *NewFile(const char *path_utf8, Directory &parent);
100
106 gcc_malloc
107 static Song *LoadFile(Storage &storage, const char *name_utf8,
108 Directory &parent);
109
110 void Free();
111
112 bool UpdateFile(Storage &storage);
113
114 #ifdef ENABLE_ARCHIVE
115 static Song *LoadFromArchive(ArchiveFile &archive,
116 const char *name_utf8,
117 Directory &parent);
118 bool UpdateFileInArchive(ArchiveFile &archive);
119 #endif
120
125 gcc_pure
126 std::string GetURI() const noexcept;
127
128 gcc_pure
129 LightSong Export() const noexcept;
130 };
131
132 typedef boost::intrusive::list<Song,
133 boost::intrusive::member_hook<Song, Song::Hook,
134 &Song::siblings>,
135 boost::intrusive::constant_time_size<false>> SongList;
136
137 #endif
Song::siblings
Hook siblings
Pointers to the siblings of this directory within the parent directory.
Definition: Song.hxx:63
Song::Export
gcc_pure LightSong Export() const noexcept
check.h
Chrono.hxx
Song::Free
void Free()
Tag
The meta information about a song file.
Definition: Tag.hxx:34
SongList
boost::intrusive::list< Song, boost::intrusive::member_hook< Song, Song::Hook, &Song::siblings >, boost::intrusive::constant_time_size< false > > SongList
Definition: Song.hxx:135
Song::LinkMode
boost::intrusive::link_mode< link_mode > LinkMode
Definition: Song.hxx:46
SongTime
A time stamp within a song.
Definition: Chrono.hxx:31
Song::Disposer::operator()
void operator()(Song *song) const
Definition: Song.hxx:50
Tag.hxx
Storage
Definition: StorageInterface.hxx:45
gcc_malloc
#define gcc_malloc
Definition: Compiler.h:112
Song::start_time
SongTime start_time
Start of this sub-song within the file.
Definition: Song.hxx:78
path_utf8
const Storage const char const char * path_utf8
Definition: DatabasePlaylist.hxx:31
Song::LoadFile
static gcc_malloc Song * LoadFile(Storage &storage, const char *name_utf8, Directory &parent)
allocate a new song structure with a local file name and attempt to load its metadata.
Song::NewFile
static gcc_malloc Song * NewFile(const char *path_utf8, Directory &parent)
allocate a new song with a local file name
Song::UpdateFile
bool UpdateFile(Storage &storage)
Song
A song file inside the configured music directory.
Definition: Song.hxx:44
Song::Disposer
Definition: Song.hxx:49
Compiler.h
Song::tag
Tag tag
Definition: Song.hxx:65
Song::Hook
boost::intrusive::list_member_hook< LinkMode > Hook
Definition: Song.hxx:47
storage
const Storage & storage
Definition: DatabasePlaylist.hxx:31
Song::end_time
SongTime end_time
End of this sub-song within the file.
Definition: Song.hxx:84
ArchiveFile
Definition: ArchiveFile.hxx:29
Song::Song
Song(const char *_uri, size_t uri_length, Directory &parent)
Song::parent
Directory *const parent
The Directory that contains this song.
Definition: Song.hxx:71
Song::mtime
time_t mtime
Definition: Song.hxx:73
Song::link_mode
static constexpr auto link_mode
Definition: Song.hxx:45
Song::NewFrom
static gcc_malloc Song * NewFrom(DetachedSong &&other, Directory &parent)
Song::uri
char uri[sizeof(int)]
The file name.
Definition: Song.hxx:89
Song::GetURI
gcc_pure std::string GetURI() const noexcept
Returns the URI of the song in UTF-8 encoding, including its location within the music directory...
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
Directory
Definition: Directory.hxx:49
DetachedSong
Definition: DetachedSong.hxx:37
Song::~Song
~Song()
LightSong
A reference to a song file.
Definition: LightSong.hxx:40