Struct PntosRegistry
Defined in File common.h
Struct Documentation
-
struct PntosRegistry
A registry of key/value data which is organized by (string) groups. In order to get/set a key in the registry, one must call PntosRegistry.batch_start with the group the key is stored under and then use the resulting PntosKeyValueStore to get/set the key/value pair. When one is done accessing keys in the PntosKeyValueStore, they must call PntosKeyValueStore.batch_end. It is not permitted to access any member inside the PntosKeyValueStore after a batch has ended. If a user has ended a batch and then desires to access the PntosKeyValueStore again, they may use the PntosKeyValueStore.batch_restart method.
Public Members
-
PntosManagedMemory *memory
-
PntosKeyValueStore *(*batch_start)(struct PntosRegistry *self, char *group)
Begin a batch get/set operation wherein the user may make any number of modifications to the keys/values in the
group. The registry implementation may wait to batch these requests until PntosKeyValueStore.batch_end is called for better performance. For example, a lock may be obtained at the beginning of a batch_start and not released until a PntosKeyValueStore.batch_end call is encountered. Thus, a plugin that calls batch_start should endeavour to make its calls to the “set_”, “get_”, and “register” methods as quickly as possible and call PntosKeyValueStore.batch_end immediately, as doing otherwise may be locking other plugins out of access to the registry (depending on the registry plugin implementation). If a plugin supports PntosKeyValueStore.request_notify, then notifications of updates may be suspended until the batch ends. After a batch is ended, the returned PntosKeyValueStore can still be used to access the store via PntosKeyValueStore.batch_restart.Note
While a batch is active, access to the store may be denied to other users. Thus a user should endeavour to call PntosKeyValueStore.batch_end as soon as possible after they are done getting/setting values in the returned PntosKeyValueStore.
-
PntosStringArray *(*get_group_array)(struct PntosRegistry *self)
Get the array of groups which currently exist. Returns NULL if no groups exist.
-
bool (*has_group)(struct PntosRegistry *self, char *group)
Returns whether or not a given group has had any values added to it (for any key).
-
bool (*request_notify_new_group)(struct PntosRegistry *self, void *receiver, void (*callback)(void *receiver, char *new_group))
Register a callback which gets called each time a new group is made in the registry. Returns true if the notifier was successfully registered, and false if the registry is unable to notify the requester. The callback will receive the same receiver as was passed into this method, which may be used as a context object. The
new_groupparameter passed into the callback is the name of the new group that was created.Note
This method will retain the receiver beyond the lifetime of the function call, as the purpose of that parameter is to pass it back later in the callback. However, the method will never dereference the receiver pointer, and thus it is safe to pass in a receiver that does not survive longer than the lifetime of the function call, as long as the callback checks for validity of the receiver before using it.
-
PntosManagedMemory *memory