blocxx
BLOCXX_NAMESPACE::RefCountedPimpl< Impl > Class Template Reference

PURPOSE: Make it easy to define immutable classes or handle classes, making it inexpensive to copy them, while keeping implementation details out of the header file. More...

#include <RefCountedPimpl.hpp>

Protected Member Functions

 RefCountedPimpl ()
 
 RefCountedPimpl (Impl *p)
 
 RefCountedPimpl (IntrusiveCountableBase *p)
 
Impl * pimpl () const
 
bool null () const
 

Private Attributes

IntrusiveReference< IntrusiveCountableBasem_impl
 

Detailed Description

template<typename Impl>
class BLOCXX_NAMESPACE::RefCountedPimpl< Impl >

PURPOSE: Make it easy to define immutable classes or handle classes, making it inexpensive to copy them, while keeping implementation details out of the header file.

This is done by declaring

  class FooImpl;
  class Foo : private RefcountedPimpl<FooImpl>
  {
     ...
  };

and using pimpl() in Foo member functions to access the internal data. The Foo object is a wrapper around a reference-counted pointer to a FooImpl object.

Precondition
Impl is derived from BloCxx::IntrusiveCountableBase.

Definition at line 64 of file RefCountedPimpl.hpp.

Constructor & Destructor Documentation

◆ RefCountedPimpl() [1/3]

template<typename Impl>
BLOCXX_NAMESPACE::RefCountedPimpl< Impl >::RefCountedPimpl ( )
inlineprotected
Postcondition
Object holds null reference

Definition at line 79 of file RefCountedPimpl.hpp.

References m_impl.

◆ RefCountedPimpl() [2/3]

template<typename Impl>
BLOCXX_NAMESPACE::RefCountedPimpl< Impl >::RefCountedPimpl ( Impl * p)
inlineprotected
Postcondition
Object holds reference to *p.

Definition at line 86 of file RefCountedPimpl.hpp.

References m_impl.

◆ RefCountedPimpl() [3/3]

template<typename Impl>
BLOCXX_NAMESPACE::RefCountedPimpl< Impl >::RefCountedPimpl ( IntrusiveCountableBase * p)
inlineprotected
Postcondition
Object holds reference to *p.
Precondition
The dynamic type of *p is Impl or a subclass of Impl.

Definition at line 94 of file RefCountedPimpl.hpp.

References m_impl.

Member Function Documentation

◆ null()

template<typename Impl>
bool BLOCXX_NAMESPACE::RefCountedPimpl< Impl >::null ( ) const
inlineprotected
Returns
True if and only if this object holds a null pointer.

Definition at line 108 of file RefCountedPimpl.hpp.

References m_impl.

◆ pimpl()

template<typename Impl>
Impl * BLOCXX_NAMESPACE::RefCountedPimpl< Impl >::pimpl ( ) const
inlineprotected
Returns
A pointer to the Impl object held by *this.

Definition at line 101 of file RefCountedPimpl.hpp.

References m_impl.

Member Data Documentation

◆ m_impl

template<typename Impl>
IntrusiveReference<IntrusiveCountableBase> BLOCXX_NAMESPACE::RefCountedPimpl< Impl >::m_impl
private

Definition at line 118 of file RefCountedPimpl.hpp.

Referenced by null(), pimpl(), RefCountedPimpl(), RefCountedPimpl(), and RefCountedPimpl().


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