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

Developer

resources

Creating a new native store

To create a new native store, do the following:

  1. Implement the ISettingsStoreFactory interface for your new type of settings store.

    Each ISettingsStoreFactory implementation will contain its own implementation of the ISettings interface. When ISettingsStoreFactory_Create() is called, it returns a pointer to this ISettings object.

  2. Register the subtree of the registry with SettingsReg using RegisterCustomStore{} in the CIF. This can include optional parameters to pass to the factory as well as settings ACLs to allow other modules access to your subtree in the registry.
    -- my settings will be located under "/myApp/settings/..."
          s:RegisterCustomStore {
             owner = 0x9876dcba,
             key = "/myApp/settings",
             store = AEECLSID_SomeStoreFactory,
             args = { key = "value" }    -- optional key/value pairs to
                                         -- pass to the factory
             acls = {                    -- optional ACLs to limit access
             {
                -- grant everyone read access to my settings but write
                -- access to only those modules belonging to the
                -- 0x7654fedc group
                {
                   groups = {0}, 
                   perms = "r/r",
                },
                {
                   groups = {0x7654fedc}, 
                   perms = "rw/rw",
                },
                path = "/myApp/settings"
             }
          }
    • owner is the ClassID of the component that owns this registry subtree. The owner ClassID is required and is used to create an implicit R/W ACL for the subtree.
    • key is the full settings path that specifies the root of the subtree. The settings will be located under this root. In this example, the settings are accessed under the /myApp/settings/ subtree.
    • store is the ClassID of the implementation of ISettingsStoreFactory that will be used to create the ISettings implementation to manage the settings.
    • args is a table of any extra information (name/value pairs) that the factory may require to create/manage the store.
    • acls is a table of ACLs.

    All parameters passed to RegisterCustomStore{} are built into a string and provided to the call to ISettingsStoreFactory_Create().

Using the new native store

To use your new native store in an application or component, include the SettingsCIFHelpers helper script and the factory .bid file in the CIF for the application or component. For the example shown above, the following lines are added to the CIF:

include "AEESomeStoreFactory.bid"
local s = require 'SettingsCIFHelpers'