libcamgm
Public Types | Public Member Functions | Private Attributes | Related Functions | List of all members
ca_mgm::RW_pointer< _D, _Traits > Struct Template Reference

#include <PtrTypes.hpp>

Public Types

typedef _Traits::_Ptr _Ptr
 
typedef _Traits::_constPtr _constPtr
 

Public Member Functions

 RW_pointer (typename _Ptr::element_type *dptr=0)
 
 RW_pointer (_Ptr dptr)
 
void reset ()
 
void reset (typename _Ptr::element_type *dptr)
 
void swap (RW_pointer &rhs)
 
void swap (_Ptr &rhs)
 
 operator bool () const
 
const _D & operator* () const
 
const _D * operator-> () const
 
const _D * get () const
 
_D & operator* ()
 
_D * operator-> ()
 
_D * get ()
 
bool unique () const
 
long use_count () const
 
_constPtr getPtr () const
 
_Ptr getPtr ()
 
_constPtr cgetPtr ()
 

Private Attributes

_Ptr _dptr
 

Related Functions

(Note that these are not member functions.)

template<class _D , class _Ptr >
std::ostream & operator<< (std::ostream &str, const RW_pointer< _D, _Ptr > &obj)
 
template<class _D , class _Ptr >
bool operator== (const RW_pointer< _D, _Ptr > &lhs, const RW_pointer< _D, _Ptr > &rhs)
 
template<class _D , class _Ptr >
bool operator== (const RW_pointer< _D, _Ptr > &lhs, const typename _Ptr::_Ptr &rhs)
 
template<class _D , class _Ptr >
bool operator== (const typename _Ptr::_Ptr &lhs, const RW_pointer< _D, _Ptr > &rhs)
 
template<class _D , class _Ptr >
bool operator== (const RW_pointer< _D, _Ptr > &lhs, const typename _Ptr::_constPtr &rhs)
 
template<class _D , class _Ptr >
bool operator== (const typename _Ptr::_constPtr &lhs, const RW_pointer< _D, _Ptr > &rhs)
 
template<class _D , class _Ptr >
bool operator!= (const RW_pointer< _D, _Ptr > &lhs, const RW_pointer< _D, _Ptr > &rhs)
 
template<class _D , class _Ptr >
bool operator!= (const RW_pointer< _D, _Ptr > &lhs, const typename _Ptr::_Ptr &rhs)
 
template<class _D , class _Ptr >
bool operator!= (const typename _Ptr::_Ptr &lhs, const RW_pointer< _D, _Ptr > &rhs)
 
template<class _D , class _Ptr >
bool operator!= (const RW_pointer< _D, _Ptr > &lhs, const typename _Ptr::_constPtr &rhs)
 
template<class _D , class _Ptr >
bool operator!= (const typename _Ptr::_constPtr &lhs, const RW_pointer< _D, _Ptr > &rhs)
 

Detailed Description

template<class _D, class _Traits = rw_pointer::Shared<_D>>
struct ca_mgm::RW_pointer< _D, _Traits >

Wrapper for const correct access via Smart pointer types.

ca_mgm::RW_pointer<tt><_D,_Traits> stores a Smart pointer types of type _Traits::_Ptr, which must be convertible into a _D *. Pointer style access (via -> and *) offers a const _D * in const a context, otherwise a _D *. Thus RW_ means read/write, as you get a different type, dependent on whether you're allowed to read or write.

Forwarding access from an interface to an implemantation class, an RW_pointer prevents const interface methods from accidentally calling nonconst implementation methods.

The second template argument defaults to _Traits = rw_pointer::Shared<_D> thus wraping a shared_ptr<_D>. To wrap an intrusive_ptr<_D> use rw_pointer::Intrusive<_D>.

See Also
ca_mgm::RWCOW_pointer for 'copy on write' functionality.
#include "ca_mgm/base/PtrTypes.h"
class Foo
{
...
private:
// Implementation class
struct Impl;
// Pointer to implementation; actually a shared_ptr<Impl>
RW_pointer<Impl> _pimpl;
void baa() { _pimpl->... } // is Impl *
void baa() const { _pimpl->... } // is Impl const *
};

Member Typedef Documentation

template<class _D, class _Traits = rw_pointer::Shared<_D>>
typedef _Traits::_constPtr ca_mgm::RW_pointer< _D, _Traits >::_constPtr
template<class _D, class _Traits = rw_pointer::Shared<_D>>
typedef _Traits::_Ptr ca_mgm::RW_pointer< _D, _Traits >::_Ptr

Constructor & Destructor Documentation

template<class _D, class _Traits = rw_pointer::Shared<_D>>
ca_mgm::RW_pointer< _D, _Traits >::RW_pointer ( typename _Ptr::element_type *  dptr = 0)
inlineexplicit
template<class _D, class _Traits = rw_pointer::Shared<_D>>
ca_mgm::RW_pointer< _D, _Traits >::RW_pointer ( _Ptr  dptr)
inlineexplicit

Member Function Documentation

template<class _D, class _Traits = rw_pointer::Shared<_D>>
_constPtr ca_mgm::RW_pointer< _D, _Traits >::cgetPtr ( )
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
const _D* ca_mgm::RW_pointer< _D, _Traits >::get ( ) const
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
_D* ca_mgm::RW_pointer< _D, _Traits >::get ( )
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
_constPtr ca_mgm::RW_pointer< _D, _Traits >::getPtr ( ) const
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
_Ptr ca_mgm::RW_pointer< _D, _Traits >::getPtr ( )
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
ca_mgm::RW_pointer< _D, _Traits >::operator bool ( ) const
inlineexplicit
template<class _D, class _Traits = rw_pointer::Shared<_D>>
const _D& ca_mgm::RW_pointer< _D, _Traits >::operator* ( ) const
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
_D& ca_mgm::RW_pointer< _D, _Traits >::operator* ( )
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
const _D* ca_mgm::RW_pointer< _D, _Traits >::operator-> ( ) const
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
_D* ca_mgm::RW_pointer< _D, _Traits >::operator-> ( )
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
void ca_mgm::RW_pointer< _D, _Traits >::reset ( )
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
void ca_mgm::RW_pointer< _D, _Traits >::reset ( typename _Ptr::element_type *  dptr)
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
void ca_mgm::RW_pointer< _D, _Traits >::swap ( RW_pointer< _D, _Traits > &  rhs)
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
void ca_mgm::RW_pointer< _D, _Traits >::swap ( _Ptr rhs)
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
bool ca_mgm::RW_pointer< _D, _Traits >::unique ( ) const
inline
template<class _D, class _Traits = rw_pointer::Shared<_D>>
long ca_mgm::RW_pointer< _D, _Traits >::use_count ( ) const
inline

Member Data Documentation

template<class _D, class _Traits = rw_pointer::Shared<_D>>
_Ptr ca_mgm::RW_pointer< _D, _Traits >::_dptr
private

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