8#ifndef META_OCEAN_DEVICES_ARCORE_AC_SCOPED_AR_OBJECT_H
9#define META_OCEAN_DEVICES_ARCORE_AC_SCOPED_AR_OBJECT_H
13#include <arcore_c_api.h>
25template <
typename T,
void (*tDestroyFunction)(T*)>
126template <
typename T,
void (*tDestroyFunction)(T*)>
185 inline operator T*()
const;
191 explicit inline operator bool()
const;
218template <
typename T,
void (*tDestroyFunction)(T*)>
222 static_assert(tDestroyFunction !=
nullptr,
"Invalid destroy function!");
225template <
typename T,
void (*tDestroyFunction)(T*)>
228 ocean_assert(arSession !=
nullptr);
229 ocean_assert(createFunction !=
nullptr);
231 createFunction(arSession, &object_);
232 ocean_assert(object_ !=
nullptr);
235template <
typename T,
void (*tDestroyFunction)(T*)>
238 *
this = std::move(arScopedObject);
241template <
typename T,
void (*tDestroyFunction)(T*)>
247template <
typename T,
void (*tDestroyFunction)(T*)>
255template <
typename T,
void (*tDestroyFunction)(T*)>
258 if (object_ !=
nullptr)
260 tDestroyFunction(object_);
265template <
typename T,
void (*tDestroyFunction)(T*)>
271template <
typename T,
void (*tDestroyFunction)(T*)>
274 return object_ !=
nullptr;
277template <
typename T,
void (*tDestroyFunction)(T*)>
280 if (
this != &arScopedObject)
284 object_ = arScopedObject.object_;
285 arScopedObject.object_ =
nullptr;
T ** ingest()
Allows ingesting an object via an external function.
Definition ScopedARObject.h:248
void(*)(const ArSession *arSession, T **object) CreateFunction
Definition of a function pointer to a function creating the object.
Definition ScopedARObject.h:136
~ScopedARObject()
Destructs the object and destroys it.
Definition ScopedARObject.h:242
ScopedARObject< T, tDestroyFunction > & operator=(ScopedARObject< T, tDestroyFunction > &&arScopedObject)
Move operator.
Definition ScopedARObject.h:278
ScopedARObject(T *object)
Creates a new scoped ARCore object.
Definition ScopedARObject.h:219
ScopedARObject(const ArSession *arSession, const CreateFunction &createFunction)
Creates a new scoped ARCore object.
Definition ScopedARObject.h:226
ScopedARObject(const ScopedARObject< T, tDestroyFunction > &)=delete
Disabled copy constructor.
ScopedARObject()=default
Default constructor creating an invalid object.
void release()
Explicitly releases the scoped object.
Definition ScopedARObject.h:256
ScopedARObject< T, tDestroyFunction > & operator=(const ScopedARObject< T, tDestroyFunction > &)=delete
Disabled assign operator.
ScopedARObject(ScopedARObject< T, tDestroyFunction > &&arScopedObject)
Move constructor.
Definition ScopedARObject.h:236
T * object_
The actual object.
Definition ScopedARObject.h:215
The namespace covering the entire Ocean framework.
Definition Accessor.h:15