Support Forum G3D Web Page |
Provides a level of indirection for accessing objects to allow computing them on demand or extending them with metadata without subclassing the object itself.
More...
Public Member Functions | |
lazy_ptr () | |
Creates a nullptr lazy pointer. More... | |
lazy_ptr (nullptr_t) | |
lazy_ptr (const std::function< shared_ptr< T >(void)> &resolve) | |
Creates a lazy_ptr from a function that will create the object. More... | |
lazy_ptr (const shared_ptr< T > &object) | |
Creates a lazy_ptr for an already-resolved object. More... | |
template<class S > | |
lazy_ptr (const shared_ptr< S > &object) | |
Creates a lazy_ptr for an already-resolved object. More... | |
bool | isNull () const |
Is the proxy itself a null pointer. More... | |
bool | operator!= (const lazy_ptr< T > &other) const |
const T & | operator* () const |
Invokes resolve. More... | |
T & | operator* () |
Invokes resolve. More... | |
const T * | operator-> () const |
Invokes resolve. More... | |
T * | operator-> () |
Invokes resolve. More... | |
bool | operator== (const lazy_ptr< T > &other) const |
const shared_ptr< T > | resolve () const |
Returns a pointer to a T or a nullptr pointer. More... | |
shared_ptr< T > | resolve () |
Returns a pointer to a T or a nullptr pointer. More... | |
bool | resolved () const |
True if this object can be resolved() without triggering any evaluation. More... | |
Provides a level of indirection for accessing objects to allow computing them on demand or extending them with metadata without subclassing the object itself.
For example, lazy loading of files.
Useful for implementing lazy loading, for example, as done by ArticulatedModel::lazyCreate:
Analogous to shared_ptr and weak_ptr. Copies of lazy_ptrs retain the same underlying object, so it will only be resolved once.
Threadsafe.
|
inline |
Creates a nullptr lazy pointer.
|
inline |
|
inline |
Creates a lazy_ptr from a function that will create the object.
|
inline |
Creates a lazy_ptr for an already-resolved object.
|
inline |
Creates a lazy_ptr for an already-resolved object.
|
inline |
Is the proxy itself a null pointer.
Referenced by G3D::isNull(), G3D::notNull(), G3D::lazy_ptr< T >::operator==(), G3D::lazy_ptr< T >::resolve(), and G3D::lazy_ptr< T >::resolved().
|
inline |
|
inline |
Invokes resolve.
If you intend to use multiple dereferences, it is faster to invoke resolve() once and store the shared_ptr.
|
inline |
Invokes resolve.
If you intend to use multiple dereferences, it is faster to invoke resolve() once and store the shared_ptr.
|
inline |
Invokes resolve.
If you intend to use multiple dereferences, it is faster to invoke resolve() once and store the shared_ptr.
|
inline |
Invokes resolve.
If you intend to use multiple dereferences, it is faster to invoke resolve() once and store the shared_ptr.
|
inline |
|
inline |
Returns a pointer to a T or a nullptr pointer.
If there are multiple levels of proxies, then this call resolves all of them.
Referenced by G3D::lazy_ptr< T >::operator*(), and G3D::lazy_ptr< T >::operator->().
|
inline |
Returns a pointer to a T or a nullptr pointer.
If there are multiple levels of proxies, then this call resolves all of them.
|
inline |
True if this object can be resolved() without triggering any evaluation.