MPD: Directory Struct Reference

MPD 0.20.18

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_mode > | LinkMode
typedef boost::intrusive::list_member_hook< LinkMode > | Hook
typedef boost::intrusive::member_hook< Directory, Hook, &Directory::siblings > | SiblingsHook
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...
Directory * | CreateChild (const char *name_utf8)
| Create a new Directory object as a child of the given one. More...
gcc_pure const Directory * | FindChild (const char *name) const noexcept
| Caller must lock the db_mutex. More...
gcc_pure Directory * | FindChild (const char *name) noexcept
Directory * | MakeChild (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) noexcept
| Looks up a directory by its relative URI. More...
gcc_pure bool | IsEmpty () const noexcept
gcc_pure const char * | GetPath () const noexcept
gcc_pure const char * | GetName () const noexcept
| Returns the base name of the directory. More...
gcc_pure bool | IsRoot () const noexcept
| 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 Song * | FindSong (const char *name_utf8) const noexcept
| Look up a song in this directory by its name. More...
gcc_pure Song * | FindSong (const char *name_utf8) noexcept
void | AddSong (Song *song)
| Add a song object to this directory. More...
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. More...
void | PruneEmpty () noexcept
| Caller must lock the db_mutex. More...
void | Sort () noexcept
| 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 noexcept

## Static Public Member Functions
static gcc_malloc Directory * | NewRoot ()
| 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
Directory * | parent
time_t | mtime
uint64_t | inode
uint64_t | device
std::string | path
Database * | mounted_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

## ◆ Hook

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

Definition at line 52 of file Directory.hxx.

## ◆ LinkMode

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

Definition at line 51 of file Directory.hxx.

## ◆ List

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

Definition at line 67 of file Directory.hxx.

## ◆ SiblingsHook

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

Definition at line 65 of file Directory.hxx.

## Constructor & Destructor Documentation

## ◆ Directory()

Directory::Directory | ( | std::string && | _path_utf8,
|  | Directory * | _parent
| ) |  |

## ◆ ~Directory()

Directory::~Directory | ( |  | ) |

## Member Function Documentation

## ◆ AddSong()

void Directory::AddSong | ( | Song * | song | ) |

Add a song object to this directory.

Its "parent" attribute must be set already.

## ◆ CreateChild()

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_utf8 | the UTF-8 encoded name of the new sub directory

## ◆ Delete()

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.

## ◆ Export()

gcc_pure LightDirectory Directory::Export | ( |  | ) | const
| noexcept

## ◆ FindChild() [1/2]

gcc_pure const Directory* Directory::FindChild | ( | const char * | name | ) | const
| noexcept

Caller must lock the db_mutex.

## ◆ FindChild() [2/2]

gcc_pure Directory* Directory::FindChild | ( | const char * | name | ) |
| inlinenoexcept

Definition at line 139 of file Directory.hxx.

## ◆ FindSong() [1/2]

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

Look up a song in this directory by its name.

Caller must lock the db_mutex.

## ◆ FindSong() [2/2]

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

Definition at line 234 of file Directory.hxx.

## ◆ ForEachChildSafe()

template<typename T >

void Directory::ForEachChildSafe | ( | T && | t | ) |
| inline

Definition at line 208 of file Directory.hxx.

## ◆ ForEachSongSafe()

template<typename T >

void Directory::ForEachSongSafe | ( | T && | t | ) |
| inline

Definition at line 217 of file Directory.hxx.

## ◆ GetName()

gcc_pure const char* Directory::GetName | ( |  | ) | const
| noexcept

Returns the base name of the directory.

## ◆ GetPath()

gcc_pure const char* Directory::GetPath | ( |  | ) | const
| inlinenoexcept

Definition at line 189 of file Directory.hxx.

## ◆ IsEmpty()

gcc_pure bool Directory::IsEmpty | ( |  | ) | const
| inlinenoexcept

Definition at line 182 of file Directory.hxx.

## ◆ IsMount()

bool Directory::IsMount | ( |  | ) | const
| inline

Definition at line 111 of file Directory.hxx.

## ◆ IsRoot()

gcc_pure bool Directory::IsRoot | ( |  | ) | const
| inlinenoexcept

Is this the root directory of the music database?

Definition at line 203 of file Directory.hxx.

## ◆ LookupDirectory()

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

Looks up a directory by its relative URI.

Parameters

  uri | the relative URI

Returns
  the Directory, or nullptr if none was found

## ◆ MakeChild()

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 150 of file Directory.hxx.

## ◆ NewRoot()

static gcc_malloc Directory* Directory::NewRoot | ( |  | ) |
| inlinestatic

Create a new root Directory object.

Definition at line 107 of file Directory.hxx.

## ◆ PruneEmpty()

void Directory::PruneEmpty | ( |  | ) |
| noexcept

Caller must lock the db_mutex.

## ◆ RemoveSong()

void Directory::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.

## ◆ Sort()

void Directory::Sort | ( |  | ) |
| noexcept

Sort all directory entries recursively.

Caller must lock the db_mutex.

## ◆ Walk()

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

## ◆ children

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.

## ◆ device

uint64_t Directory::device

Definition at line 89 of file Directory.hxx.

## ◆ inode

uint64_t Directory::inode

Definition at line 89 of file Directory.hxx.

## ◆ link_mode

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

Definition at line 50 of file Directory.hxx.

## ◆ mounted_database

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.

## ◆ mtime

time_t Directory::mtime

Definition at line 88 of file Directory.hxx.

## ◆ parent

Directory* Directory::parent

Definition at line 87 of file Directory.hxx.

## ◆ path

std::string Directory::path

Definition at line 91 of file Directory.hxx.

## ◆ playlists

PlaylistVector Directory::playlists

Definition at line 85 of file Directory.hxx.

## ◆ siblings

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.

## ◆ songs

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:

- db/plugins/simple/Directory.hxx