20 #ifndef OMNI_VISUAL_CONTEXTBOUNDPTR_H_
21 #define OMNI_VISUAL_CONTEXTBOUNDPTR_H_
24 #include <QOpenGLContext>
25 #include <QOpenGLFramebufferObject>
31 template<
typename T,
typename DELETER>
36 template<
typename T,
typename DELETER = std::default_delete<T>>
39 template<
typename PTR>
42 &QOpenGLContext::aboutToBeDestroyed,
53 if (!QOpenGLContext::currentContext())
return;
76 template<
typename T,
typename DELETER = std::default_delete<T>>
80 template<
typename PTR>
82 QOpenGLContext *_context =
83 QOpenGLContext::globalShareContext()) {
107 template<
typename PTR>
109 QOpenGLContext *_context = QOpenGLContext::globalShareContext()) {
113 bool _valid = _context ? _context->surface() !=
nullptr :
false;
128 explicit operator bool()
const {
129 return get() !=
nullptr;
133 typename std::add_lvalue_reference<T>::type
operator*()
const {
T * ptr_
Definition: ContextBoundPtr.h:66
void reset()
Delete held object and internal state.
Definition: ContextBoundPtr.h:99
ContextBoundPtr(PTR *_p, QOpenGLContext *_context=QOpenGLContext::globalShareContext())
Definition: ContextBoundPtr.h:81
The internal structure responsible for deleting the object.
Definition: ContextBoundPtr.h:37
void contextSwitch(QOpenGLContext *_context, ContextFunctor f)
Definition: ContextSwitch.cpp:25
QMetaObject::Connection connection_
Definition: ContextBoundPtr.h:65
ContextBoundPtr & operator=(const ContextBoundPtr &)=delete
Delete copy assignment operator.
QOpenGLContext * context_
Definition: ContextBoundPtr.h:68
~ContextBoundPtrInternal()
Definition: ContextBoundPtr.h:51
T * operator->() const
Definition: ContextBoundPtr.h:137
ContextBoundPtr()
Definition: ContextBoundPtr.h:78
QOpenGLContext * context() const
Return pointer to associated context.
Definition: ContextBoundPtr.h:142
~ContextBoundPtr()
Definition: ContextBoundPtr.h:87
T * reset(PTR *_p, QOpenGLContext *_context=QOpenGLContext::globalShareContext())
Reset and and assign neew pointer.
Definition: ContextBoundPtr.h:108
QSurface * surface_
Definition: ContextBoundPtr.h:67
detail::ContextBoundPtrInternal< T > * internal_
Definition: ContextBoundPtr.h:147
std::add_lvalue_reference< T >::type operator*() const
Return reference.
Definition: ContextBoundPtr.h:133
ContextBoundPtrInternal(PTR *_ptr, QOpenGLContext *_context)
Definition: ContextBoundPtr.h:40
A pointer template which is free'd together with its context Holds an internal object which is respo...
Definition: ContextBoundPtr.h:32