Open Lighting Architecture  Latest Git
Public Member Functions | Protected Attributes | List of all members
ola::Preferences Class Referenceabstract
Inheritance diagram for ola::Preferences:
Inheritance graph
[legend]
Collaboration diagram for ola::Preferences:
Collaboration graph
[legend]

Public Member Functions

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

Protected Attributes

std::string m_preference_name
 

Constructor & Destructor Documentation

◆ ~Preferences()

virtual ola::Preferences::~Preferences ( )
inlinevirtual

Destroy this object

Member Function Documentation

◆ Clear()

virtual void ola::Preferences::Clear ( )
pure virtual

Clear the preferences

Implemented in ola::MemoryPreferences.

◆ ConfigLocation()

virtual std::string ola::Preferences::ConfigLocation ( ) const
pure virtual

The location of where these preferences are stored.

Returns
the location

Implemented in ola::FileBackedPreferences, and ola::MemoryPreferences.

◆ GetMultipleValue()

virtual std::vector<std::string> ola::Preferences::GetMultipleValue ( const std::string &  key) const
pure virtual

Returns all preference values corresponding to this key.

Parameters
keythe key to fetch
Returns
a vector of strings.

Implemented in ola::MemoryPreferences.

◆ GetValue()

virtual std::string ola::Preferences::GetValue ( const std::string &  key) const
pure virtual

Get a preference value.

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

Implemented in ola::MemoryPreferences.

◆ GetValueAsBool()

virtual bool ola::Preferences::GetValueAsBool ( const std::string &  key) const
pure virtual

Get a preference value as a bool.

Parameters
keythe key to fetch
Returns
true if the value is 'true' or false otherwise

Implemented in ola::MemoryPreferences.

◆ HasKey()

virtual bool ola::Preferences::HasKey ( const std::string &  key) const
pure virtual

Check if a preference key exists.

Parameters
keythe key to check
Returns
true if the key exists, false otherwise.

Implemented in ola::MemoryPreferences.

◆ Load()

virtual bool ola::Preferences::Load ( )
pure virtual

Load the preferences from storage

Implemented in ola::FileBackedPreferences, and ola::MemoryPreferences.

◆ RemoveValue()

virtual void ola::Preferences::RemoveValue ( const std::string &  key)
pure virtual

Remove a preference value.

Parameters
key

Implemented in ola::MemoryPreferences.

◆ Save()

virtual bool ola::Preferences::Save ( ) const
pure virtual

Save the preferences to storage

Implemented in ola::FileBackedPreferences, and ola::MemoryPreferences.

◆ SetDefaultValue() [1/5]

virtual bool ola::Preferences::SetDefaultValue ( const std::string &  key,
const Validator validator,
const std::string &  value 
)
pure 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
keythe key to check/set
validatorA Validator object
valuethe new value
Returns
true if we set the value, false if it already existed

Implemented in ola::MemoryPreferences.

◆ SetDefaultValue() [2/5]

virtual bool ola::Preferences::SetDefaultValue ( const std::string &  key,
const Validator validator,
const char  value[] 
)
pure 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
keythe key to check/set
validatorA Validator object
valuethe new value
Returns
true if we set the value, false if it already existed

Implemented in ola::MemoryPreferences.

◆ SetDefaultValue() [3/5]

virtual bool ola::Preferences::SetDefaultValue ( const std::string &  key,
const Validator validator,
unsigned int  value 
)
pure 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
keythe key to check/set
validatorA Validator object
valuethe new value
Returns
true if we set the value, false if it already existed

Implemented in ola::MemoryPreferences.

◆ SetDefaultValue() [4/5]

virtual bool ola::Preferences::SetDefaultValue ( const std::string &  key,
const Validator validator,
int  value 
)
pure 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
keythe key to check/set
validatorA Validator object
valuethe new value
Returns
true if we set the value, false if it already existed

Implemented in ola::MemoryPreferences.

◆ SetDefaultValue() [5/5]

virtual bool ola::Preferences::SetDefaultValue ( const std::string &  key,
const Validator validator,
bool  value 
)
pure 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
keythe key to check/set
validatorA Validator object
valuethe new value
Returns
true if we set the value, false if it already existed

Implemented in ola::MemoryPreferences.

◆ SetMultipleValue() [1/3]

virtual void ola::Preferences::SetMultipleValue ( const std::string &  key,
const std::string &  value 
)
pure virtual

Adds this preference value to the store.

Parameters
key
value

Implemented in ola::MemoryPreferences.

◆ SetMultipleValue() [2/3]

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

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

Parameters
key
value

Implemented in ola::MemoryPreferences.

◆ SetMultipleValue() [3/3]

virtual void ola::Preferences::SetMultipleValue ( const std::string &  key,
int  value 
)
pure virtual

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

Parameters
key
value

Implemented in ola::MemoryPreferences.

◆ SetValue() [1/3]

virtual void ola::Preferences::SetValue ( const std::string &  key,
const std::string &  value 
)
pure virtual

Set a preference value, overriding the existing value.

Parameters
key
value

Implemented in ola::MemoryPreferences.

◆ SetValue() [2/3]

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

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

Parameters
key
value

Implemented in ola::MemoryPreferences.

◆ SetValue() [3/3]

virtual void ola::Preferences::SetValue ( const std::string &  key,
int  value 
)
pure virtual

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

Parameters
key
value

Implemented in ola::MemoryPreferences.

◆ SetValueAsBool()

virtual void ola::Preferences::SetValueAsBool ( const std::string &  key,
bool  value 
)
pure virtual

Set a value as a bool.

Parameters
key
value

Implemented in ola::MemoryPreferences.


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