Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
ola::Preferences Class Reference
Inheritance diagram for ola::Preferences:
ola::MemoryPreferences ola::FileBackedPreferences

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 Source () const =0
 The location of where these preferences are stored.
virtual void SetValue (const std::string &key, const std::string &value)=0
 Set a preference value, overriding the existing value.
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.
virtual void SetValue (const std::string &key, int value)=0
 Set a preference value, overriding the existing value. This helper accepts an int.
virtual void SetMultipleValue (const std::string &key, const std::string &value)=0
 Adds this preference value to the store.
virtual void SetMultipleValue (const std::string &key, unsigned int value)=0
 Adds this preference value to the store. This helper accepts an unsigned int.
virtual void SetMultipleValue (const std::string &key, int value)=0
 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)=0
 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, 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.
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.
virtual std::string GetValue (const std::string &key) const =0
 Get a preference value.
virtual std::vector< std::string > GetMultipleValue (const std::string &key) const =0
 Returns all preference values corresponding to this key.
virtual bool HasKey (const std::string &key) const =0
 Check if a preference key exists.
virtual void RemoveValue (const std::string &key)=0
 Remove a preference value.
virtual bool GetValueAsBool (const std::string &key) const =0
 Get a preference value as a bool.
virtual void SetValueAsBool (const std::string &key, bool value)=0
 Set a value as a bool.

Protected Attributes

std::string m_preference_name

Constructor & Destructor Documentation

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

Destroy this object

Member Function Documentation

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

Clear the preferences

Implemented in ola::MemoryPreferences.

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.

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.

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.

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.

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

Load the preferences from storage

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

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

Remove a preference value.

Parameters
key

Implemented in ola::MemoryPreferences.

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

Save the preferences to storage

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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

The location of where these preferences are stored.

Returns
the location

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


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