MPD  0.20.6
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
Directory Struct Reference

#include <Directory.hxx>

Collaboration diagram for Directory:
[legend]

Data Structures

struct  LookupResult
 

Public Types

typedef boost::intrusive::link_mode< link_modeLinkMode
 
typedef boost::intrusive::list_member_hook< LinkModeHook
 
typedef boost::intrusive::member_hook< Directory, Hook,&Directory::siblingsSiblingsHook
 
typedef boost::intrusive::list< Directory, SiblingsHook, boost::intrusive::constant_time_size< false > > List
 

Public Member Functions

 Directory (std::string &&_path_utf8, Directory *_parent)
 
 ~Directory ()
 
bool IsMount () const
 
void Delete ()
 Remove this Directory object from its parent and free it. More...
 
gcc_malloc DirectoryCreateChild (const char *name_utf8)
 Create a new Directory object as a child of the given one. More...
 
gcc_pure const DirectoryFindChild (const char *name) const
 Caller must lock the db_mutex. More...
 
gcc_pure DirectoryFindChild (const char *name)
 
DirectoryMakeChild (const char *name_utf8)
 Look up a sub directory, and create the object if it does not exist. More...
 
gcc_pure LookupResult LookupDirectory (const char *uri)
 Looks up a directory by its relative URI. More...
 
gcc_pure bool IsEmpty () const
 
gcc_pure const char * GetPath () const
 
gcc_pure const char * GetName () const
 Returns the base name of the directory. More...
 
gcc_pure bool IsRoot () const
 Is this the root directory of the music database? More...
 
template<typename T >
void ForEachChildSafe (T &&t)
 
template<typename T >
void ForEachSongSafe (T &&t)
 
gcc_pure const SongFindSong (const char *name_utf8) const
 Look up a song in this directory by its name. More...
 
gcc_pure SongFindSong (const char *name_utf8)
 
void AddSong (Song *song)
 Add a song object to this directory. More...
 
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. More...
 
void PruneEmpty ()
 Caller must lock the db_mutex. More...
 
void Sort ()
 Sort all directory entries recursively. More...
 
void Walk (bool recursive, const SongFilter *match, VisitDirectory visit_directory, VisitSong visit_song, VisitPlaylist visit_playlist) const
 Caller must lock db_mutex. More...
 
gcc_pure LightDirectory Export () const
 

Static Public Member Functions

static gcc_malloc DirectoryNewRoot ()
 Create a new root Directory object. More...
 

Data Fields

Hook siblings
 Pointers to the siblings of this directory within the parent directory. More...
 
List children
 A doubly linked list of child directories. More...
 
SongList songs
 A doubly linked list of songs within this directory. More...
 
PlaylistVector playlists
 
Directoryparent
 
time_t mtime
 
unsigned inode
 
unsigned device
 
std::string path
 
Databasemounted_database
 If this is not nullptr, then this directory does not really exist, but is a mount point for another Database. More...
 

Static Public Attributes

static constexpr auto link_mode = boost::intrusive::normal_link
 

Detailed Description

Definition at line 49 of file Directory.hxx.

Member Typedef Documentation

typedef boost::intrusive::list_member_hook<LinkMode> Directory::Hook

Definition at line 52 of file Directory.hxx.

typedef boost::intrusive::link_mode<link_mode> Directory::LinkMode

Definition at line 51 of file Directory.hxx.

typedef boost::intrusive::list<Directory, SiblingsHook, boost::intrusive::constant_time_size<false> > Directory::List

Definition at line 67 of file Directory.hxx.

typedef boost::intrusive::member_hook<Directory, Hook, &Directory::siblings> Directory::SiblingsHook

Definition at line 65 of file Directory.hxx.

Constructor & Destructor Documentation

Directory::Directory ( std::string &&  _path_utf8,
Directory _parent 
)
Directory::~Directory ( )

Member Function Documentation

void Directory::AddSong ( Song song)

Add a song object to this directory.

Its "parent" attribute must be set already.

gcc_malloc Directory* Directory::CreateChild ( const char *  name_utf8)

Create a new Directory object as a child of the given one.

Caller must lock the db_mutex.

Parameters
name_utf8the UTF-8 encoded name of the new sub directory
void Directory::Delete ( )

Remove this Directory object from its parent and free it.

This must not be called with the root Directory.

Caller must lock the db_mutex.

gcc_pure LightDirectory Directory::Export ( ) const
gcc_pure const Directory* Directory::FindChild ( const char *  name) const

Caller must lock the db_mutex.

gcc_pure Directory* Directory::FindChild ( const char *  name)
inline

Definition at line 140 of file Directory.hxx.

gcc_pure const Song* Directory::FindSong ( const char *  name_utf8) const

Look up a song in this directory by its name.

Caller must lock the db_mutex.

gcc_pure Song* Directory::FindSong ( const char *  name_utf8)
inline

Definition at line 235 of file Directory.hxx.

template<typename T >
void Directory::ForEachChildSafe ( T &&  t)
inline

Definition at line 209 of file Directory.hxx.

template<typename T >
void Directory::ForEachSongSafe ( T &&  t)
inline

Definition at line 218 of file Directory.hxx.

gcc_pure const char* Directory::GetName ( ) const

Returns the base name of the directory.

gcc_pure const char* Directory::GetPath ( ) const
inline

Definition at line 190 of file Directory.hxx.

gcc_pure bool Directory::IsEmpty ( ) const
inline

Definition at line 183 of file Directory.hxx.

bool Directory::IsMount ( ) const
inline

Definition at line 111 of file Directory.hxx.

gcc_pure bool Directory::IsRoot ( ) const
inline

Is this the root directory of the music database?

Definition at line 204 of file Directory.hxx.

gcc_pure LookupResult Directory::LookupDirectory ( const char *  uri)

Looks up a directory by its relative URI.

Parameters
urithe relative URI
Returns
the Directory, or nullptr if none was found
Directory* Directory::MakeChild ( const char *  name_utf8)
inline

Look up a sub directory, and create the object if it does not exist.

Caller must lock the db_mutex.

Definition at line 151 of file Directory.hxx.

static gcc_malloc Directory* Directory::NewRoot ( )
inlinestatic

Create a new root Directory object.

Definition at line 107 of file Directory.hxx.

void Directory::PruneEmpty ( )

Caller must lock the db_mutex.

void Directory::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 Directory::Sort ( )

Sort all directory entries recursively.

Caller must lock the db_mutex.

void Directory::Walk ( bool  recursive,
const SongFilter match,
VisitDirectory  visit_directory,
VisitSong  visit_song,
VisitPlaylist  visit_playlist 
) const

Caller must lock db_mutex.

Field Documentation

List Directory::children

A doubly linked list of child directories.

This attribute is protected with the global db_mutex. Read access in the update thread does not need protection.

Definition at line 75 of file Directory.hxx.

unsigned Directory::device

Definition at line 89 of file Directory.hxx.

unsigned Directory::inode

Definition at line 89 of file Directory.hxx.

constexpr auto Directory::link_mode = boost::intrusive::normal_link
static

Definition at line 50 of file Directory.hxx.

Database* Directory::mounted_database

If this is not nullptr, then this directory does not really exist, but is a mount point for another Database.

Definition at line 97 of file Directory.hxx.

time_t Directory::mtime

Definition at line 88 of file Directory.hxx.

Directory* Directory::parent

Definition at line 87 of file Directory.hxx.

std::string Directory::path

Definition at line 91 of file Directory.hxx.

PlaylistVector Directory::playlists

Definition at line 85 of file Directory.hxx.

Hook Directory::siblings

Pointers to the siblings of this directory within the parent directory.

It is unused (undefined) in the root directory.

This attribute is protected with the global db_mutex. Read access in the update thread does not need protection.

Definition at line 62 of file Directory.hxx.

SongList Directory::songs

A doubly linked list of songs within this directory.

This attribute is protected with the global db_mutex. Read access in the update thread does not need protection.

Definition at line 83 of file Directory.hxx.


The documentation for this struct was generated from the following file: