Persist

ILxPersistenceService

class ILxPersistenceService

The service provides methods to define the setup of the configuration.

Public Functions

LxResult ScriptQuery(LXtObjectID self, void **ppvObj)
LxResult Configure(LXtObjectID self, const char *name, LXtObjectID obj)

Clients call this method to define a set of persistent attributes. The name will define a top-level atom in the config file which should be unique. The object can be a visitor which, when evaluated, should add entries and values. It should be noted that this function should only be called once for any top-level name during the lifetime of the application. Attempting to call it again will return an error.

LxResult Start(LXtObjectID self, const char *name, unsigned int type)

During configuration, these calls define the nested hierarchy of entries. Each entry has a name and a type atom, hash or list. Ending the entry definition returns the persistent entry object which can be use to traverse persistent values.

LxResult End(LXtObjectID self, void **ppvObj)
LxResult AddValue(LXtObjectID self, const char *typeName)

While in an entry definition, values can be added. Currently only one value per entry is allowed. The type name is any of the value types.

LxResult ConfigureVis(const char *name, CLxImpl_AbstractVisitor *visitor)

User Class Only: This user method on the service takes a C++ visitor object and wraps it for COM.

bool EndDef(CLxLoc_PersistentEntry &entry)

User Class Only: Alternate version of the End() method to get the persistent entry in more C++ friendly terms.

  • LXi_PERSIST_ATOM

  • LXi_PERSIST_HASH

  • LXi_PERSIST_LIST

ILxPersistenceClient

class ILxPersistenceClient

In most case the client will maintain persistent state in the host app and read it whenever it’s needed. This allows the client to react to changes to the application persistent state (like if the user imports new configs) but it can be slower than desired for very complex resource definitions, for example. If that’s the case the client will want to cache their state internally, but they then need to be able to react to config system events. If this is required the client can pass a PersistenceClient object in the call to Configure() instead of a visitor. In this case the object itself will persist, and methods will be used to manage synchnonization.

Public Functions

LxResult Setup(LXtObjectID self)

  • Setup Called to configure the entries and values, like Evaluate() from a visitor.

  • SyncRead Called when the client should read its state from the application. This will be called after a successful initial setup.

  • SyncRead Called when the client should write its cached state to the application.

LxResult SyncRead(LXtObjectID self)
LxResult SyncWrite(LXtObjectID self)

ILxPersistentEntry

class ILxPersistentEntry

Access to persistent state is through a persistent entry interface. The value for sub-entries depends on the values of their parent entries, so those need to be set in order to get valid results for sub-entries.

Public Functions

LxResult Count(LXtObjectID self, unsigned int *count)

Entry objects also have an ILxAttributes interface for accessing their values, although for now all values are index 0. Count() tells you how many values there are for this entry. For atoms this is 0 or 1, depending on whether it’s defined. For lists and hashes this can be more than one.

LxResult Select(LXtObjectID self, unsigned int index)

These methods pick the specific entry. Select() uses and index and works for lists or hashes, and Lookup() uses a key and is only for hashes. Entries that are atoms don’t need to be explicitly selected.

LxResult Lookup(LXtObjectID self, const char *key)
LxResult Append(LXtObjectID self)

These methods add new values Append() for atoms and lists, and Insert() for hashes.

LxResult Insert(LXtObjectID self, const char *key)
LxResult Delete(LXtObjectID self)

These methods remove values. Delete() removes this specific value, while Clear() removes all values of this type from the current parent.

LxResult Clear(LXtObjectID self)
LxResult Hash(LXtObjectID self, const char **key)

For hash entries, this returns the hash itself.

int Number()

User Class Only: Easier way to get the entry count, with -1 for errors.

LxResult Lookup(const std::string &key)

User Class Only: Standard string lookup.

LxResult Insert(const std::string &key)

User Class Only: Standard string insertion.