Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Using private heap-based settings

Development:

Do the following:

  1. Create an instance of SettingsHeapFactory.
  2. Call ISettingsStoreFactory_Create(), which will return an ISettings implementation instance.
  3. Use this ISettings instance for all ISettings calls.

Run-time:

  1. An instance of heapStoreFactory is created.
  2. ISettingsStoreFactory_Create() internally creates a Settings Factory Store based on the parameters passed to ISettingsStoreFactory_Create() and returns an ISettings implementation.
  3. All ISettings calls operate on this ISettings implementation.

Accessing a private heap-based settings store is similar to accessing an .ini file-based store. The main difference is the absence of the .ini file. Instead, creating a heap-based setting store requires a quota value that determines the maximum amount of heap that may be used by the store.

Follow these steps to add a private heap-based settings store to an application or component:

  1. Add code to your application or component to create the store. For example:
       ISettingsStoreFactory *piSSF = NULL;
       if (SUCCESS == IEnv_CreateInstance(piEnv, AEECLSID_SettingsHeapFactory,
                   (void**) &piSSF)) {
         ISettings *piSettings = NULL;
         int result;
         result = ISettingsStoreFactory_Create(
            piSSF,
            "quota=0x1000",
            &piSettings
         );
        
  2. Add code to the application or component to access the settings.

    Note: A heap-based setting does not exist until ISettings_Set() is called on it.

    For example:

    if (SUCCESS == result) {
            char outbuf[32];
            (void) ISettings_Set(piSettings, "foo/bar", "Hello world");
            result = ISettings_Get(piSettings, "foo/bar", outbuf,
                     sizeof(outbuf), NULL);
            if (SUCCESS == result) {
               // outbuf will contain "Hello world"
            }
            ISettings_Release(piSettings);
            pSettings = NULL;
         }