MPD  0.20.15
Data Structures | Public Member Functions
CompositeStorage Class Referencefinal

A Storage implementation that combines multiple other Storage instances in one virtual tree. More...

#include <CompositeStorage.hxx>

Inheritance diagram for CompositeStorage:
[legend]
Collaboration diagram for CompositeStorage:
[legend]

Public Member Functions

 CompositeStorage () noexcept
 
virtual ~CompositeStorage ()
 
gcc_pure gcc_nonnull_all StorageGetMount (const char *uri) noexcept
 Get the Storage at the specified mount point. More...
 
template<typename T >
void VisitMounts (T t) const
 Call the given function for each mounted storage, including the root storage. More...
 
void Mount (const char *uri, Storage *storage)
 
bool Unmount (const char *uri)
 
StorageFileInfo GetInfo (const char *uri, bool follow) override
 Throws #std::runtime_error on error. More...
 
StorageDirectoryReaderOpenDirectory (const char *uri) override
 Throws #std::runtime_error on error. More...
 
std::string MapUTF8 (const char *uri) const noexcept override
 Map the given relative URI to an absolute URI. More...
 
AllocatedPath MapFS (const char *uri) const noexcept override
 Map the given relative URI to a local file path. More...
 
const char * MapToRelativeUTF8 (const char *uri) const noexcept override
 Check if the given URI points inside this storage. More...
 
- Public Member Functions inherited from Storage
 Storage ()=default
 
 Storage (const Storage &)=delete
 
virtual ~Storage ()
 
gcc_pure AllocatedPath MapChildFS (const char *uri_utf8, const char *child_utf8) const noexcept
 

Detailed Description

A Storage implementation that combines multiple other Storage instances in one virtual tree.

It is used to "mount" new Storage instances into the storage tree.

This class is thread-safe: mounts may be added and removed at any time in any thread.

Definition at line 39 of file CompositeStorage.hxx.

Constructor & Destructor Documentation

◆ CompositeStorage()

CompositeStorage::CompositeStorage ( )
noexcept

◆ ~CompositeStorage()

virtual CompositeStorage::~CompositeStorage ( )
virtual

Member Function Documentation

◆ GetInfo()

StorageFileInfo CompositeStorage::GetInfo ( const char *  uri_utf8,
bool  follow 
)
overridevirtual

Throws #std::runtime_error on error.

Implements Storage.

◆ GetMount()

gcc_pure gcc_nonnull_all Storage* CompositeStorage::GetMount ( const char *  uri)
noexcept

Get the Storage at the specified mount point.

Returns nullptr if the given URI is not a mount point.

The returned pointer is unprotected. No other thread is allowed to unmount the given mount point while the return value is being used.

◆ MapFS()

AllocatedPath CompositeStorage::MapFS ( const char *  uri_utf8) const
overridevirtualnoexcept

Map the given relative URI to a local file path.

Returns AllocatedPath::Null() on error or if this storage does not support local files.

Reimplemented from Storage.

◆ MapToRelativeUTF8()

const char* CompositeStorage::MapToRelativeUTF8 ( const char *  uri_utf8) const
overridevirtualnoexcept

Check if the given URI points inside this storage.

If yes, then it returns a relative URI (pointing inside the given string); if not, returns nullptr.

Implements Storage.

◆ MapUTF8()

std::string CompositeStorage::MapUTF8 ( const char *  uri_utf8) const
overridevirtualnoexcept

Map the given relative URI to an absolute URI.

Implements Storage.

◆ Mount()

void CompositeStorage::Mount ( const char *  uri,
Storage storage 
)

◆ OpenDirectory()

StorageDirectoryReader* CompositeStorage::OpenDirectory ( const char *  uri_utf8)
overridevirtual

Throws #std::runtime_error on error.

Implements Storage.

◆ Unmount()

bool CompositeStorage::Unmount ( const char *  uri)

◆ VisitMounts()

template<typename T >
void CompositeStorage::VisitMounts ( t) const
inline

Call the given function for each mounted storage, including the root storage.

Passes mount point URI and the a const Storage reference to the function.

Definition at line 112 of file CompositeStorage.hxx.


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