Open Lighting Architecture: ola::MemoryPreferences Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Member Functions | Protected Types | Protected Attributes | List of all members
ola::MemoryPreferences Class Reference
Inheritance diagram for ola::MemoryPreferences:

## Public Member Functions
| MemoryPreferences (const std::string name)
virtual bool | Load ()
virtual bool | Save () const
virtual void | Clear ()
virtual std::string | ConfigLocation () const
| The location of where these preferences are stored.
virtual void | SetValue (const std::string &key, const std::string &value)
| Set a preference value, overriding the existing value.
virtual void | SetValue (const std::string &key, unsigned int value)
| Set a preference value, overriding the existing value. This helper accepts an unsigned int.
virtual void | SetValue (const std::string &key, int value)
| Set a preference value, overriding the existing value. This helper accepts an int.
virtual void | SetMultipleValue (const std::string &key, const std::string &value)
| Adds this preference value to the store.
virtual void | SetMultipleValue (const std::string &key, unsigned int value)
| Adds this preference value to the store. This helper accepts an unsigned int.
virtual void | SetMultipleValue (const std::string &key, int value)
| Adds this preference value to the store. This helper accepts an int.
virtual bool | SetDefaultValue (const std::string &key, const Validator &validator, const std::string &value)
| Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator.
virtual bool | SetDefaultValue (const std::string &key, const Validator &validator, const char value[])
| Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator. This helper accepts a char array to force it to a string.
virtual bool | SetDefaultValue (const std::string &key, const Validator &validator, unsigned int value)
| Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator. This helper accepts an unsigned int value.
virtual bool | SetDefaultValue (const std::string &key, const Validator &validator, int value)
| Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator. This helper accepts an int value.
virtual bool | SetDefaultValue (const std::string &key, const Validator &validator, bool value)
| Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator. This helper accepts a bool value.
virtual std::string | GetValue (const std::string &key) const
| Get a preference value.
virtual std::vector< std::string > | GetMultipleValue (const std::string &key) const
| Returns all preference values corresponding to this key.
virtual bool | HasKey (const std::string &key) const
| Check if a preference key exists.
virtual void | RemoveValue (const std::string &key)
| Remove a preference value.
virtual bool | GetValueAsBool (const std::string &key) const
| Get a preference value as a bool.
virtual void | SetValueAsBool (const std::string &key, bool value)
| Set a value as a bool.
bool | operator== (const MemoryPreferences &other)
Public Member Functions inherited from ola::Preferences
| Preferences (const std::string name)
virtual | ~Preferences ()

## Protected Types
typedef std::multimap< std::string, std::string > | PreferencesMap

## Protected Attributes
PreferencesMap | m_pref_map
Protected Attributes inherited from ola::Preferences
std::string | m_preference_name

## Member Function Documentation

## ◆ Clear()

void ola::MemoryPreferences::Clear | ( |  | ) |
| virtual

Clear the preferences

Implements ola::Preferences.

## ◆ ConfigLocation()

virtual std::string ola::MemoryPreferences::ConfigLocation | ( |  | ) | const
| inlinevirtual

The location of where these preferences are stored.

Returns
  the location

Implements ola::Preferences.

Reimplemented in ola::FileBackedPreferences.

## ◆ GetMultipleValue()

vector< string > ola::MemoryPreferences::GetMultipleValue | ( | const std::string & | key | ) | const
| virtual

Returns all preference values corresponding to this key.

Parameters

  key | the key to fetch

Returns
  a vector of strings.

Implements ola::Preferences.

## ◆ GetValue()

string ola::MemoryPreferences::GetValue | ( | const std::string & | key | ) | const
| virtual

Get a preference value.

Parameters

  key | the key to fetch

Returns
  the value corresponding to key, or the empty string if the key doesn't exist.

Implements ola::Preferences.

## ◆ GetValueAsBool()

bool ola::MemoryPreferences::GetValueAsBool | ( | const std::string & | key | ) | const
| virtual

Get a preference value as a bool.

Parameters

  key | the key to fetch

Returns
  true if the value is 'true' or false otherwise

Implements ola::Preferences.

## ◆ HasKey()

bool ola::MemoryPreferences::HasKey | ( | const std::string & | key | ) | const
| virtual

Check if a preference key exists.

Parameters

  key | the key to check

Returns
  true if the key exists, false otherwise.

Implements ola::Preferences.

## ◆ Load()

virtual bool ola::MemoryPreferences::Load | ( |  | ) |
| inlinevirtual

Load the preferences from storage

Implements ola::Preferences.

Reimplemented in ola::FileBackedPreferences.

## ◆ RemoveValue()

void ola::MemoryPreferences::RemoveValue | ( | const std::string & | key | ) |
| virtual

Remove a preference value.

Parameters

  key |

Implements ola::Preferences.

## ◆ Save()

virtual bool ola::MemoryPreferences::Save | ( |  | ) | const
| inlinevirtual

Save the preferences to storage

Implements ola::Preferences.

Reimplemented in ola::FileBackedPreferences.

## ◆ SetDefaultValue() [1/5]

bool ola::MemoryPreferences::SetDefaultValue | ( | const std::string & | key,
|  | const Validator & | validator,
|  | bool | value )
| virtual

Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator. This helper accepts a bool value.

Note
  Note this only checks the first value's validity.

Parameters

  key | the key to check/set
  validator | A Validator object
  value | the new value

Returns
  true if we set the value, false if it already existed

Implements ola::Preferences.

## ◆ SetDefaultValue() [2/5]

bool ola::MemoryPreferences::SetDefaultValue | ( | const std::string & | key,
|  | const Validator & | validator,
|  | const char | value[] )
| virtual

Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator. This helper accepts a char array to force it to a string.

Note
  Note this only checks the first value's validity.

Parameters

  key | the key to check/set
  validator | A Validator object
  value | the new value

Returns
  true if we set the value, false if it already existed

Implements ola::Preferences.

## ◆ SetDefaultValue() [3/5]

bool ola::MemoryPreferences::SetDefaultValue | ( | const std::string & | key,
|  | const Validator & | validator,
|  | const std::string & | value )
| virtual

Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator.

Note
  Note this only checks the first value's validity.

Parameters

  key | the key to check/set
  validator | A Validator object
  value | the new value

Returns
  true if we set the value, false if it already existed

Implements ola::Preferences.

## ◆ SetDefaultValue() [4/5]

bool ola::MemoryPreferences::SetDefaultValue | ( | const std::string & | key,
|  | const Validator & | validator,
|  | int | value )
| virtual

Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator. This helper accepts an int value.

Note
  Note this only checks the first value's validity.

Parameters

  key | the key to check/set
  validator | A Validator object
  value | the new value

Returns
  true if we set the value, false if it already existed

Implements ola::Preferences.

## ◆ SetDefaultValue() [5/5]

bool ola::MemoryPreferences::SetDefaultValue | ( | const std::string & | key,
|  | const Validator & | validator,
|  | unsigned int | value )
| virtual

Set a preference value if it doesn't already exist, or if it exists and doesn't pass the validator. This helper accepts an unsigned int value.

Note
  Note this only checks the first value's validity.

Parameters

  key | the key to check/set
  validator | A Validator object
  value | the new value

Returns
  true if we set the value, false if it already existed

Implements ola::Preferences.

## ◆ SetMultipleValue() [1/3]

void ola::MemoryPreferences::SetMultipleValue | ( | const std::string & | key,
|  | const std::string & | value )
| virtual

Adds this preference value to the store.

Parameters

  key |
  value |

Implements ola::Preferences.

## ◆ SetMultipleValue() [2/3]

void ola::MemoryPreferences::SetMultipleValue | ( | const std::string & | key,
|  | int | value )
| virtual

Adds this preference value to the store. This helper accepts an int.

Parameters

  key |
  value |

Implements ola::Preferences.

## ◆ SetMultipleValue() [3/3]

void ola::MemoryPreferences::SetMultipleValue | ( | const std::string & | key,
|  | unsigned int | value )
| virtual

Adds this preference value to the store. This helper accepts an unsigned int.

Parameters

  key |
  value |

Implements ola::Preferences.

## ◆ SetValue() [1/3]

void ola::MemoryPreferences::SetValue | ( | const std::string & | key,
|  | const std::string & | value )
| virtual

Set a preference value, overriding the existing value.

Parameters

  key |
  value |

Implements ola::Preferences.

## ◆ SetValue() [2/3]

void ola::MemoryPreferences::SetValue | ( | const std::string & | key,
|  | int | value )
| virtual

Set a preference value, overriding the existing value. This helper accepts an int.

Parameters

  key |
  value |

Implements ola::Preferences.

## ◆ SetValue() [3/3]

void ola::MemoryPreferences::SetValue | ( | const std::string & | key,
|  | unsigned int | value )
| virtual

Set a preference value, overriding the existing value. This helper accepts an unsigned int.

Parameters

  key |
  value |

Implements ola::Preferences.

## ◆ SetValueAsBool()

void ola::MemoryPreferences::SetValueAsBool | ( | const std::string & | key,
|  | bool | value )
| virtual

Set a value as a bool.

Parameters

  key |
  value |

Implements ola::Preferences.

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

- include/olad/Preferences.h
- olad/plugin_api/Preferences.cpp