WVR_EnumeratePersistedSpatialAnchorNames

WVR_EXPORT WVR_Result WVR_EnumeratePersistedSpatialAnchorNames(uint32_t persistedSpatialAnchorNamesCapacityInput, uint32_t * persistedSpatialAnchorNamesCountOutput, WVR_SpatialAnchorName * persistedSpatialAnchorNames)

Function is used to enumerate the name list of persisted anchors.

This is two calls API. Developers should call this API with the value of persistedSpatialAnchorNamesCapacityInput equals to 0 to retrieve the size of data from persistedSpatialAnchorNamesCountOutput. Then developers allocate the size of data and assign the persistedSpatialAnchorNamesCapacityInput and call the API in the second time. Then runtime will fill the data.

Note: Since there is a time gap between the first and the second calls, developers should verify the persistedSpatialAnchorNamesCountOutput when retrieving the data that filled by runtime during the second time.

Version
API Level 14
Parameters
  • persistedSpatialAnchorNamesCapacityInput: the capacity of the data, or 0 to indicate a request to retrieve the required capacity.
  • persistedSpatialAnchorNamesCountOutput: a pointer to the count of data written, or a pointer to the required capacity in the case that persistedSpatialAnchorNamesCapacityInput is insufficient.
  • persistedSpatialAnchorNames: a pointer to an array of WVR_SpatialAnchorName names, but can be NULL if persistedSpatialAnchorNamesCapacityInput is 0.
Return Value
  • WVR_Success: Enumerate the names of the persisted spatial anchors successfully.
  • others: WVR_Result mean failure.

How to use

Sample function:

// somewhere to listen persisted spatial anchor list change event
void ProcessEvent() {
    WVR_Event_t event;
    while(WVR_PollEventQueue(&event)) {
        switch (event.common.type) {
            case WVR_EventType_PersistedAnchor_Changed: {
                uint32_t output = 0;
                if (WVR_EnumeratePersistedSpatialAnchorNames(0, &output, nullptr) == WVR_Success) {
                    uint32_t input = output;
                    auto anchorNames = (WVR_SpatialAnchorName*)malloc(sizeof(WVR_SpatialAnchorName)*(input));
                    if (WVR_EnumeratePersistedSpatialAnchorNames(input, &output, anchorNames) == WVR_Success) {
                        // enumerate all persisted spatial anchor names successfully
                        // get the valid persisted spatial anchor names
                        uint32_t size = input<=output? input:output;
                        for (int i; i<size; i++) {
                        }
                     }
                }

                break;
            }
        }
    }
}