Qt 4.8
Public Functions | Protected Functions | List of all members
QGLContextResource< T > Class Template Reference

#include <qgl_p.h>

Inheritance diagram for QGLContextResource< T >:
QGLContextResourceBase

Public Functions

T * value (const QGLContext *context)
 
 ~QGLContextResource ()
 
- Public Functions inherited from QGLContextResourceBase
void insert (const QGLContext *context, void *value)
 
void * value (const QGLContext *context)
 
virtual ~QGLContextResourceBase ()
 

Protected Functions

void freeResource (void *resource)
 

Additional Inherited Members

- Protected Variables inherited from QGLContextResourceBase
QList< const QGLContext * > m_contexts
 

Detailed Description

template<class T>
class QGLContextResource< T >

Definition at line 824 of file qgl_p.h.

Constructors and Destructors

◆ ~QGLContextResource()

template<class T >
QGLContextResource< T >::~QGLContextResource ( )
inline

Definition at line 827 of file qgl_p.h.

827  {
828  for (int i = 0; i < m_contexts.size(); ++i) {
829  const QGLContext *context = m_contexts.at(i);
830  T *resource = reinterpret_cast<T *>(QGLContextResourceBase::value(context));
831  if (resource) {
832  QGLShareContextScope scope(context);
833  delete resource;
834  }
835  }
836  }
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< const QGLContext * > m_contexts
Definition: qgl_p.h:811
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void * value(const QGLContext *context)
Definition: qgl_p.h:805

Functions

◆ freeResource()

template<class T >
void QGLContextResource< T >::freeResource ( void *  resource)
inlineprotectedvirtual

Implements QGLContextResourceBase.

Definition at line 848 of file qgl_p.h.

848  {
849  delete reinterpret_cast<T *>(resource);
850  }

◆ value()

template<class T >
T* QGLContextResource< T >::value ( const QGLContext context)
inline

Definition at line 838 of file qgl_p.h.

838  {
839  T *resource = reinterpret_cast<T *>(QGLContextResourceBase::value(context));
840  if (!resource) {
841  resource = new T(context);
842  insert(context, resource);
843  }
844  return resource;
845  }
void * value(const QGLContext *context)
Definition: qgl_p.h:805
void insert(const QGLContext *context, void *value)
Definition: qgl_p.h:801

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