Qt 4.8
Public Types | Public Functions | Public Variables | Private Functions | List of all members
QPatternist::ReferenceCountedValue< T > Class Template Reference

A template class that reference counts a value. More...

#include <qreferencecountedvalue_p.h>

Inheritance diagram for QPatternist::ReferenceCountedValue< T >:
QSharedData

Public Types

typedef QExplicitlySharedDataPointer< ReferenceCountedValue< T > > Ptr
 

Public Functions

 ReferenceCountedValue (T *const v)
 
 ~ReferenceCountedValue ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Public Variables

T *const value
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Private Functions

 ReferenceCountedValue ()
 Disabled, no implementation provided. More...
 

Detailed Description

template<typename T>
class QPatternist::ReferenceCountedValue< T >

A template class that reference counts a value.

Warning
This function is not part of the public interface.
Since
4.4

This class is useful when an instance needs to have ownership semantics as if it was value based. A typical examples is a QObject pointer, which doesn't have a single owner.

This is achieved through storing a copy of the object as a member inside ReferenceCountedValue, which never is copied. It will stay in scope until the last reference to the ReferenceCountedValue instance is removed, and subsequently ReferenceCountedValue is deleted and hence also the contained value. One should use ReferenceCountedValue by passing around copies of Ptr, which is a typedef for the QExplicitlySharedDataPointer smart pointer.

Definition at line 82 of file qreferencecountedvalue_p.h.

Typedefs

◆ Ptr

Definition at line 85 of file qreferencecountedvalue_p.h.

Constructors and Destructors

◆ ReferenceCountedValue() [1/2]

template<typename T>
QPatternist::ReferenceCountedValue< T >::ReferenceCountedValue ( T *const  v)
inline

Definition at line 87 of file qreferencecountedvalue_p.h.

87  : value(v)
88  {
89  }

◆ ~ReferenceCountedValue()

template<typename T>
QPatternist::ReferenceCountedValue< T >::~ReferenceCountedValue ( )
inline

Definition at line 91 of file qreferencecountedvalue_p.h.

92  {
93  delete value;
94  }

◆ ReferenceCountedValue() [2/2]

template<typename T>
QPatternist::ReferenceCountedValue< T >::ReferenceCountedValue ( )
inlineprivate

Disabled, no implementation provided.

Properties

◆ value

template<typename T>
T* const QPatternist::ReferenceCountedValue< T >::value

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