8 #ifndef META_OCEAN_PLATFORM_META_QUEST_PLATFORMSDK_MESSAGE_HANDLER_H
9 #define META_OCEAN_PLATFORM_META_QUEST_PLATFORMSDK_MESSAGE_HANDLER_H
15 #include <OVR_Platform.h>
78 inline operator T()
const;
105 T options_ =
nullptr;
115 template <
typename T>
129 void setResponse(T&& response);
135 void setResponse(
const T& response);
143 bool latestResponse(T& response);
151 bool hasLatestResponse_ =
false;
160 template <
typename T>
174 std::future<T> addRequest();
181 void setResponse(T&& response);
188 void setResponse(
const T& response);
209 template <
typename T>
231 template <
typename T>
241 template <
typename T>
266 static constexpr uint32_t string2tag(
const char tagString[4]);
285 template <
typename T>
288 return invokeRequest(requestId, std::bind(responseCallback, (T*)(
this), std::placeholders::_1, std::placeholders::_2));
291 template <
typename T>
294 return subscribeForMessageResponse(messageType, std::bind(responseCallback, (T*)(
this), std::placeholders::_1, std::placeholders::_2));
297 template <
typename T>
300 destroyFunction_(destroyFunction)
306 template <
typename T>
309 ocean_assert(options_ !=
nullptr);
310 ocean_assert(destroyFunction_ !=
nullptr);
312 destroyFunction_(options_);
315 template <
typename T>
321 template <
typename T>
326 latestResponse_ = std::move(response);
327 hasLatestResponse_ =
true;
330 template <
typename T>
335 latestResponse_ = response;
336 hasLatestResponse_ =
true;
339 template <
typename T>
344 if (hasLatestResponse_)
346 value = std::move(latestResponse_);
347 hasLatestResponse_ =
false;
355 template <
typename T>
360 std::promise<T> promise;
361 std::future future = promise.get_future();
363 promises_.push(std::move(promise));
368 template <
typename T>
373 ocean_assert(!promises_.empty());
375 std::promise<T>& promise = promises_.front();
376 promise.set_value(response);
383 template <
typename T>
388 ocean_assert(!promises_.empty());
390 std::promise<T>& promise = promises_.front();
391 promise.set_value(response);
400 ocean_assert(tagString[0] != 0 && tagString[1] != 0 && tagString[2] != 0 && tagString[3] != 0);
402 return (uint32_t(tagString[0]) << 0ull)
403 | (uint32_t(tagString[1]) << 8ull)
404 | (uint32_t(tagString[2]) << 16ull)
405 | (uint32_t(tagString[3]) << 24ull);
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
This class implements a subscription object which can be used unique subscriptions to e....
Definition: ScopedSubscription.h:28
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15