Typed data storage, queries, field access and scheduled callbacks.
| Include: | #include <dmsdk/datastore/datastore.h> |
| TYPES | |
|---|---|
| DataStoreFieldId | Bound query field identifier |
| DataStoreId | Row or group identifier |
| DataStoreSystemProcess | Process a query range |
| HDataStoreBlob | Loaded blob handle |
| HDataStoreBlobInstance | Blob instance handle |
| HDataStoreContext | Store handle |
| HDataStoreQuery | Query handle |
| CONSTANTS | |
|---|---|
| DATASTORE_CONTEXT_NAME | Engine datastore context |
| DATASTORE_EVENT_GAMEOBJECT_POST_UPDATE | After game-object updates |
| DATASTORE_EVENT_GAMEOBJECT_PRE_UPDATE | Before game-object updates |
| DATASTORE_QUERY_MAX_ITEMS | Maximum items in a query descriptor |
| DATASTORE_SYSTEM_MAX_DEPENDENCIES | Maximum function or event dependencies |
| ENUMS | |
|---|---|
| DataStoreAccess | Query access flags |
| DataStoreQueryFlags | Query flags |
| DataStoreQueryItemKind | Query item kinds |
| DataStoreResetPolicy | Native reset history |
| DataStoreResult | Operation results |
| DataStoreValueType | Value kinds |
| STRUCTS | |
|---|---|
| struct DataStoreCreateParams | Store allocation parameters |
| struct DataStoreEventDesc | Engine event registration |
| struct DataStoreFieldArray | Native field array |
| struct DataStoreFieldDesc | Field layout |
| struct DataStoreIterator | Query iterator |
| struct DataStoreListInput | Dynamic list input |
| struct DataStoreMatrix4 | Matrix4 value |
| struct DataStoreQueryDesc | Query filter descriptor |
| struct DataStoreQueryItem | Required query tag or field |
| struct DataStoreReference | Native reference input |
| struct DataStoreRowIterator | Row iterator |
| struct DataStoreStructDesc | Inline struct layout |
| struct DataStoreStructInput | Dynamic struct input |
| struct DataStoreSystemDesc | System registration |
| struct DataStoreTableDesc | Table layout |
| struct DataStoreValueView | Borrowed value view |
| struct DataStoreVector3 | Vector3 value |
| struct DataStoreVector4 | Vector4 value |
| struct DataStoreViewIterator | Container value iterator |
DataStoreResult DataStoreBlobAdd(HDataStoreContext store, HDataStoreBlob blob, DataStoreId group, HDataStoreBlobInstance* out_instance)
Retains the resource and copies fixed row bytes into shared mutable tables. Registrations of the same loaded resource share metadata, defaults and capacity. Strings and containers retain blob offsets. The caller keeps the immutable buffer alive until all references and registrations are released. Requires a store without active query reservations.
PARAMETERS
HDataStoreContext |
store |
Destination store. |
HDataStoreBlob |
blob |
Loaded resource to retain. |
DataStoreId |
group |
Caller-provided owner ID; bookkeeping is created lazily even for an empty blob. Zero leaves the registration ungrouped. |
HDataStoreBlobInstance* |
out_instance |
Receives the registration handle on success; unchanged on error. |
RETURNS
DataStoreResult |
OK, LOCKED while query reservations are active, or INVALID_ARGUMENT if store capacity would be exceeded. Errors leave the store unchanged. |
void DataStoreBlobDestroy(HDataStoreBlob blob)
Resource pools retain a reference while any registrations remain. The last release frees the blob handle, never the caller's buffer. Does not remove any instance's rows. The caller may free the buffer after releasing this reference and removing all registrations.
PARAMETERS
HDataStoreBlob |
blob |
Reference to release; must not be used afterward. |
DataStoreResult DataStoreBlobLoad(const void* buffer, uint32_t buffer_size, HDataStoreBlob* out_blob)
Validates all tables and borrows the supplied buffer without copying or modifying it. The input must be eight-byte aligned. Member offsets and row/struct sizes are validated for C-compatible alignment. The caller keeps the buffer unchanged and alive until the blob reference and all its registrations have been released. Loading does not register rows in a store.
PARAMETERS
const void* |
buffer |
Caller-owned complete packed component-data blob. |
uint32_t |
buffer_size |
Blob byte size. |
HDataStoreBlob* |
out_blob |
Receives a caller-owned reference on success; unchanged on error. |
RETURNS
DataStoreResult |
OK or INVALID_FORMAT for malformed/unsupported data or an unaligned buffer. |
DataStoreResult DataStoreBlobRemove(HDataStoreBlobInstance instance)
Removes its remaining rows, invalidates their IDs, frees its replacement payloads, and returns the registration slot for reuse. Shared capacity remains while other registrations use that resource; the last removal frees the pool and its blob reference. DataStoreGroupRemove also releases registrations owned by that group. Their handles must not be used afterward. The store releases all registrations when destroyed.
PARAMETERS
HDataStoreBlobInstance |
instance |
Registration to remove; must not be used after success. |
RETURNS
DataStoreResult |
OK, or LOCKED while its store has active query reservations (no changes). |
DataStoreResult DataStoreBlobReset(HDataStoreBlobInstance instance)
Copies loaded values into this registration's remaining mutable rows and frees its replacement payload blocks. Does not restore removed rows or invalidate iterators. Borrowed replacement payloads expire. Other registrations are unaffected, even if they share a blob, type or group ID. The engine retains this handle when registering a game object's component tables; no datastore-wide group search is needed. Independently added rows are not included.
PARAMETERS
HDataStoreBlobInstance |
instance |
Registration to reset. |
RETURNS
DataStoreResult |
OK, or LOCKED during query reservations. |
HDataStoreContext DataStoreCreate(const DataStoreCreateParams* params)
The caller owns the store and releases it with DataStoreDestroy.
PARAMETERS
const DataStoreCreateParams* |
params |
Allocation settings; zero uses defaults. Copied during creation. |
RETURNS
HDataStoreContext |
New store, or zero for invalid allocation sizes or when linked with datastore_null. |
DataStoreResult DataStoreDestroy(HDataStoreContext store)
Frees the store, tables/rows and callback/event registrations. Finish callbacks and all access, end any schedule, then destroy queries. Borrowed blobs and callback contexts remain caller-owned; destruction does not invoke callbacks.
PARAMETERS
HDataStoreContext |
store |
Store owned by the caller. |
RETURNS
DataStoreResult |
OK, or LOCKED during a schedule or query reservation; leaves the store intact on failure. |
DataStoreResult DataStoreEventAdd(HDataStoreContext store, const DataStoreEventDesc* desc)
Copies the descriptor and hashes between schedules. Events have no query or callback; the caller signals them explicitly with DataStoreSchedulerEvent.
PARAMETERS
HDataStoreContext |
store |
Store receiving the registration. |
const DataStoreEventDesc* |
desc |
Event hash and prerequisite hashes. |
RETURNS
DataStoreResult |
OK, LOCKED during a schedule, ALREADY_EXISTS for a duplicate name, or INVALID_ARGUMENT for a zero name hash. |
DataStoreResult DataStoreEventRemove(HDataStoreContext store, dmhash_t name)
Removes the named event between schedules. Dependent registrations retain their hashes.
PARAMETERS
HDataStoreContext |
store |
Store containing the event. |
dmhash_t |
name |
Name hash supplied when registering the event. |
RETURNS
DataStoreResult |
OK, LOCKED during a schedule, NOT_FOUND for an unknown name, or INVALID_ARGUMENT if the name identifies a function. |
DataStoreQueryItem DataStoreField(const char* name, DataStoreValueType type, uint32_t access)
Hashes the name immediately; the returned descriptor does not retain the string.
PARAMETERS
const char* |
name |
NUL-terminated full name, such as "light.color". |
DataStoreValueType |
type |
Required value kind. |
uint32_t |
access |
Zero for shared reads, or DATASTORE_FIELD_MUTABLE for read/write access. |
RETURNS
DataStoreQueryItem |
Field item for query creation or binding. |
DataStoreResult DataStoreFieldGetBoolean(HDataStoreContext store, DataStoreId id, uint64_t field, uint8_t* out_value)
Uses the ID-read synchronization requirements of DataStoreFieldGetNumber.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
uint8_t* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetBooleanBatch(HDataStoreContext store, uint32_t count, const DataStoreId* ids, uint64_t field, uint8_t* out_values)
Reads IDs in input order without allocation. Stops at the first error; outputs may be partially written on failure; use them only after OK. Synchronize as for DataStoreFieldGetBoolean. Input/output arrays must not overlap and must contain count entries. Zero count accesses nothing.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
uint32_t |
count |
Number of IDs and output values. |
const DataStoreId* |
ids |
Row IDs in requested order; duplicates are allowed. |
uint64_t |
field |
Shared field name hash. |
uint8_t* |
out_values |
Receives the values on success. |
RETURNS
DataStoreResult |
OK (including zero count), or the first NOT_FOUND for an absent row/field or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetFloat(HDataStoreContext store, DataStoreId id, uint64_t field, float* out_value)
Uses the ID-read synchronization requirements of DataStoreFieldGetNumber.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
float* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetFloatBatch(HDataStoreContext store, uint32_t count, const DataStoreId* ids, uint64_t field, float* out_values)
Reads IDs in input order without allocation. Stops at the first error; outputs may be partially written on failure; use them only after OK. Synchronize as for DataStoreFieldGetFloat. Input/output arrays must not overlap and must contain count entries. Zero count accesses nothing.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
uint32_t |
count |
Number of IDs and output values. |
const DataStoreId* |
ids |
Row IDs in requested order; duplicates are allowed. |
uint64_t |
field |
Shared field name hash. |
float* |
out_values |
Receives the values on success. |
RETURNS
DataStoreResult |
OK (including zero count), or the first NOT_FOUND for an absent row/field or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetMatrix4(HDataStoreContext store, DataStoreId id, uint64_t field, DataStoreMatrix4* out_value)
Uses the ID-read synchronization requirements of DataStoreFieldGetNumber.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
DataStoreMatrix4* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetMatrix4Batch(HDataStoreContext store, uint32_t count, const DataStoreId* ids, uint64_t field, DataStoreMatrix4* out_values)
Reads IDs in input order without allocation. Stops at the first error; outputs may be partially written on failure; use them only after OK. Synchronize as for DataStoreFieldGetMatrix4. Input/output arrays must not overlap and must contain count entries. Zero count accesses nothing.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
uint32_t |
count |
Number of IDs and output values. |
const DataStoreId* |
ids |
Row IDs in requested order; duplicates are allowed. |
uint64_t |
field |
Shared field name hash. |
DataStoreMatrix4* |
out_values |
Receives the values on success. |
RETURNS
DataStoreResult |
OK (including zero count), or the first NOT_FOUND for an absent row/field or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetNumber(HDataStoreContext store, DataStoreId id, uint64_t field, double* out_value)
ID-based reads acquire no lock or query reservation. Prevent structural changes and conflicting writes with a matching query reservation or caller synchronization. Keep that protection while using borrowed strings or views.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
double* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetNumberBatch(HDataStoreContext store, uint32_t count, const DataStoreId* ids, uint64_t field, double* out_values)
Reads IDs in input order without allocation. Stops at the first error; outputs may be partially written on failure; use them only after OK. Synchronize as for DataStoreFieldGetNumber. Input/output arrays must not overlap and must contain count entries. Zero count accesses nothing.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
uint32_t |
count |
Number of IDs and output values. |
const DataStoreId* |
ids |
Row IDs in requested order; duplicates are allowed. |
uint64_t |
field |
Shared field name hash. |
double* |
out_values |
Receives the values on success. |
RETURNS
DataStoreResult |
OK (including zero count), or the first NOT_FOUND for an absent row/field or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetString(HDataStoreContext store, DataStoreId id, uint64_t field, const char** out_value)
Uses the ID-read synchronization requirements of DataStoreFieldGetNumber.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
const char** |
out_value |
Borrowed string; copy before a store write, reset or iterator step. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetStringBatch(HDataStoreContext store, uint32_t count, const DataStoreId* ids, uint64_t field, const char** out_values)
Reads IDs in input order without allocation. Stops at the first error; outputs may be partially written on failure; use them only after OK. Synchronize as for DataStoreFieldGetString. Input/output arrays must not overlap and must contain count entries. Zero count accesses nothing. Returned strings are borrowed; finish using them before a store write or reset.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
uint32_t |
count |
Number of IDs and output values. |
const DataStoreId* |
ids |
Row IDs in requested order; duplicates are allowed. |
uint64_t |
field |
Shared field name hash. |
const char** |
out_values |
Receives the values on success. |
RETURNS
DataStoreResult |
OK (including zero count), or the first NOT_FOUND for an absent row/field or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetUInt32(HDataStoreContext store, DataStoreId id, uint64_t field, uint32_t* out_value)
Uses the ID-read synchronization requirements of DataStoreFieldGetNumber.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
uint32_t* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetUInt32Batch(HDataStoreContext store, uint32_t count, const DataStoreId* ids, uint64_t field, uint32_t* out_values)
Reads IDs in input order without allocation. Stops at the first error; outputs may be partially written on failure; use them only after OK. Synchronize as for DataStoreFieldGetUInt32. Input/output arrays must not overlap and must contain count entries. Zero count accesses nothing.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
uint32_t |
count |
Number of IDs and output values. |
const DataStoreId* |
ids |
Row IDs in requested order; duplicates are allowed. |
uint64_t |
field |
Shared field name hash. |
uint32_t* |
out_values |
Receives the values on success. |
RETURNS
DataStoreResult |
OK (including zero count), or the first NOT_FOUND for an absent row/field or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetVector3(HDataStoreContext store, DataStoreId id, uint64_t field, DataStoreVector3* out_value)
Uses the ID-read synchronization requirements of DataStoreFieldGetNumber.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
DataStoreVector3* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetVector3Batch(HDataStoreContext store, uint32_t count, const DataStoreId* ids, uint64_t field, DataStoreVector3* out_values)
Reads IDs in input order without allocation. Stops at the first error; outputs may be partially written on failure; use them only after OK. Synchronize as for DataStoreFieldGetVector3. Input/output arrays must not overlap and must contain count entries. Zero count accesses nothing.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
uint32_t |
count |
Number of IDs and output values. |
const DataStoreId* |
ids |
Row IDs in requested order; duplicates are allowed. |
uint64_t |
field |
Shared field name hash. |
DataStoreVector3* |
out_values |
Receives the values on success. |
RETURNS
DataStoreResult |
OK (including zero count), or the first NOT_FOUND for an absent row/field or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetVector4(HDataStoreContext store, DataStoreId id, uint64_t field, DataStoreVector4* out_value)
Uses the ID-read synchronization requirements of DataStoreFieldGetNumber.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
DataStoreVector4* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetVector4Batch(HDataStoreContext store, uint32_t count, const DataStoreId* ids, uint64_t field, DataStoreVector4* out_values)
Reads IDs in input order without allocation. Stops at the first error; outputs may be partially written on failure; use them only after OK. Synchronize as for DataStoreFieldGetVector4. Input/output arrays must not overlap and must contain count entries. Zero count accesses nothing.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
uint32_t |
count |
Number of IDs and output values. |
const DataStoreId* |
ids |
Row IDs in requested order; duplicates are allowed. |
uint64_t |
field |
Shared field name hash. |
DataStoreVector4* |
out_values |
Receives the values on success. |
RETURNS
DataStoreResult |
OK (including zero count), or the first NOT_FOUND for an absent row/field or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreFieldGetView(HDataStoreContext store, DataStoreId id, uint64_t field, DataStoreValueView* out_view)
Uses the ID-read synchronization requirements of DataStoreFieldGetNumber.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Full field-name hash. |
DataStoreValueView* |
out_view |
Receives a borrowed view on success. |
RETURNS
DataStoreResult |
OK, or NOT_FOUND for an absent row/field. |
DataStoreResult DataStoreFieldSetBoolean(HDataStoreContext store, DataStoreId id, uint64_t field, uint8_t value)
Write a Boolean field
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
uint8_t |
value |
Zero or one. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, INVALID_ARGUMENT for an invalid value/kind, or LOCKED during query reservations. |
DataStoreResult DataStoreFieldSetFloat(HDataStoreContext store, DataStoreId id, uint64_t field, float value)
Write a Float field
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
float |
value |
Replacement value. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, INVALID_ARGUMENT for an invalid value/kind, or LOCKED during query reservations. |
DataStoreResult DataStoreFieldSetMatrix4(HDataStoreContext store, DataStoreId id, uint64_t field, const DataStoreMatrix4* value)
Write a Matrix4 field
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
const DataStoreMatrix4* |
value |
Value to copy; pointer not retained. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, INVALID_ARGUMENT for an invalid value/kind, or LOCKED during query reservations. |
DataStoreResult DataStoreFieldSetNumber(HDataStoreContext store, DataStoreId id, uint64_t field, double value)
Write a Number field
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
double |
value |
Replacement value. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, INVALID_ARGUMENT for an invalid value/kind, or LOCKED during query reservations. |
DataStoreResult DataStoreFieldSetString(HDataStoreContext store, DataStoreId id, uint64_t field, const char* value)
Copies the NUL-terminated string into owned storage; self-assignment is supported.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
const char* |
value |
Value to copy; pointer not retained. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, INVALID_ARGUMENT for an invalid value/kind, or LOCKED during query reservations. |
DataStoreResult DataStoreFieldSetUInt32(HDataStoreContext store, DataStoreId id, uint64_t field, uint32_t value)
Write a UInt32 field
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
uint32_t |
value |
Replacement value. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, INVALID_ARGUMENT for an invalid value/kind, or LOCKED during query reservations. |
DataStoreResult DataStoreFieldSetVector3(HDataStoreContext store, DataStoreId id, uint64_t field, const DataStoreVector3* value)
Write a Vector3 field
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
const DataStoreVector3* |
value |
Value to copy; pointer not retained. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, INVALID_ARGUMENT for an invalid value/kind, or LOCKED during query reservations. |
DataStoreResult DataStoreFieldSetVector4(HDataStoreContext store, DataStoreId id, uint64_t field, const DataStoreVector4* value)
Write a Vector4 field
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
Row ID. |
uint64_t |
field |
Field name hash. |
const DataStoreVector4* |
value |
Value to copy; pointer not retained. |
RETURNS
DataStoreResult |
OK, NOT_FOUND for an absent row/field, INVALID_ARGUMENT for an invalid value/kind, or LOCKED during query reservations. |
DataStoreResult DataStoreFunctionAdd(HDataStoreContext store, const DataStoreSystemDesc* desc)
Copies the descriptor and hashes; registration does not invoke the callback.
PARAMETERS
HDataStoreContext |
store |
Store receiving the registration. |
const DataStoreSystemDesc* |
desc |
Callback, query, context and dependency hashes. |
RETURNS
DataStoreResult |
OK, LOCKED during a schedule, ALREADY_EXISTS for a duplicate name, or INVALID_ARGUMENT for missing required values, a zero name hash or a query from another store. |
DataStoreResult DataStoreFunctionRemove(HDataStoreContext store, dmhash_t name)
Removes the named registration between schedules. The query and user context remain caller-owned. Dependent registrations retain their hashes.
PARAMETERS
HDataStoreContext |
store |
Store containing the registration. |
dmhash_t |
name |
Name hash supplied when registering the callback. |
RETURNS
DataStoreResult |
OK, LOCKED during a schedule, NOT_FOUND for an unknown name, or INVALID_ARGUMENT if the name identifies an event. |
DataStoreResult DataStoreGroupRemove(HDataStoreContext store, DataStoreId group)
Removes the group's rows across all tables, owned payloads and blob registrations, including empty registrations. Invalidates their row IDs and blob-instance handles and releases group bookkeeping. Other groups and their row IDs remain valid. Independent table registrations remain available for reuse. Does not scan unrelated rows. Requires a store without active query reservations; queue requests in caller-owned storage and apply them after jobs finish. Zero is not a removable group. Bookkeeping is created on first use and kept until group removal, including when rows are removed individually. Reusing the caller ID later recreates the group; existing query filters then match its new rows.
PARAMETERS
HDataStoreContext |
store |
Store owning the group. |
DataStoreId |
group |
Caller-provided owner ID. |
RETURNS
DataStoreResult |
OK, LOCKED during query reservations, or NOT_FOUND for zero or an unknown group. Failure leaves the store unchanged. |
uint64_t DataStoreIterGetType(const DataStoreIterator* iterator)
Get the current table type
PARAMETERS
const DataStoreIterator* |
iterator |
Batch iterator. |
RETURNS
uint64_t |
Table type hash, or zero without a valid current batch. Zero may also be a valid type hash. |
bool DataStoreIterNext(DataStoreIterator* iterator)
Selects a nonempty contiguous batch. Invalidates child iterators, including when exhausted.
PARAMETERS
DataStoreIterator* |
iterator |
Iterator to advance. |
RETURNS
bool |
True for a new batch, or false when exhausted. |
DataStoreRowIterator DataStoreIterRows(const DataStoreIterator* iterator)
Borrows the current batch; empty when no batch is selected.
PARAMETERS
const DataStoreIterator* |
iterator |
Parent query iterator to borrow. |
RETURNS
DataStoreRowIterator |
Iterator with no current row; advance using DataStoreRowIterNext. |
DataStoreResult DataStoreQueryCreate(HDataStoreContext store, const DataStoreQueryDesc* desc, HDataStoreQuery* out_query)
Copies filters and tracks matching tables, including later registrations. Destroy the query before its store.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
const DataStoreQueryDesc* |
desc |
Filters to copy. |
HDataStoreQuery* |
out_query |
Receives the owned query on success. |
RETURNS
DataStoreResult |
OK, INVALID_ARGUMENT for invalid items/access or excessive group count, or LOCKED during query reservations. |
DataStoreResult DataStoreQueryDestroy(HDataStoreQuery query)
Frees the query. Finish using its iterators first.
PARAMETERS
HDataStoreQuery |
query |
Query whose store is still alive. |
RETURNS
DataStoreResult |
OK, or LOCKED while query reservations are active or this query is registered in an active schedule. |
void DataStoreQueryEnd(HDataStoreQuery query)
Thread-safe release. The caller must join all jobs and finish using iterators and pointers first.
PARAMETERS
HDataStoreQuery |
query |
Query with a successful begin to release once. |
DataStoreFieldId DataStoreQueryFindField(HDataStoreQuery query, const DataStoreQueryItem* field)
Binds a requested full-name hash, kind and access to a handle valid until query destruction. The handle is neither a byte offset nor a query descriptor index. No lock or matching rows are required. Fixed-size kinds support typed pointers; DataStoreRowIterGetView also reads containers, strings and nulls. Table and row iteration order is unspecified. Pointer getters require this query's current row and matching typed handle, with its reservation active. No kind, bounds or lifetime checks occur. Writable pointers require DATASTORE_FIELD_MUTABLE during reservations. Borrowed pointers expire on row/batch advance, query end, or another mutating accessor/reset for the row/table. Never write through a read pointer.
PARAMETERS
HDataStoreQuery |
query |
Query to bind. |
const DataStoreQueryItem* |
field |
Field item to match; borrowed for this call. Access must not exceed the query declaration. |
RETURNS
DataStoreFieldId |
Field handle, or UINT32_MAX for a non-field item or an absent, incompatible or unsupported field. |
uint32_t DataStoreQueryGetRowCount(HDataStoreQuery query)
Count reserved rows
PARAMETERS
HDataStoreQuery |
query |
Query with an active reservation. |
RETURNS
uint32_t |
Reserved matching row count. |
DataStoreIterator DataStoreQueryIter(HDataStoreQuery query)
Traverses all rows in an active query reservation. The scheduler keeps access reserved until every iterator and job finishes, including early exits.
PARAMETERS
HDataStoreQuery |
query |
Query reserved for traversal. |
RETURNS
DataStoreIterator |
Iterator with no current batch; advance using DataStoreIterNext. |
DataStoreIterator DataStoreQueryIterRange(HDataStoreQuery query, uint32_t first, uint32_t count)
Selects [first, first + count) within reserved rows, possibly across tables. Each job owns its cursor; ranges must be in bounds and disjoint when writing. Keep the reservation active until all iterators and borrowed pointers finish.
PARAMETERS
HDataStoreQuery |
query |
Query reserved for these jobs. |
uint32_t |
first |
Index in the reserved matching rows. |
uint32_t |
count |
Row count; zero is allowed. |
RETURNS
DataStoreIterator |
Cursor to advance with DataStoreIterNext. |
DataStoreResult DataStoreQueryTryBegin(HDataStoreQuery query)
Thread-safe, nonblocking reservation that keeps rows and bindings stable. Overlapping fields on the same table allow read/read access; writes conflict. Disjoint group filters permit concurrent writes to the same table. Aliased external views remain conservative. Without fields or whole-row flags, only row identities are read. DATASTORE_ROW_MUTABLE conflicts with any reader or writer of overlapping row values. Field filters still select matching tables. Field writes require DATASTORE_FIELD_MUTABLE, or DATASTORE_ROW_MUTABLE for native row access; string replacement and resets must happen outside reservations. Each query supports one active reservation, shared by its jobs. The caller schedules and synchronizes jobs, then calls DataStoreQueryEnd once, even for an empty query. The scheduler owns this scope for both serial and parallel iteration. Do not bypass reservations with unrelated ID-based access. Matching-table changes invalidate cached compatibility; row changes refresh ranges. First use of a query pair or changed ranges may allocate; later begins reuse storage.
PARAMETERS
HDataStoreQuery |
query |
Query to reserve. |
RETURNS
DataStoreResult |
OK, or BUSY without acquiring access if already active or unavailable. |
DataStoreResult DataStoreRowCreate(HDataStoreContext store, uint64_t type, DataStoreId group, uint32_t count, const void* rows, DataStoreId* out_ids)
Copies count complete rows using the registered C layout and row size. Assigns group to every row; groups can share a table. DataStoreGroupRemove removes owned rows. Stores current values only unless m_ResetPolicy is DATASTORE_RESET_RETAIN. Native rows have no component name; DataStoreRowGetComponentId returns zero. Supports fixed-size values, inline structs and DataStoreReference fields. Strings and dynamic containers are copied into table-owned storage, including nested payloads; all input memory can be released after the call. Dynamic struct fields share layout metadata and own separate child rows. Removal releases those rows for reuse; reset releases replacements and restores the original children. Removed rows' default slots and string/list payload chunks are reused. Empty payload blocks are released, keeping at most one small spare per arena. Booleans must be 0 or 1. Inputs, including padding, must be initialized, disjoint from store storage and valid through the call. On error no rows are published and output IDs remain unchanged. Nonempty batches require a store without active query reservations. An empty batch returns OK without accessing the store or arrays.
PARAMETERS
HDataStoreContext |
store |
Destination store. |
uint64_t |
type |
Registered table type. |
DataStoreId |
group |
Caller-provided owner ID; bookkeeping is created lazily. Zero creates ungrouped rows. |
uint32_t |
count |
Rows to add; zero adds nothing. |
const void* |
rows |
Borrowed contiguous native rows; NULL for zero-size rows or an empty batch. |
DataStoreId* |
out_ids |
Optional array receiving count stable IDs on success; NULL skips the output. IDs remain available through row iteration. |
RETURNS
DataStoreResult |
OK, LOCKED, NOT_FOUND for an unknown type, ALREADY_EXISTS for duplicate dynamic member names, or INVALID_ARGUMENT for incompatible input or capacity limits. |
DataStoreResult DataStoreRowCreateSoA(HDataStoreContext store, uint64_t type, DataStoreId group, uint32_t count, uint32_t field_count, const DataStoreFieldArray* fields, DataStoreId* out_ids)
Supply every root field exactly once, in any order, with count values per array. Copies into the selected runtime storage and retains native reset rows only when m_ResetPolicy is DATASTORE_RESET_RETAIN. Types and element sizes come from the registered layout. Inline struct fields use arrays of complete structs, not separate arrays for their nested members. Inputs, including struct padding, must be initialized, disjoint from store storage and valid through the call. The table policy controls reset history. Group, locking and reference ownership rules match DataStoreRowCreate. On error no rows are published and output IDs remain unchanged.
PARAMETERS
HDataStoreContext |
store |
Destination store. |
uint64_t |
type |
Registered table type. |
DataStoreId |
group |
Caller-provided owner ID; bookkeeping is created lazily. Zero creates ungrouped rows. |
uint32_t |
count |
Rows to add; zero returns OK without accessing the store or arrays. |
uint32_t |
field_count |
Number of root field arrays. |
const DataStoreFieldArray* |
fields |
Borrowed field arrays; NULL for a table without fields or an empty batch. |
DataStoreId* |
out_ids |
Optional array receiving count stable IDs on success; NULL skips the output. IDs remain available through row iteration. |
RETURNS
DataStoreResult |
OK, LOCKED, NOT_FOUND for an unknown table, ALREADY_EXISTS for duplicate dynamic member names, or INVALID_ARGUMENT for invalid fields, input or capacity limits. |
uint64_t DataStoreRowGetComponentId(HDataStoreContext store, DataStoreId id)
Used by game object integration to associate a runtime row with its component. Uses the ID-read synchronization requirements of DataStoreFieldGetNumber.
PARAMETERS
HDataStoreContext |
store |
Store containing the row. |
DataStoreId |
id |
Runtime row ID. |
RETURNS
uint64_t |
Component name hash, or zero for an invalid/stale row. Zero may also identify an unnamed row. |
const uint8_t* DataStoreRowIterGetBoolean(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Boolean handle from DataStoreQueryFindField. |
RETURNS
const uint8_t* |
Borrowed read-only value. |
uint8_t* DataStoreRowIterGetBooleanMut(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField. Write only zero or one.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Boolean handle from DataStoreQueryFindField. |
RETURNS
uint8_t* |
Borrowed writable value. |
const void* DataStoreRowIterGetData(const DataStoreRowIterator* iterator)
Requires a nonzero row stride. Cast only to the registered C layout, including its member offsets and size. Use DataStoreIterGetType to distinguish layouts in queries matching multiple types. Returns zero unless the query flags include DATASTORE_ROW_MUTABLE. Otherwise reads any field; permissions are cached in the iterator. Reference slots are internal handles, not native pointers; use container accessors for them. The pointer follows DataStoreIterator lifetime rules. No layout checks occur.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
RETURNS
const void* |
Borrowed read-only row start, or zero without whole-row access. |
void* DataStoreRowIterGetDataMut(const DataStoreRowIterator* iterator)
Uses the layout and lifetime rules of DataStoreRowIterGetData. Returns zero unless the query flags include DATASTORE_ROW_MUTABLE, which reserves reads and writes of the entire row. Never overwrite reference slots or whole rows containing references. Boolean writes must be zero or one. The access flag is cached in the iterator; this getter does not access the query or store.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
RETURNS
void* |
Borrowed row start for fixed-size field writes, or zero without DATASTORE_ROW_MUTABLE. |
const float* DataStoreRowIterGetFloat(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Float handle from DataStoreQueryFindField. |
RETURNS
const float* |
Borrowed read-only value. |
float* DataStoreRowIterGetFloatMut(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Float handle from DataStoreQueryFindField. |
RETURNS
float* |
Borrowed writable value. |
DataStoreId DataStoreRowIterGetGroupId(const DataStoreRowIterator* iterator)
Get the current row group
PARAMETERS
const DataStoreRowIterator* |
iterator |
Row iterator. |
RETURNS
DataStoreId |
Caller-provided owner ID, or zero for an ungrouped row or without a valid row. |
DataStoreId DataStoreRowIterGetId(const DataStoreRowIterator* iterator)
Get the current row ID
PARAMETERS
const DataStoreRowIterator* |
iterator |
Row iterator. |
RETURNS
DataStoreId |
Store-local row ID, or zero without a valid current row. |
const DataStoreMatrix4* DataStoreRowIterGetMatrix4(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Matrix4 handle from DataStoreQueryFindField. |
RETURNS
const DataStoreMatrix4* |
Borrowed read-only value. |
DataStoreMatrix4* DataStoreRowIterGetMatrix4Mut(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Matrix4 handle from DataStoreQueryFindField. |
RETURNS
DataStoreMatrix4* |
Borrowed writable value. |
const double* DataStoreRowIterGetNumber(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Number handle from DataStoreQueryFindField. |
RETURNS
const double* |
Borrowed read-only value. |
double* DataStoreRowIterGetNumberMut(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Number handle from DataStoreQueryFindField. |
RETURNS
double* |
Borrowed writable value. |
const uint32_t* DataStoreRowIterGetUInt32(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
UInt32 handle from DataStoreQueryFindField. |
RETURNS
const uint32_t* |
Borrowed read-only value. |
uint32_t* DataStoreRowIterGetUInt32Mut(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
UInt32 handle from DataStoreQueryFindField. |
RETURNS
uint32_t* |
Borrowed writable value. |
const DataStoreVector3* DataStoreRowIterGetVector3(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Vector3 handle from DataStoreQueryFindField. |
RETURNS
const DataStoreVector3* |
Borrowed read-only value. |
DataStoreVector3* DataStoreRowIterGetVector3Mut(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Vector3 handle from DataStoreQueryFindField. |
RETURNS
DataStoreVector3* |
Borrowed writable value. |
const DataStoreVector4* DataStoreRowIterGetVector4(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Vector4 handle from DataStoreQueryFindField. |
RETURNS
const DataStoreVector4* |
Borrowed read-only value. |
DataStoreVector4* DataStoreRowIterGetVector4Mut(const DataStoreRowIterator* iterator, DataStoreFieldId field)
Uses the handle and pointer lifetime rules of DataStoreQueryFindField.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Iterator on the current row. |
DataStoreFieldId |
field |
Vector4 handle from DataStoreQueryFindField. |
RETURNS
DataStoreVector4* |
Borrowed writable value. |
void DataStoreRowIterGetView(const DataStoreRowIterator* iterator, DataStoreFieldId field, DataStoreValueView* out_view)
Uses the same valid-row and matching-handle contract as typed pointer getters. Containers and strings require read-only access. No name lookup or allocation.
PARAMETERS
const DataStoreRowIterator* |
iterator |
Current row of a reserved query. |
DataStoreFieldId |
field |
Handle returned by DataStoreQueryFindField. |
DataStoreValueView* |
out_view |
Receives a borrowed view. |
bool DataStoreRowIterNext(DataStoreRowIterator* iterator)
Invalidates borrowed field pointers; clears the current row when exhausted.
PARAMETERS
DataStoreRowIterator* |
iterator |
Row iterator. |
RETURNS
bool |
True for a new row, or false when exhausted. |
DataStoreResult DataStoreRowRemove(HDataStoreContext store, DataStoreId id)
Uses swap removal; other live IDs remain valid. The removed ID becomes stale. Requires a store without active query reservations. To remove during traversal, collect DataStoreIds in a caller-owned reusable buffer and apply removals after all query reservations finish. Reclaims the retained default slot and owned dynamic child rows. String/list payload chunks are recycled; empty blocks are freed, retaining one small spare per arena. Borrowed blob payloads remain unchanged.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
DataStoreId |
id |
ID of the row to remove. |
RETURNS
DataStoreResult |
LOCKED while query reservations are active; otherwise OK on success, NOT_FOUND for an invalid or stale ID, or INVALID_ARGUMENT for a borrowed view. |
DataStoreResult DataStoreRowReset(HDataStoreContext store, DataStoreId id)
Restores all fields, including nested values, to their loaded or added defaults. Other rows are unaffected, including other components with the same group or type. Does not allocate, change IDs or query membership, or invalidate iterators. Mutable row storage stays in place. Owned replacement payloads are released for reuse; borrowed views and strings must no longer be used. Returns LOCKED during query reservations. Tables registered with DATASTORE_RESET_NONE do not retain history and cannot reset.
PARAMETERS
HDataStoreContext |
store |
Store containing the component row. |
DataStoreId |
id |
Component's runtime row ID. |
RETURNS
DataStoreResult |
OK, LOCKED during query reservations, NOT_FOUND for an invalid or stale ID, or INVALID_ARGUMENT for a borrowed view or a table with DATASTORE_RESET_NONE. |
DataStoreResult DataStoreSchedulerBegin(HDataStoreContext store, HJobContext jobs)
Starts one invocation of all registered functions and events. Resolves dependencies after registration changes and clears function completion and event signals from the previous invocation. Reserves each ready function's query and submits its jobs. Borrowed job context must outlive this invocation. Zero-worker contexts execute work during DataStoreSchedulerUpdate. Pair success with DataStoreSchedulerEnd; no threads are created or destroyed here.
PARAMETERS
HDataStoreContext |
store |
Store containing the registrations. |
HJobContext |
jobs |
Caller-owned job context. Pump it on the same main thread as scheduler operations. |
RETURNS
DataStoreResult |
OK, LOCKED if already active, NOT_FOUND for a missing prerequisite, or INVALID_ARGUMENT for a null job context or dependency cycle. Failure leaves the schedule inactive except when already active. |
DataStoreResult DataStoreSchedulerEnd(HDataStoreContext store)
Ends the invocation, discarding unsignaled events and functions waiting on them. Returns BUSY while jobs await completion or ready functions await query access; keep pumping DataStoreSchedulerUpdate before retrying. A failed end retains reservations and dependencies. Registration changes are allowed after success. The next begin starts fresh.
PARAMETERS
HDataStoreContext |
store |
Store with an active schedule. |
RETURNS
DataStoreResult |
OK, BUSY while functions are running or ready to run, or INVALID_ARGUMENT without an active schedule. |
DataStoreResult DataStoreSchedulerEvent(HDataStoreContext store, dmhash_t name)
Signals an engine milestone, such as the start of an update stage, once its own prerequisites are satisfied. The scheduler immediately submits every ready function, subject to remaining dependencies and query access checks. This call does not wait for jobs. BUSY leaves the event pending: pump DataStoreSchedulerUpdate and retry before entering an engine stage that requires those prerequisites. Signal each event once per invocation; DataStoreSchedulerBegin clears previous signals. Events do not reserve data or protect engine accesses outside registered queries.
PARAMETERS
HDataStoreContext |
store |
Store with an active schedule. |
dmhash_t |
name |
Registered event hash. |
RETURNS
DataStoreResult |
OK, BUSY while prerequisites are incomplete, NOT_FOUND for an unknown name, or INVALID_ARGUMENT without an active schedule, for a function name or for an already signaled event. |
DataStoreResult DataStoreSchedulerSync(HDataStoreContext store)
Pumps jobs until running functions and ready functions finish, including their dependents. Functions waiting on unsignaled events remain pending. Keeps the schedule active so later events can use earlier completions without rerunning work. Query reservations are released as functions finish; this does not lock the store. Call on the scheduler's main thread, outside jobs and completion callbacks.
PARAMETERS
HDataStoreContext |
store |
Store with an active schedule. |
RETURNS
DataStoreResult |
OK after ready work finishes, or INVALID_ARGUMENT without an active schedule. |
DataStoreResult DataStoreSchedulerUpdate(HDataStoreContext store)
Pumps the borrowed job context's completion callbacks on the main thread. In a zero-worker context, also executes at most one queued job. This may service other users of the same job context. Do not call recursively from a job or completion callback. The last job of each function releases query access and submits newly ready functions. Also retries functions blocked by external query reservations. Read/read and disjoint writes may overlap; conflicting accesses wait. Use m_DependsOn when order matters. The same query handle cannot have two active reservations. Unsignaled events do not keep this call BUSY unless a pending function depends on them.
PARAMETERS
HDataStoreContext |
store |
Store with an active schedule. |
RETURNS
DataStoreResult |
OK when all functions finished, BUSY while functions await jobs, events or reservations, or INVALID_ARGUMENT without an active schedule. |
DataStoreResult DataStoreTableAdd(HDataStoreContext store, const DataStoreTableDesc* desc)
Copies tags and field metadata. Fields have fixed kinds and non-overlapping byte offsets. Duplicate type hashes and full-name field hashes (including inline members) are rejected. Successful registration updates live queries. Requires a store without active query reservations.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
const DataStoreTableDesc* |
desc |
Table type, tags and shared field layout to copy. |
RETURNS
DataStoreResult |
LOCKED while query reservations are active; otherwise OK, ALREADY_EXISTS for a duplicate type/field name, or INVALID_ARGUMENT for invalid tags/count/layout. |
DataStoreResult DataStoreTableAddView(HDataStoreContext store, const DataStoreTableDesc* desc, void* values, uint32_t value_count, uint32_t row_count, const uint32_t* indices, DataStoreId* out_ids)
Creates a runtime table over caller-owned AoS values without copying them. Layouts contain scalar/vector/matrix fields; struct and reference fields are unsupported. Indices select source rows and are copied; NULL selects rows in order. Optional out_ids receives row identities. Keep values alive, aligned and stationary until DataStoreTableRemove or store destruction. The caller synchronizes external access with query reservations. Shared reads are allowed; writable jobs must select distinct source rows, including within one query. Views with overlapping source rows conflict on overlapping writable fields. View rows cannot be created, removed or reset individually, or serialized. Unregistering frees metadata and identities, never the borrowed values.
PARAMETERS
HDataStoreContext |
store |
Destination store. |
const DataStoreTableDesc* |
desc |
Native layout and tags; copied. |
void* |
values |
Borrowed native row array. |
uint32_t |
value_count |
Accessible source rows. |
uint32_t |
row_count |
Selected rows. |
const uint32_t* |
indices |
Optional source indices, each below value_count. |
DataStoreId* |
out_ids |
Optional row_count output identities. |
RETURNS
DataStoreResult |
OK, LOCKED, ALREADY_EXISTS or INVALID_ARGUMENT. |
DataStoreResult DataStoreTableRemove(HDataStoreContext store, uint64_t type)
Removes an independently registered table and all its rows. Their IDs become stale, even if the type is registered again. Updates live queries. Requires a store without active query reservations.
PARAMETERS
HDataStoreContext |
store |
Store handle. |
uint64_t |
type |
Table type hash. |
RETURNS
DataStoreResult |
LOCKED while query reservations are active; otherwise OK on success, or NOT_FOUND if the type is not registered. |
DataStoreQueryItem DataStoreTag(const char* name)
Hashes the name immediately; the returned item does not retain the string.
PARAMETERS
const char* |
name |
NUL-terminated tag name. |
RETURNS
DataStoreQueryItem |
Tag item for query creation. |
DataStoreResult DataStoreViewGetBoolean(const DataStoreValueView* view, uint8_t* out_value)
Copies the value without conversion. Errors leave the output unchanged.
PARAMETERS
const DataStoreValueView* |
view |
Valid view. |
uint8_t* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreViewGetCount(const DataStoreValueView* view, uint32_t* out_count)
Count container entries
PARAMETERS
const DataStoreValueView* |
view |
Struct or list view. |
uint32_t* |
out_count |
Receives the immediate member/element count. |
RETURNS
DataStoreResult |
OK, or INVALID_ARGUMENT for a non-container. |
DataStoreResult DataStoreViewGetElement(const DataStoreValueView* view, uint32_t index, DataStoreValueView* out_view)
Read a list element
PARAMETERS
const DataStoreValueView* |
view |
List view. |
uint32_t |
index |
Zero-based element index. |
DataStoreValueView* |
out_view |
Receives the element view; may alias view. |
RETURNS
DataStoreResult |
OK, NOT_FOUND outside the list, or INVALID_ARGUMENT for a non-list. |
DataStoreResult DataStoreViewGetField(const DataStoreValueView* view, uint64_t field, DataStoreValueView* out_view)
Uses a local member hash; repeat for further nesting. No member enumeration.
PARAMETERS
const DataStoreValueView* |
view |
Struct view, including an inline struct. |
uint64_t |
field |
Local member-name hash. |
DataStoreValueView* |
out_view |
Receives the member view; may alias view. |
RETURNS
DataStoreResult |
OK, NOT_FOUND, or INVALID_ARGUMENT for a non-struct. |
DataStoreResult DataStoreViewGetFloat(const DataStoreValueView* view, float* out_value)
Copies the value without conversion. Errors leave the output unchanged.
PARAMETERS
const DataStoreValueView* |
view |
Valid view. |
float* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreViewGetMatrix4(const DataStoreValueView* view, DataStoreMatrix4* out_value)
Copies the value without conversion. Errors leave the output unchanged.
PARAMETERS
const DataStoreValueView* |
view |
Valid view. |
DataStoreMatrix4* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreViewGetNumber(const DataStoreValueView* view, double* out_value)
Copies the value without conversion. Errors leave the output unchanged.
PARAMETERS
const DataStoreValueView* |
view |
Valid view. |
double* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreViewGetString(const DataStoreValueView* view, const char** out_value)
Borrows the NUL-terminated string until the view expires. Errors leave the output unchanged.
PARAMETERS
const DataStoreValueView* |
view |
Valid view. |
const char** |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreValueType DataStoreViewGetType(const DataStoreValueView* view)
Read a view's kind
PARAMETERS
const DataStoreValueView* |
view |
Valid view. |
RETURNS
DataStoreValueType |
Value kind, including NULL for a null element. |
DataStoreResult DataStoreViewGetUInt32(const DataStoreValueView* view, uint32_t* out_value)
Copies the value without conversion. Errors leave the output unchanged.
PARAMETERS
const DataStoreValueView* |
view |
Valid view. |
uint32_t* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreViewGetVector3(const DataStoreValueView* view, DataStoreVector3* out_value)
Copies the value without conversion. Errors leave the output unchanged.
PARAMETERS
const DataStoreValueView* |
view |
Valid view. |
DataStoreVector3* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreResult DataStoreViewGetVector4(const DataStoreValueView* view, DataStoreVector4* out_value)
Copies the value without conversion. Errors leave the output unchanged.
PARAMETERS
const DataStoreValueView* |
view |
Valid view. |
DataStoreVector4* |
out_value |
Receives the value on success. |
RETURNS
DataStoreResult |
OK, or INVALID_ARGUMENT for a kind mismatch. |
DataStoreViewIterator DataStoreViewIter(const DataStoreValueView* view)
Visits list elements in order or immediate struct values in storage order. Struct order is unspecified. Empty containers and non-container views yield no values. No allocation; count is resolved once.
PARAMETERS
const DataStoreValueView* |
view |
Parent view; keep unchanged through iteration. |
RETURNS
DataStoreViewIterator |
Iterator positioned before the first value. |
bool DataStoreViewIterNext(DataStoreViewIterator* iterator, DataStoreValueView* out_view)
Returned views use the existing typed view getters. Nested containers can have their own iterators. Exhaustion leaves the output unchanged.
PARAMETERS
DataStoreViewIterator* |
iterator |
Container iterator. |
DataStoreValueView* |
out_view |
Receives the next value; must not alias the parent view. |
RETURNS
bool |
True for a value, including NULL; false at the end. |
TYPE
struct DataStoreCreateParamsZero selects the default for each size. Pages are allocated lazily and shared by table value chunks. These are allocator sizes, independent of OS pages.
MEMBERS
uint32_t |
m_PageSize |
Backing allocation bytes; default 524288. Power of two, at least m_RowChunkSize. |
uint32_t |
m_RowChunkSize |
Target current/default value-chunk bytes; default 262144. Power of two, at least 64. Larger rows use dedicated allocations. |
uint32_t |
m_MaxSparePages |
Empty backing pages retained for reuse. Zero releases all; a null params pointer uses 16. |
TYPE
struct DataStoreEventDescAn externally signaled milestone in the same dependency graph as query callbacks. Hashes are copied. Dependencies may name functions or events registered later; DataStoreSchedulerBegin rejects missing prerequisites and cycles.
MEMBERS
dmhash_t |
m_Name |
Nonzero name hash, unique among functions and events in the store. |
dmhash_t[] |
m_DependsOn |
Prerequisite hashes that must complete before signaling succeeds. Packed from index zero; stop at the first zero or use all DATASTORE_SYSTEM_MAX_DEPENDENCIES entries. |
TYPE
struct DataStoreFieldArrayOne input column for DataStoreRowCreateSoA. The registered layout determines the element type and size; an inline struct uses complete native struct elements. STRING, dynamic STRUCT and LIST columns use DataStoreReference elements.
MEMBERS
uint64_t |
m_Field |
Root field name hash. |
const void* |
m_Values |
Borrowed contiguous native values; NULL only for a zero-size field or an empty batch. |
TYPE
struct DataStoreFieldDescOffsets follow C alignment. Inline members and their parents require single-segment names for full-name hashing. Registration copies the compiled metadata.
MEMBERS
uint64_t |
m_Field |
Local field name hash. |
DataStoreValueType |
m_Type |
Fixed field kind. |
uint32_t |
m_Offset |
Byte offset in the containing row or struct. |
const DataStoreStructDesc* |
m_Struct |
Inline STRUCT layout, otherwise NULL. |
const char* |
m_Name |
Borrowed local name; required for inline parents/members, without dots. |
TYPE
struct DataStoreIteratorStack cursor; iterators and fixed-size field access allocate nothing. Keep the query/store alive and its query reservation active. Do not copy active iterators. Parents must stay at the same address; stepping one invalidates its children, including when exhausted. Lifetimes are not checked. Batch and row order are unspecified.
TYPE
struct DataStoreListInputWith m_Types NULL, m_Type describes a contiguous native array. Numeric elements use their native API types; STRING, STRUCT and LIST elements use DataStoreReference. With m_Types set, m_Values is a const void* array of payload pointers: addresses of native scalar/vector/matrix values, string bytes, DataStoreStructInput or DataStoreListInput. NULL-kind elements need no payload. m_Type is ignored. Both arrays contain m_Count entries. Inputs are borrowed through creation; values are copied, including nested payloads. Input rules match DataStoreStructInput.
MEMBERS
DataStoreValueType |
m_Type |
Shared element kind when m_Types is NULL; otherwise ignored. |
uint32_t |
m_Count |
Number of elements. |
const void* |
m_Values |
Native array or array of payload pointers. NULL only for an empty list or a homogeneous NULL list. |
const DataStoreValueType* |
m_Types |
Optional array of per-element kinds; NULL selects homogeneous input. |
TYPE
struct DataStoreMatrix4Matrix4 value
MEMBERS
float[16] |
m_Values |
Column-major components; element at row r, column c is m_Values[c * 4 + r]. |
TYPE
struct DataStoreQueryDescRequires all tags and fields in one table, and matches any listed group. Empty filters impose no restriction. Bind requested fields with DataStoreQueryFindField. Zero-initialize. Items end at the first DATASTORE_QUERY_ITEM_NONE or the array capacity. Filters are copied during creation; group IDs use an explicit count because zero is valid.
MEMBERS
DataStoreQueryItem[DATASTORE_QUERY_MAX_ITEMS] |
m_Items |
Required tags and fields, in any order. |
const DataStoreId* |
m_GroupIds |
Caller-provided owner IDs; zero selects ungrouped rows. IDs may precede row creation. Optional when count is zero. |
uint32_t |
m_GroupIdCount |
Group count; zero matches all. |
uint32_t |
m_Flags |
DataStoreQueryFlags bits; zero keeps field-level access and disables native row pointers. |
TYPE
struct DataStoreQueryItemConstruct with DataStoreTag or DataStoreField, or initialize the kind and hash directly. Field names may include inline members, such as "light.color"; dynamic members cannot bind.
MEMBERS
uint64_t |
m_Hash |
Tag hash or full field name hash; zero is valid. |
DataStoreValueType |
m_Type |
Exact value kind for field items; ignored for tags. |
uint32_t |
m_Access |
Field access: zero for shared reads, or DATASTORE_FIELD_MUTABLE for fixed-size read/write access. Ignored for tags. |
DataStoreQueryItemKind |
m_Kind |
Tag, field, or unused item. |
TYPE
struct DataStoreReferenceUse for STRING, dynamic STRUCT and LIST fields in native rows or field arrays, including nested members. Select the union member matching the declared kind. Payloads and descriptors are borrowed through creation and copied into the table. References must be non-NULL. This is an input descriptor, not a stored pointer view; read strings through the typed API. Reference slots occupy eight bytes on all supported hosts and follow the registered C alignment rules.
MEMBERS
const char* |
m_String |
Borrowed NUL-terminated string. |
const DataStoreStructInput* |
m_Struct |
Borrowed dynamic struct. |
const DataStoreListInput* |
m_List |
Borrowed dynamic list. |
TYPE
struct DataStoreRowIteratorTraverses the current batch. DataStoreIterator lifetime rules apply. Fixed-size writes preserve sibling fields and defaults. Reset outside reservations.
TYPE
struct DataStoreStructDescReusable metadata, copied by registration. Members must not overlap. Layouts must be acyclic. Inline structs and dynamic containers share a 64-level nesting limit.
MEMBERS
const DataStoreFieldDesc* |
m_Fields |
Borrowed member descriptions. |
uint32_t |
m_FieldCount |
Number of members. |
uint32_t |
m_Size |
Native size including alignment padding. |
TYPE
struct DataStoreStructInputDescribes one native struct, with per-input member names and kinds. The table field uses STRUCT without an inline layout. Members may contain DataStoreReference values, including further containers. Inputs must be acyclic, no deeper than 64 container levels including enclosing inline structs; names within each struct must be unique.
MEMBERS
const DataStoreStructDesc* |
m_Layout |
Borrowed native member layout; required even for an empty struct. |
const void* |
m_Values |
Borrowed native struct bytes; NULL only when layout size is zero. |
TYPE
struct DataStoreSystemDescHashes are copied during registration. The query must belong to the supplied store. Keep the query and context alive until unregistration or store teardown. At teardown, finish callbacks, end the schedule and destroy queries before the store. Dependencies name complete updates and may refer to updates registered later. DataStoreSchedulerBegin resolves hashes to indices and rejects cycles. Use dmHashString64 during setup; reverse hashes are available for diagnostics. Prerequisites may name functions or events. Every prerequisite must be registered; the engine registers DATASTORE_EVENT_GAMEOBJECT_PRE_UPDATE and DATASTORE_EVENT_GAMEOBJECT_POST_UPDATE in its own store.
MEMBERS
dmhash_t |
m_Name |
Nonzero name hash, unique among functions and events in the store. |
dmhash_t[] |
m_DependsOn |
Prerequisite hashes, packed from index zero. Stop at the first zero or use all DATASTORE_SYSTEM_MAX_DEPENDENCIES entries. |
HDataStoreQuery |
m_Query |
Borrowed query. |
DataStoreSystemProcess |
m_Process |
Required processing callback. |
void* |
m_Context |
Borrowed user context passed unchanged to the callback. |
uint32_t |
m_RowsPerJob |
Maximum rows per job. Zero (default) submits one job for the complete query. Nonzero opts into concurrent calls sharing m_Context; callbacks must process only their supplied range and synchronize shared state. |
TYPE
struct DataStoreTableDescTags and metadata are copied. Tags and total metadata entries, including nested members, are each limited to 65,535. Full-name hashes must be unique across the entire layout, including inline members. Rows share this fixed layout.
MEMBERS
uint64_t |
m_Type |
Type name hash, unique among independently registered tables. |
const uint64_t* |
m_Tags |
Borrowed tag hashes. |
uint32_t |
m_TagCount |
Number of tags. |
const DataStoreFieldDesc* |
m_Fields |
Borrowed root field descriptions. |
uint32_t |
m_FieldCount |
Number of root fields. |
uint32_t |
m_RowStride |
Native row size including trailing alignment padding. |
DataStoreResetPolicy |
m_ResetPolicy |
NONE by default; RETAIN keeps an extra copy of initial native values. |
TYPE
struct DataStoreValueViewCreated by the view accessors. Copyable; owns no storage. Finish using views and borrowed strings before a store mutation, row/batch advance or query end. Synchronize ID-based reads externally; query views use the current reservation. The private representation is not a serialized/native row layout.
TYPE
struct DataStoreVector3Vector3 value
MEMBERS
float[3] |
m_Values |
X, Y and Z components. |
TYPE
struct DataStoreVector4Vector4 value
MEMBERS
float[4] |
m_Values |
X, Y, Z and W components. |
TYPE
struct DataStoreViewIteratorBorrows its parent view, which must remain unchanged and outlive iteration. Has the same borrowed-data lifetime and synchronization requirements as DataStoreValueView.
Registry name for the engine-owned HDataStoreContext, available from extension app initialization through app finalization. Borrow the store; do not destroy it. Finish jobs and release your queries and tables before finalization ends. Enable creation with engine.datastore = 1; the default is 0 (disabled). Context lookup returns NULL while disabled.
Registered in the engine's DATASTORE_CONTEXT_NAME store when engine.datastore is enabled. Signaled after dmGameObject::Update, including late updates, and before rendering. The engine waits for ready functions and their dependents, then ends the frame's schedule. Post-update functions can depend on functions from DATASTORE_EVENT_GAMEOBJECT_PRE_UPDATE. This precedes game-object PostUpdate deletion processing and does not refresh world transforms after callback writes. Callbacks run on workers; do not access game objects or Lua there. Standalone stores must register and signal their own events.
Registered in the engine's DATASTORE_CONTEXT_NAME store when engine.datastore is enabled. After input dispatch and before game-object updates, the engine starts the frame's schedule and signals this event. It waits for submitted functions and their dependents before updating components. The same schedule remains active through DATASTORE_EVENT_GAMEOBJECT_POST_UPDATE. Callbacks run on a dedicated engine job context; do not access game objects or Lua from workers. This does not refresh world transforms. Standalone stores must register and signal their own events.
void DataStoreFieldId()
Returned by DataStoreQueryFindField and valid for that query until its destruction. UINT32_MAX means no matching field. This is not a field-name hash or byte offset.
PARAMETERS
void DataStoreId()
As a row ID, a store-generated handle with generation checks, valid until removal. Row IDs survive moves, are not serialized, and cannot be zero. As a group ID, a caller-provided 64-bit owner key, such as a game-object handle. Group bookkeeping is created on first addition; the caller controls uniqueness and reuse. Group removal removes its rows and blob registrations. Zero selects ungrouped rows. Query group filters match the same key if it is reused. The datastore does not manage the external owner's lifetime.
PARAMETERS
void DataStoreSystemProcess(HDataStoreQuery query, uint32_t first, uint32_t num_rows, void* context)
The scheduler reserves the query and calls this function once per job. With m_RowsPerJob set, jobs may run concurrently over disjoint ranges. Otherwise one job covers all matching rows. An empty query still invokes one job with zero rows. Use DataStoreQueryIterRange for the supplied range, not DataStoreQueryIter for the whole query. Returning finishes this range; do not leave child jobs running or retain iterators/pointers. Query access is released and dependents are scheduled only after every range finishes. Compatible registered functions may run concurrently. Synchronize shared context writes and do not call scheduler operations from workers. Disjoint row ranges do not make aliased external or referenced data independent.
PARAMETERS
HDataStoreQuery |
query |
Registered query with active access. |
uint32_t |
first |
Zero-based index in the query's reserved matching rows, not a row ID. |
uint32_t |
num_rows |
Number of rows in this job's range, possibly spanning tables. |
void* |
context |
Borrowed user context from registration; may be zero. |
void HDataStoreBlob()
Owns a reference to validated metadata, borrowing the caller's immutable bytes. Release with DataStoreBlobDestroy. Store-owned references are synchronized across stores; keep a live reference while other threads call DataStoreBlobAdd.
PARAMETERS
void HDataStoreBlobInstance()
Identifies one grouped registration in a store. Release with DataStoreBlobRemove or DataStoreGroupRemove, or by destroying the store. This does not own the caller's blob bytes.
PARAMETERS
void HDataStoreContext()
Owned when created with DataStoreCreate; engine-supplied handles are borrowed.
PARAMETERS
void HDataStoreQuery()
Owns a live query. Destroy after its iterators finish, before its store shuts down.
PARAMETERS
Pass zero for shared read access, the default.
DATASTORE_FIELD_MUTABLE |
Exclusive read/write access (1). |
Zero keeps field-level access and disables whole-row pointers. Field reads are the default; individual writes require DATASTORE_FIELD_MUTABLE.
DATASTORE_ROW_MUTABLE |
Exclusive read/write access to the entire row; reference slots must not be overwritten (2). |
Query item kinds
DATASTORE_QUERY_ITEM_NONE |
Unused entry; ends the item list (0). |
DATASTORE_QUERY_ITEM_FIELD |
Required field with an exact value kind (1). |
DATASTORE_QUERY_ITEM_TAG |
Required table tag (2). |
Controls whether native row creation retains initial values. Blob instances always use their immutable resource as reset defaults. Borrowed views retain none.
DATASTORE_RESET_NONE |
Store current values only; the default. Reset returns INVALID_ARGUMENT. |
DATASTORE_RESET_RETAIN |
Keep an extra copy of initial values for row/field reset. |
Output arguments remain unchanged on error unless stated otherwise.
DATASTORE_RESULT_OK |
Operation succeeded (0). |
DATASTORE_RESULT_NOT_FOUND |
Table, row, group, field, system or event was not found (-1). |
DATASTORE_RESULT_LOCKED |
An operation requires query reservations or a schedule to finish (-3). |
DATASTORE_RESULT_INVALID_ARGUMENT |
Invalid argument, value or count (-4). |
DATASTORE_RESULT_ALREADY_EXISTS |
Table type, field name or function/event name is duplicated (-5). |
DATASTORE_RESULT_BUFFER_TOO_SMALL |
The output buffer is too small (-6). |
DATASTORE_RESULT_INVALID_FORMAT |
The serialized blob is malformed or has an unsupported version (-7). |
DATASTORE_RESULT_BUSY |
Unfinished schedule work, query already active, conflicting access, or store mutation in progress (-8). |
Declared field kinds. Structs and lists may nest.
DATASTORE_TYPE_NUMBER |
Double-precision number (0). |
DATASTORE_TYPE_BOOLEAN |
Boolean encoded as zero or one (1). |
DATASTORE_TYPE_STRING |
NUL-terminated string (2). |
DATASTORE_TYPE_NULL |
Null value with no payload (3). |
DATASTORE_TYPE_STRUCT |
Named fields (4). |
DATASTORE_TYPE_LIST |
Ordered values (5). |
DATASTORE_TYPE_VECTOR3 |
Three float32 components (6). |
DATASTORE_TYPE_VECTOR4 |
Four float32 components (7). |
DATASTORE_TYPE_MATRIX4 |
Sixteen float32 components in column-major order (8). |
DATASTORE_TYPE_FLOAT |
Single-precision number, stored as float. |
DATASTORE_TYPE_UINT32 |
Unsigned 32-bit integer. |