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::ContextBoundPtr< T, DELETER > Struct Template Reference

A pointer template which is free'd together with its context Holds an internal object which is responsible for freeing the held object when OpenGL context is free'd. More...

#include <ContextBoundPtr.h>

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

Public Member Functions

 ContextBoundPtr ()
 
template<typename PTR >
 ContextBoundPtr (PTR *_p, QOpenGLContext *_context=QOpenGLContext::globalShareContext())
 
 ~ContextBoundPtr ()
 
 ContextBoundPtr (const ContextBoundPtr &that)=delete
 Delete copy constructor. More...
 
ContextBoundPtroperator= (const ContextBoundPtr &)=delete
 Delete copy assignment operator. More...
 
void reset ()
 Delete held object and internal state. More...
 
template<typename PTR >
T * reset (PTR *_p, QOpenGLContext *_context=QOpenGLContext::globalShareContext())
 Reset and and assign neew pointer. More...
 
T * get () const
 
 operator bool () const
 Cast to bool operator. Return true if pointer is not null. More...
 
std::add_lvalue_reference< T >
::type 
operator* () const
 Return reference. More...
 
T * operator-> () const
 
QOpenGLContext * context () const
 Return pointer to associated context. More...
 

Private Attributes

detail::ContextBoundPtrInternal
< T > * 
internal_ = nullptr
 

Detailed Description

template<typename T, typename DELETER>
struct omni::visual::ContextBoundPtr< T, DELETER >

A pointer template which is free'd together with its context Holds an internal object which is responsible for freeing the held object when OpenGL context is free'd.

Constructor & Destructor Documentation

template<typename T, typename DELETER>
omni::visual::ContextBoundPtr< T, DELETER >::ContextBoundPtr ( )
inline
78 {}
template<typename T, typename DELETER>
template<typename PTR >
omni::visual::ContextBoundPtr< T, DELETER >::ContextBoundPtr ( PTR *  _p,
QOpenGLContext *  _context = QOpenGLContext::globalShareContext() 
)
inline
83  {
84  reset(_p, _context);
85  }
void reset()
Delete held object and internal state.
Definition: ContextBoundPtr.h:99
template<typename T, typename DELETER>
omni::visual::ContextBoundPtr< T, DELETER >::~ContextBoundPtr ( )
inline
87  {
88  // Internal is not deleted here because its done by the bound context
89  //reset();
90  }
template<typename T, typename DELETER>
omni::visual::ContextBoundPtr< T, DELETER >::ContextBoundPtr ( const ContextBoundPtr< T, DELETER > &  that)
delete

Delete copy constructor.

Member Function Documentation

template<typename T, typename DELETER>
QOpenGLContext* omni::visual::ContextBoundPtr< T, DELETER >::context ( ) const
inline

Return pointer to associated context.

142  {
143  return internal_ ? internal_->context_ : nullptr;
144  }
QOpenGLContext * context_
Definition: ContextBoundPtr.h:68
detail::ContextBoundPtrInternal< T > * internal_
Definition: ContextBoundPtr.h:147
template<typename T, typename DELETER>
T* omni::visual::ContextBoundPtr< T, DELETER >::get ( ) const
inline
123  {
124  return internal_ ? internal_->ptr_ : nullptr;
125  }
T * ptr_
Definition: ContextBoundPtr.h:66
detail::ContextBoundPtrInternal< T > * internal_
Definition: ContextBoundPtr.h:147
template<typename T, typename DELETER>
omni::visual::ContextBoundPtr< T, DELETER >::operator bool ( ) const
inlineexplicit

Cast to bool operator. Return true if pointer is not null.

128  {
129  return get() != nullptr;
130  }
template<typename T, typename DELETER>
std::add_lvalue_reference<T>::type omni::visual::ContextBoundPtr< T, DELETER >::operator* ( ) const
inline

Return reference.

133  {
134  return *get();
135  }
template<typename T, typename DELETER>
T* omni::visual::ContextBoundPtr< T, DELETER >::operator-> ( ) const
inline
137  {
138  return get();
139  }
template<typename T, typename DELETER>
ContextBoundPtr& omni::visual::ContextBoundPtr< T, DELETER >::operator= ( const ContextBoundPtr< T, DELETER > &  )
delete

Delete copy assignment operator.

template<typename T, typename DELETER>
void omni::visual::ContextBoundPtr< T, DELETER >::reset ( )
inline

Delete held object and internal state.

99  {
100  if (internal_) {
101  delete internal_;
102  internal_ = nullptr;
103  }
104  }
detail::ContextBoundPtrInternal< T > * internal_
Definition: ContextBoundPtr.h:147
template<typename T, typename DELETER>
template<typename PTR >
T* omni::visual::ContextBoundPtr< T, DELETER >::reset ( PTR *  _p,
QOpenGLContext *  _context = QOpenGLContext::globalShareContext() 
)
inline

Reset and and assign neew pointer.

Reset and make new internal object

No initialization without context!

109  {
110  /// Reset and make new internal object
111  reset();
112  /// No initialization without context!
113  bool _valid = _context ? _context->surface() != nullptr : false;
114  if (!_valid) {
115  return nullptr;
116  }
117 
118  internal_ = new detail::ContextBoundPtrInternal<T,DELETER>(_p, _context);
119 
120  return get();
121  }
void reset()
Delete held object and internal state.
Definition: ContextBoundPtr.h:99
detail::ContextBoundPtrInternal< T > * internal_
Definition: ContextBoundPtr.h:147

Field Documentation

template<typename T, typename DELETER>
detail::ContextBoundPtrInternal<T>* omni::visual::ContextBoundPtr< T, DELETER >::internal_ = nullptr
private

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