WVR_EnumerateCachedSpatialAnchorNames¶
-
WVR_EXPORT WVR_Result WVR_EnumerateCachedSpatialAnchorNames(uint32_t cachedSpatialAnchorNamesCapacityInput, uint32_t * cachedSpatialAnchorNamesCountOutput, WVR_SpatialAnchorName * cachedSpatialAnchorNames)
Function is used to enumerate the name list of cached anchors.
This is two calls API. Developers should call this API with the value of cachedSpatialAnchorNamesCapacityInput equals to 0 to retrieve the size of data from cachedSpatialAnchorNamesCountOutput. Then developers allocate the size of data and assign the cachedSpatialAnchorNamesCapacityInput 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 cachedSpatialAnchorNamesCountOutput when retrieving the data that filled by runtime during the second time.
- Version
- API Level 14
- Parameters
cachedSpatialAnchorNamesCapacityInput
: the capacity of the data, or 0 to indicate a request to retrieve the required capacity.cachedSpatialAnchorNamesCountOutput
: a pointer to the count of data written, or a pointer to the required capacity in the case that cachedSpatialAnchorNamesCapacityInput is insufficient.cachedSpatialAnchorNames
: a pointer to an array of WVR_SpatialAnchorName names, but can be NULL if cachedSpatialAnchorNamesCapacityInput is 0.
- Return Value
WVR_Success
: Enumerate the names of the cached spatial anchors successfully.others
: WVR_Result mean failure.
How to use¶
Sample function:
// somewhere to listen cached spatial anchor list change event
void ProcessEvent() {
WVR_Event_t event;
while(WVR_PollEventQueue(&event)) {
switch (event.common.type) {
case WVR_EventType_CachedAnchor_Changed: {
uint32_t output = 0;
if (WVR_EnumerateCachedSpatialAnchorNames(0, &output, nullptr) == WVR_Success) {
uint32_t input = output;
auto anchorNames = (WVR_SpatialAnchorName*)malloc(sizeof(WVR_SpatialAnchorName)*(input));
if (WVR_EnumerateCachedSpatialAnchorNames(input, &output, anchorNames) == WVR_Success) {
// enumerate all cached spatial anchor names successfully
// get the valid cached spatial anchor names
uint32_t size = input<=output? input:output;
for (int i; i<size; i++) {
}
}
}
break;
}
}
}
}