pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Private Attributes | List of all members
UserData::Dictionary< TKey, TValue, TStorage > Class Template Reference

Store key-value pairs of arbitrary key and value types. More...

#include <datastore.h>

Inheritance diagram for UserData::Dictionary< TKey, TValue, TStorage >:
Inheritance graph
[legend]
Collaboration diagram for UserData::Dictionary< TKey, TValue, TStorage >:
Collaboration graph
[legend]

Public Member Functions

 Dictionary (const std::string &_origin, const std::string &_id)
 
virtual const std::string & origin (void) const override
 Retrieve the origin (type of data) stored in this storage unit. More...
 
virtual const std::string & identity (void) const override
 Retrieve the identity (primary identifier) of the data in this storage unit. More...
 
void rename (const std::string new_id)
 
bool add (const TKey &key, const TValue &value)
 
const TValue & get (const TKey &key, const TValue &def) const
 
 Dictionary (const Parsnip::Data &data)
 
virtual bool reconstitute (const Parsnip::Data &data) override
 Restore data from a JSON source. More...
 
virtual Parsnip::Data persist () const override
 Persist data using Parsnip. More...
 
- Public Member Functions inherited from UserData::DataStore
virtual ~DataStore (void)
 
bool isSourceData (void) const
 

Private Attributes

const std::string originid
 
const std::string id
 

Additional Inherited Members

- Static Public Member Functions inherited from UserData::DataStore
static bool isSourceData (const std::string &origin)
 

Detailed Description

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
class UserData::Dictionary< TKey, TValue, TStorage >

Store key-value pairs of arbitrary key and value types.

Template Parameters
TKeyThe type of the key. Always string, at the moment.
TValueThe type of the data.
TStorageThe type of the data when serialized.

Constructor & Destructor Documentation

◆ Dictionary() [1/2]

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
UserData::Dictionary< TKey, TValue, TStorage >::Dictionary ( const std::string &  _origin,
const std::string &  _id 
)
inline

◆ Dictionary() [2/2]

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
UserData::Dictionary< TKey, TValue, TStorage >::Dictionary ( const Parsnip::Data data)
inline
Here is the call graph for this function:

Member Function Documentation

◆ add()

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
bool UserData::Dictionary< TKey, TValue, TStorage >::add ( const TKey &  key,
const TValue &  value 
)
inline

◆ get()

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
const TValue& UserData::Dictionary< TKey, TValue, TStorage >::get ( const TKey &  key,
const TValue &  def 
) const
inline
Here is the caller graph for this function:

◆ identity()

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
virtual const std::string& UserData::Dictionary< TKey, TValue, TStorage >::identity ( void  ) const
inlineoverridevirtual

Retrieve the identity (primary identifier) of the data in this storage unit.

Implements UserData::DataStore.

Here is the caller graph for this function:

◆ origin()

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
virtual const std::string& UserData::Dictionary< TKey, TValue, TStorage >::origin ( void  ) const
inlineoverridevirtual

Retrieve the origin (type of data) stored in this storage unit.

Implements UserData::DataStore.

Here is the caller graph for this function:

◆ persist()

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
virtual Parsnip::Data UserData::Dictionary< TKey, TValue, TStorage >::persist ( ) const
inlineoverridevirtual

Persist data using Parsnip.

Returns
A Parsnip Data object suitable for serialization.

Implements UserData::DataStore.

Here is the call graph for this function:

◆ reconstitute()

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
virtual bool UserData::Dictionary< TKey, TValue, TStorage >::reconstitute ( const Parsnip::Data data)
inlineoverridevirtual

Restore data from a JSON source.

Parameters
dataData to restore from.
Returns
True on success, false otherwise.

Implements UserData::DataStore.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rename()

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
void UserData::Dictionary< TKey, TValue, TStorage >::rename ( const std::string  new_id)
inline

Member Data Documentation

◆ id

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
const std::string UserData::Dictionary< TKey, TValue, TStorage >::id
private

◆ originid

template<class TKey = std::string, class TValue = std::string, class TStorage = TValue>
const std::string UserData::Dictionary< TKey, TValue, TStorage >::originid
private

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