20 #ifndef MPD_DIRECTORY_HXX
21 #define MPD_DIRECTORY_HXX
29 #include <boost/intrusive/list.hpp>
50 static constexpr
auto link_mode = boost::intrusive::normal_link;
51 typedef boost::intrusive::link_mode<link_mode>
LinkMode;
52 typedef boost::intrusive::list_member_hook<LinkMode>
Hook;
67 boost::intrusive::constant_time_size<false>>
List;
100 Directory(std::string &&_path_utf8, Directory *_parent);
108 return new Directory(std::string(),
nullptr);
112 return mounted_database !=
nullptr;
140 const Directory *cthis =
this;
152 if (child ==
nullptr)
183 return children.empty() &&
197 const char *
GetName() const noexcept;
204 return parent ==
nullptr;
209 const auto end = children.end();
210 for (
auto i = children.begin(), next = i; i != end; i = next) {
218 const auto end = songs.end();
219 for (
auto i = songs.begin(), next = i; i != end; i = next) {
231 const Song *
FindSong(
const char *name_utf8)
const noexcept;
235 const Directory *cthis =
this;
262 void Sort() noexcept;
gcc_pure const Directory * FindChild(const char *name) const noexcept
Caller must lock the db_mutex.
gcc_pure Directory * FindChild(const char *name) noexcept
static constexpr unsigned DEVICE_CONTAINER
Virtual directory that is really a song file with one or more "sub" songs as specified by DecoderPlug...
const char * uri
The remaining URI part (without leading slash) or nullptr if the given URI was consumed completely...
SongList songs
A doubly linked list of songs within this directory.
boost::intrusive::list< Song, boost::intrusive::member_hook< Song, Song::Hook,&Song::siblings >, boost::intrusive::constant_time_size< false > > SongList
gcc_pure bool IsEmpty() const noexcept
boost::intrusive::link_mode< link_mode > LinkMode
static constexpr auto link_mode
std::function< void(const LightDirectory &)> VisitDirectory
List children
A doubly linked list of child directories.
std::function< void(const PlaylistInfo &, const LightDirectory &)> VisitPlaylist
Hook siblings
Pointers to the siblings of this directory within the parent directory.
void ForEachChildSafe(T &&t)
Directory * CreateChild(const char *name_utf8)
Create a new Directory object as a child of the given one.
void AddSong(Song *song)
Add a song object to this directory.
A song file inside the configured music directory.
void Sort() noexcept
Sort all directory entries recursively.
void Walk(bool recursive, const SongFilter *match, VisitDirectory visit_directory, VisitSong visit_song, VisitPlaylist visit_playlist) const
Caller must lock db_mutex.
gcc_pure LookupResult LookupDirectory(const char *uri) noexcept
Looks up a directory by its relative URI.
boost::intrusive::list< Directory, SiblingsHook, boost::intrusive::constant_time_size< false > > List
gcc_pure const char * GetName() const noexcept
Returns the base name of the directory.
Directory * directory
The last directory that was found.
gcc_pure bool IsRoot() const noexcept
Is this the root directory of the music database?
void RemoveSong(Song *song) noexcept
Remove a song object from this directory (which effectively invalidates the song object, because the "parent" attribute becomes stale), but does not free it.
gcc_pure const char * GetPath() const noexcept
void PruneEmpty() noexcept
Caller must lock the db_mutex.
void Delete()
Remove this Directory object from its parent and free it.
static gcc_malloc Directory * NewRoot()
Create a new root Directory object.
std::function< void(const LightSong &)> VisitSong
gcc_pure LightDirectory Export() const noexcept
gcc_pure Song * FindSong(const char *name_utf8) noexcept
static constexpr unsigned DEVICE_INARCHIVE
Virtual directory that is really an archive file or a folder inside the archive (special value for Di...
boost::intrusive::list_member_hook< LinkMode > Hook
Directory * MakeChild(const char *name_utf8)
Look up a sub directory, and create the object if it does not exist.
void ForEachSongSafe(T &&t)
Directory(std::string &&_path_utf8, Directory *_parent)
Database * mounted_database
If this is not nullptr, then this directory does not really exist, but is a mount point for another D...
A reference to a directory.
const Storage const char * uri
boost::intrusive::member_hook< Directory, Hook,&Directory::siblings > SiblingsHook
gcc_pure const Song * FindSong(const char *name_utf8) const noexcept
Look up a song in this directory by its name.
const Partition const char * name