|
pianod2
multisource multiuser scriptable networked music player
|
Customized hash tables for music library. More...
#include <musiclibrary.h>


Public Types | |
| using | Allocator = std::function< TThing *(TParent *const, const std::string &, const std::string &)> |
Public Member Functions | |
| ThingieContainer (const Allocator &alloc) | |
| Constructor: Construct a new ThingieContainer and assign it an allocator. More... | |
| ~ThingieContainer () | |
| Destructor: Release all contents prior to destruction. More... | |
| void | clear () |
| Remove all items from the hash table. More... | |
| void | purge (bool pred(const TThing *)) |
| Remove items according to the predicate. More... | |
| TThing * | getById (const std::string &key) const |
| Get a thing by its id. More... | |
| TThing * | getById (const Parsnip::Data &data, const char *field) |
| Get a thing by its id, getting the ID from JSON data. More... | |
| TThing * | getByName (const std::string &name, TParent *parent) const |
| Search the things looking for a name and parent match. More... | |
| std::string | getNewId (MusicThingie::Type item_type) const |
| Construct unique, random ID for a new item. More... | |
| TThing * | addItem (const std::string &name, std::string id, TParent *parent) |
| Construct a new item instance and add it to the hash by its ID. More... | |
| TThing * | addOrGetItem (const std::string &name, std::string id, TParent *parent) |
| Retrieve an item by ID or by name. More... | |
| TThing * | addOrGetItem (const std::string &name, TParent *parent) |
| TThing * | addOrGetItem (const Parsnip::Data &data, TParent *parent, const std::string &namefield, const std::string &idfield) |
| Reconstitute an item from a persisted file. More... | |
Private Attributes | |
| const Allocator | allocate |
| An allocator for making new items of derived types we could store. More... | |
Customized hash tables for music library.
These add persist/restore capabilities, and provide for items that are cross-linked with parent objects.
| using MusicLibrary::ThingieContainer< TThing, TParent >::Allocator = std::function <TThing * (TParent *const, const std::string &, const std::string &)> |
| MusicLibrary::ThingieContainer< TThing, TParent >::ThingieContainer | ( | const Allocator & | alloc | ) |
Constructor: Construct a new ThingieContainer and assign it an allocator.
| MusicLibrary::ThingieContainer< TThing, TParent >::~ThingieContainer |
Destructor: Release all contents prior to destruction.
| TThing * MusicLibrary::ThingieContainer< TThing, TParent >::addItem | ( | const std::string & | name, |
| std::string | id, | ||
| TParent * | parent | ||
| ) |
Construct a new item instance and add it to the hash by its ID.
| name | The new item's name. |
| id | The item's ID, if known, or the empty string. |
| parent | The parent object to which the new item will be linked. |

| TThing * MusicLibrary::ThingieContainer< TThing, TParent >::addOrGetItem | ( | const Parsnip::Data & | data, |
| TParent * | parent, | ||
| const std::string & | namefield, | ||
| const std::string & | idfield | ||
| ) |
Reconstitute an item from a persisted file.
| data | The JSON node with data to be restored. |
| parent | The parent to which the new record will be attached. |
| namefield | The name of the name field within data. |
| idfield | The name of the ID field within data. |

| TThing * MusicLibrary::ThingieContainer< TThing, TParent >::addOrGetItem | ( | const std::string & | name, |
| std::string | id, | ||
| TParent * | parent | ||
| ) |
Retrieve an item by ID or by name.
| name | The name to search for. |
| id | The ID to search for. |
| parent | The parent item. |


|
inline |

| void MusicLibrary::ThingieContainer< TThing, TParent >::clear |
Remove all items from the hash table.

| TThing * MusicLibrary::ThingieContainer< TThing, TParent >::getById | ( | const Parsnip::Data & | data, |
| const char * | field | ||
| ) |
Get a thing by its id, getting the ID from JSON data.
| TThing * MusicLibrary::ThingieContainer< TThing, TParent >::getById | ( | const std::string & | key | ) | const |
Get a thing by its id.

| TThing * MusicLibrary::ThingieContainer< TThing, TParent >::getByName | ( | const std::string & | name, |
| TParent * | parent | ||
| ) | const |
Search the things looking for a name and parent match.

| std::string MusicLibrary::ThingieContainer< TThing, TParent >::getNewId | ( | MusicThingie::Type | item_type | ) | const |
Construct unique, random ID for a new item.
| item_type | The type code for the item. |
| void MusicLibrary::ThingieContainer< TThing, TParent >::purge | ( | bool | predconst TThing * | ) |
Remove items according to the predicate.
| pred | Predicate, which returns true to indicate removal. |

|
private |
An allocator for making new items of derived types we could store.