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;
141 const Directory *cthis =
this;
142 return const_cast<Directory *
>(cthis->
FindChild(name));
153 if (child ==
nullptr)
184 return children.empty() &&
205 return parent ==
nullptr;
210 const auto end = children.end();
211 for (
auto i = children.begin(), next = i; i != end; i = next) {
219 const auto end = songs.end();
220 for (
auto i = songs.begin(), next = i; i != end; i = next) {
236 const Directory *cthis =
this;
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...
gcc_pure LookupResult LookupDirectory(const char *uri)
Looks up a directory by its relative URI.
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
boost::intrusive::link_mode< link_mode > LinkMode
gcc_pure bool IsEmpty() const
static constexpr auto link_mode
std::function< void(const LightDirectory &)> VisitDirectory
void RemoveSong(Song *song)
Remove a song object from this directory (which effectively invalidates the song object, because the "parent" attribute becomes stale), but does not free it.
void PruneEmpty()
Caller must lock the db_mutex.
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)
void AddSong(Song *song)
Add a song object to this directory.
A song file inside the configured music directory.
void Walk(bool recursive, const SongFilter *match, VisitDirectory visit_directory, VisitSong visit_song, VisitPlaylist visit_playlist) const
Caller must lock db_mutex.
gcc_pure const char * GetPath() const
boost::intrusive::list< Directory, SiblingsHook, boost::intrusive::constant_time_size< false > > List
gcc_pure const char * GetName() const
Returns the base name of the directory.
Directory * directory
The last directory that was found.
gcc_pure const Song * FindSong(const char *name_utf8) const
Look up a song in this directory by its name.
gcc_pure Song * FindSong(const char *name_utf8)
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
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)
void Sort()
Sort all directory entries recursively.
Database * mounted_database
If this is not nullptr, then this directory does not really exist, but is a mount point for another D...
gcc_pure const Directory * FindChild(const char *name) const
Caller must lock the db_mutex.
gcc_pure bool IsRoot() const
Is this the root directory of the music database?
gcc_malloc Directory * CreateChild(const char *name_utf8)
Create a new Directory object as a child of the given one.
gcc_pure LightDirectory Export() const
A reference to a directory.
gcc_pure Directory * FindChild(const char *name)
const Storage const char * uri
boost::intrusive::member_hook< Directory, Hook,&Directory::siblings > SiblingsHook
const Partition const char * name