Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes
omni::visual::detail::ContextBoundPtrInternal< T, DELETER > Struct Template Reference

The internal structure responsible for deleting the object. More...

#include <ContextBoundPtr.h>

Collaboration diagram for omni::visual::detail::ContextBoundPtrInternal< T, DELETER >:
Collaboration graph
[legend]

Public Member Functions

template<typename PTR >
 ContextBoundPtrInternal (PTR *_ptr, QOpenGLContext *_context)
 
 ~ContextBoundPtrInternal ()
 

Private Attributes

QMetaObject::Connection connection_
 
T * ptr_ = nullptr
 
QSurface * surface_ = nullptr
 
QOpenGLContext * context_ = nullptr
 

Detailed Description

template<typename T, typename DELETER = std::default_delete<T>>
struct omni::visual::detail::ContextBoundPtrInternal< T, DELETER >

The internal structure responsible for deleting the object.

Constructor & Destructor Documentation

template<typename T, typename DELETER = std::default_delete<T>>
template<typename PTR >
omni::visual::detail::ContextBoundPtrInternal< T, DELETER >::ContextBoundPtrInternal ( PTR *  _ptr,
QOpenGLContext *  _context 
)
inline
40  {
41  connection_ = QObject::connect(_context,
42  &QOpenGLContext::aboutToBeDestroyed,
43  [&]() {
44  delete this;
45  });
46  ptr_ = _ptr;
47  context_ = _context;
48  surface_ = _context->surface();
49  }
T * ptr_
Definition: ContextBoundPtr.h:66
QMetaObject::Connection connection_
Definition: ContextBoundPtr.h:65
QOpenGLContext * context_
Definition: ContextBoundPtr.h:68
QSurface * surface_
Definition: ContextBoundPtr.h:67
template<typename T, typename DELETER = std::default_delete<T>>
omni::visual::detail::ContextBoundPtrInternal< T, DELETER >::~ContextBoundPtrInternal ( )
inline

Make sure object is destroyed in its context

51  {
52  QObject::disconnect(connection_);
53  if (!QOpenGLContext::currentContext()) return;
54 
55  /// Make sure object is destroyed in its context
56  contextSwitch(context_,[&](QOpenGLFunctions& _) {
57  if (ptr_) {
58  DELETER()(ptr_);
59  ptr_ = nullptr;
60  }
61  });
62  }
T * ptr_
Definition: ContextBoundPtr.h:66
void contextSwitch(QOpenGLContext *_context, ContextFunctor f)
Definition: ContextSwitch.cpp:25
QMetaObject::Connection connection_
Definition: ContextBoundPtr.h:65
QOpenGLContext * context_
Definition: ContextBoundPtr.h:68

Field Documentation

template<typename T, typename DELETER = std::default_delete<T>>
QMetaObject::Connection omni::visual::detail::ContextBoundPtrInternal< T, DELETER >::connection_
private
template<typename T, typename DELETER = std::default_delete<T>>
QOpenGLContext* omni::visual::detail::ContextBoundPtrInternal< T, DELETER >::context_ = nullptr
private
template<typename T, typename DELETER = std::default_delete<T>>
T* omni::visual::detail::ContextBoundPtrInternal< T, DELETER >::ptr_ = nullptr
private
template<typename T, typename DELETER = std::default_delete<T>>
QSurface* omni::visual::detail::ContextBoundPtrInternal< T, DELETER >::surface_ = nullptr
private

The documentation for this struct was generated from the following file: