#include <cascade/util/CascadeSettings.h>
Inheritance diagram for CascadeSettings:
Public Types | |
typedef bool() | IntegerValueEnumProc (const CascadeString &variableName, const s32 value, void *pClientData) |
typedef bool() | StringValueEnumProc (const CascadeString &variableName, const CascadeString &value, void *pClientData) |
Public Member Functions | |
CascadeSettings (const CascadeString §ionName) | |
virtual | ~CascadeSettings () |
sectionName the section name for the settings | |
bool | SectionExists () |
bool | CreateSection () |
bool | ReadStringValue (const CascadeString &variableName, CascadeString &valueToSet) |
bool | WriteStringValue (const CascadeString &variableName, const CascadeString &value) |
bool | ReadIntegerValue (const CascadeString &variableName, s32 &valueToSet) |
bool | WriteIntegerValue (const CascadeString &variableName, const s32 &value) |
void | Flush () |
void | DeleteIntegerValue (const CascadeString &variableName) |
void | DeleteStringValue (const CascadeString &variableName) |
variableName the variable to delete | |
void | DeleteSection () |
variableName the variable to delete | |
bool | EnumerateIntegerValues (IntegerValueEnumProc *pEnumProc, void *pClientData) |
bool | EnumerateStringValues (StringValueEnumProc *pEnumProc, void *pClientData) |
CascadeSettings provides an easy method for Cascade programs to get and set persistent configuration variables. A CascadeSettings class instance is instantiated with a CascadeString that specifies the section the settings apply to. For example, an application named "DonsCoolApp" written by a developer affiliated with woodward.org might use a section named "org.woodward.DonsCoolApp". All Roku apps use sections of the form "com.roku.XXX".
When a CascadeSettings class instance is instantiated, the persistent backing data for the section may or may not exist. This can be determined by calling SectionExists(). If the section does not exist and the client wants to create the section, then CreateSection() should be called.
Within a section, string variable names are mapped to string or integer values, or both. If a variable does not exist with a string or integer value, the corresponding Read() function will return false. Variable names may be added to the persistent store for the section by calling the appropriate Write() function.
Example:
CascadeSettings settings(CascadeString("com.roku.deschutes.videosettings")); bool bSectionCreated = settings.SectionExists(); if (! bSectionCreated) bSectionCreated = settings.CreateSection(); if (! bSectionCreated) { /* bogus! */ return; }
// I now know that the section "com.roku.deschutes.videosettings" exists!! CascadeString outputWidthVariableName("OutputWidth"); s32 nOutputWidth = 0; if (settings.ReadIntegerValue(outputWidthVariableName, nOutputWidth)) { // the output width was read from the settings } else { // the output width is not in the settings, set it to my default nOutputWidth = 1280; settings.WriteIntegerValue(outputWidthVariableName, nOutputWidth); }
|
Callback function for enumerating integer values Clients provide their own IntegerValueEnumProc to the EnumerateIntegerValues() function. Your custom IntegerValueEnumProc will get called back by the EnumerateIntegerValues() function, one for each integer variable contained in the section
|
|
Callback function for enumerating string values Clients provide their own StringValueEnumProc to the EnumerateStringValues() function. Your custom StringValueEnumProc will get called back by the EnumerateStringValues() function, one for each string variable contained in the section
|
|
constructs a CascadeSettings object for the specified section The CascadeSettings constructor constructs a settings instance for the |
|
sectionName the section name for the settings destructor This is the CascadeSettings destructor. |
|
creates the section if it does not already exist CreateSection() creates the section if it doesn't already exist.
|
|
deletes the value associated with an integer variable DeleteIntegerValue() deletes the value associated with an integer variable. |
|
variableName the variable to delete deletes the section and all values DeleteSection() deletes the section and all of its variables |
|
variableName the variable to delete deletes the value associated with a string variable DeleteIntegerValue() deletes the value associated with a string variable. |
|
enumerates integer variable values in the section call EnumerateIntegerValues() to enumerate the integer variables within the section.
|
|
enumerates string variable values in the section call EnumerateStringValues() to enumerate the string variables within the section.
|
|
flushes settings to persistent store Flush() forces any pending changes in settings to be written to persistent store. This is unnecessary on the HD1000 and is used on SoundBridge to force flush changes to the serial flash prior to a software reboot. |
|
reads the integer value for a variable within the section ReadIntegerValue() reads an integer value for a variable within the section. |
|
reads the string value for a variable within the section ReadStringValue() reads a string value for a variable within the section. |
|
determines whether or not the section exists SectionExists() determines whether or not the section exists.
|
|
writes an integer value for a variable to the section WriteIntegerValue() writes an integer value for a variable to the section. |
|
writes a string value for a variable to the section WriteStringValue() writes a string value for a variable to the section. |