foobar2000 SDK  2015-08-03
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions
service_ptr_t< T >

#include <service.h>

+ Inheritance diagram for service_ptr_t< T >:

Public Member Functions

 service_ptr_t () throw ()
 
 service_ptr_t (T *p_ptr) throw ()
 
 service_ptr_t (const t_self &p_source) throw ()
 
 service_ptr_t (t_self &&p_source) throw ()
 
template<typename t_source >
 service_ptr_t (t_source *p_ptr) throw ()
 
template<typename t_source >
 service_ptr_t (const service_ptr_base_t< t_source > &p_source) throw ()
 
template<typename t_source >
 service_ptr_t (const service_nnptr_t< t_source > &p_source) throw ()
 
template<typename t_source >
 service_ptr_t (service_ptr_t< t_source > &&p_source) throw ()
 
 ~service_ptr_t () throw ()
 
service_ptr_t< service_base > & _as_base_ptr ()
 
T_duplicate_ptr () const throw ()
 
template<typename t_source >
void attach (t_source *p_ptr) throw ()
 
template<typename t_source >
void copy (t_source *p_ptr) throw ()
 
template<typename t_source >
void copy (const service_ptr_base_t< t_source > &p_source) throw ()
 
template<typename t_source >
void copy (service_ptr_t< t_source > &&p_source) throw ()
 
Tdetach () throw ()
 
Tget_ptr () const throw ()
 
bool is_empty () const throw ()
 
bool is_valid () const throw ()
 
bool operator!= (const service_ptr_base_t< T > &p_item) const throw ()
 
bool operator!= (T *p_item) const throw ()
 
template<typename otherPtr_t >
bool operator&= (otherPtr_t other)
 
Toperator* () const throw ()
 
service_obscure_refcounting< T > * operator-> () const throw ()
 
bool operator< (const service_ptr_base_t< T > &p_item) const throw ()
 
bool operator< (T *p_item) const throw ()
 
template<typename t_other >
t_selfoperator<< (service_ptr_t< t_other > &p_source) throw ()
 
const t_selfoperator= (const t_self &p_source) throw ()
 
const t_selfoperator= (t_self &&p_source) throw ()
 
const t_selfoperator= (T *p_ptr) throw ()
 
template<typename t_source >
t_selfoperator= (const service_ptr_base_t< t_source > &p_source) throw ()
 
template<typename t_source >
t_selfoperator= (service_ptr_t< t_source > &&p_source) throw ()
 
template<typename t_source >
t_selfoperator= (t_source *p_ptr) throw ()
 
template<typename t_source >
t_selfoperator= (const service_nnptr_t< t_source > &p_ptr) throw ()
 
bool operator== (const service_ptr_base_t< T > &p_item) const throw ()
 
bool operator== (T *p_item) const throw ()
 
bool operator> (const service_ptr_base_t< T > &p_item) const throw ()
 
bool operator> (T *p_item) const throw ()
 
template<typename t_other >
t_selfoperator>> (service_ptr_t< t_other > &p_dest) throw ()
 
template<typename otherPtr_t >
void operator^= (otherPtr_t other)
 
void release () throw ()
 
- Public Member Functions inherited from service_ptr_base_t< T >
Tget_ptr () const throw ()
 

Static Public Member Functions

static bool _as_base_ptr_check ()
 

Private Types

typedef service_ptr_t< Tt_self
 

Private Member Functions

template<typename t_source >
void _init (t_source *in) throw ()
 
template<typename t_source >
void _init (t_source &&in) throw ()
 

Additional Inherited Members

- Protected Attributes inherited from service_ptr_base_t< T >
Tm_ptr
 

Detailed Description

template<typename T>
class service_ptr_t< T >

Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.

Definition at line 55 of file service.h.

Member Typedef Documentation

template<typename T>
typedef service_ptr_t<T> service_ptr_t< T >::t_self
private

Definition at line 57 of file service.h.

Constructor & Destructor Documentation

template<typename T>
service_ptr_t< T >::service_ptr_t ( )
throw (
)
inline

Definition at line 67 of file service.h.

67 {this->m_ptr = NULL;}
template<typename T>
service_ptr_t< T >::service_ptr_t ( T p_ptr)
throw (
)
inline

Definition at line 68 of file service.h.

68 {_init(p_ptr);}
void _init(t_source *in)
Definition: service.h:59
template<typename T>
service_ptr_t< T >::service_ptr_t ( const t_self p_source)
throw (
)
inline

Definition at line 69 of file service.h.

69 {_init(p_source.get_ptr());}
void _init(t_source *in)
Definition: service.h:59
template<typename T>
service_ptr_t< T >::service_ptr_t ( t_self &&  p_source)
throw (
)
inline

Definition at line 70 of file service.h.

70 {_init(std::move(p_source));}
void _init(t_source *in)
Definition: service.h:59
template<typename T>
template<typename t_source >
service_ptr_t< T >::service_ptr_t ( t_source *  p_ptr)
throw (
)
inline

Definition at line 71 of file service.h.

71 {_init(p_ptr);}
void _init(t_source *in)
Definition: service.h:59
template<typename T>
template<typename t_source >
service_ptr_t< T >::service_ptr_t ( const service_ptr_base_t< t_source > &  p_source)
throw (
)
inline

Definition at line 72 of file service.h.

72 {_init(p_source.get_ptr());}
T * get_ptr() const
Definition: service.h:45
void _init(t_source *in)
Definition: service.h:59
template<typename T>
template<typename t_source >
service_ptr_t< T >::service_ptr_t ( const service_nnptr_t< t_source > &  p_source)
throw (
)
inline

Definition at line 73 of file service.h.

73 { this->m_ptr = p_source.get_ptr(); this->m_ptr->service_add_ref(); }
T * get_ptr() const
Definition: service.h:225
template<typename T>
template<typename t_source >
service_ptr_t< T >::service_ptr_t ( service_ptr_t< t_source > &&  p_source)
throw (
)
inline

Definition at line 74 of file service.h.

74 { _init(std::move(p_source)); }
void _init(t_source *in)
Definition: service.h:59
template<typename T>
service_ptr_t< T >::~service_ptr_t ( )
throw (
)
inline

Definition at line 76 of file service.h.

static void service_release_safe(T *p_ptr)
Definition: service.h:31

Member Function Documentation

template<typename T>
service_ptr_t<service_base>& service_ptr_t< T >::_as_base_ptr ( )
inline

Definition at line 157 of file service.h.

157  {
158  PFC_ASSERT( _as_base_ptr_check() );
159  return *reinterpret_cast<service_ptr_t<service_base>*>(this);
160  }
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
static bool _as_base_ptr_check()
Definition: service.h:161
template<typename T>
static bool service_ptr_t< T >::_as_base_ptr_check ( )
inlinestatic

Definition at line 161 of file service.h.

161  {
162  return static_cast<service_base*>((T*)NULL) == reinterpret_cast<service_base*>((T*)NULL);
163  }
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
template<typename T>
T* service_ptr_t< T >::_duplicate_ptr ( ) const
throw (
)
inline

Definition at line 140 of file service.h.

140  {//should not be used ! temporary !
142  return this->m_ptr;
143  }
static void service_add_ref_safe(T *p_ptr)
Definition: service.h:36
template<typename T>
template<typename t_source >
void service_ptr_t< T >::_init ( t_source *  in)
throw (
)
inlineprivate

Definition at line 59 of file service.h.

59  {
60  this->m_ptr = in;
61  if (this->m_ptr) this->m_ptr->service_add_ref();
62  }
template<typename T>
template<typename t_source >
void service_ptr_t< T >::_init ( t_source &&  in)
throw (
)
inlineprivate

Definition at line 63 of file service.h.

63  {
64  this->m_ptr = in.detach();
65  }
template<typename T>
template<typename t_source >
void service_ptr_t< T >::attach ( t_source *  p_ptr)
throw (
)
inline

Definition at line 150 of file service.h.

150  {
152  this->m_ptr = pfc::safe_ptr_cast<T>(p_ptr);
153  }
t_ret * safe_ptr_cast(t_param *p_param)
Definition: primitives.h:185
static void service_release_safe(T *p_ptr)
Definition: service.h:31
template<typename T>
template<typename t_source >
void service_ptr_t< T >::copy ( t_source *  p_ptr)
throw (
)
inline

Definition at line 79 of file service.h.

79  {
80  service_add_ref_safe(p_ptr);
82  this->m_ptr = pfc::safe_ptr_cast<T>(p_ptr);
83  }
t_ret * safe_ptr_cast(t_param *p_param)
Definition: primitives.h:185
static void service_add_ref_safe(T *p_ptr)
Definition: service.h:36
static void service_release_safe(T *p_ptr)
Definition: service.h:31
template<typename T>
template<typename t_source >
void service_ptr_t< T >::copy ( const service_ptr_base_t< t_source > &  p_source)
throw (
)
inline

Definition at line 86 of file service.h.

86 {copy(p_source.get_ptr());}
T * get_ptr() const
Definition: service.h:45
void copy(t_source *p_ptr)
Definition: service.h:79
template<typename T>
template<typename t_source >
void service_ptr_t< T >::copy ( service_ptr_t< t_source > &&  p_source)
throw (
)
inline

Definition at line 89 of file service.h.

89 {attach(p_source.detach());}
T * detach()
Definition: service.h:145
void attach(t_source *p_ptr)
Definition: service.h:150
template<typename T>
T* service_ptr_t< T >::detach ( )
throw (
)
inline

Definition at line 145 of file service.h.

145  {
146  return pfc::replace_null_t(this->m_ptr);
147  }
t_type replace_null_t(t_type &p_var)
Definition: primitives.h:688
template<typename T>
T* service_ptr_t< T >::get_ptr ( ) const
throw (
)
inline

Definition at line 117 of file service.h.

117 {return this->m_ptr;}
template<typename T>
bool service_ptr_t< T >::is_empty ( ) const
throw (
)
inline

Definition at line 120 of file service.h.

120 {return this->m_ptr == NULL;}
template<typename T>
bool service_ptr_t< T >::is_valid ( ) const
throw (
)
inline

Definition at line 119 of file service.h.

119 {return this->m_ptr != NULL;}
template<typename T>
bool service_ptr_t< T >::operator!= ( const service_ptr_base_t< T > &  p_item) const
throw (
)
inline

Definition at line 123 of file service.h.

123 {return this->m_ptr != p_item.get_ptr();}
T * get_ptr() const
Definition: service.h:45
template<typename T>
bool service_ptr_t< T >::operator!= ( T p_item) const
throw (
)
inline

Definition at line 129 of file service.h.

129 {return this->m_ptr != p_item;}
template<typename T>
template<typename otherPtr_t >
bool service_ptr_t< T >::operator&= ( otherPtr_t  other)
inline

Conditional cast operator - attempts to obtain a vaild service pointer to the expected class; returns true on success, false on failure.

Definition at line 174 of file service.h.

174  {
175  PFC_ASSERT( other.is_valid() );
176  return other->cast(*this);
177  }
template<typename T>
T& service_ptr_t< T >::operator* ( ) const
throw (
)
inline

Definition at line 155 of file service.h.

155 {return *this->m_ptr;}
template<typename T>
service_obscure_refcounting<T>* service_ptr_t< T >::operator-> ( ) const
throw (
)
inline

Definition at line 115 of file service.h.

115 {PFC_ASSERT(this->m_ptr != NULL);return service_obscure_refcounting_cast(this->m_ptr);}
static service_obscure_refcounting< T > * service_obscure_refcounting_cast(T *p_source)
Converts a service interface pointer to a pointer that obscures service counter functionality.
Definition: service.h:28
template<typename T>
bool service_ptr_t< T >::operator< ( const service_ptr_base_t< T > &  p_item) const
throw (
)
inline

Definition at line 126 of file service.h.

126 {return this->m_ptr < p_item.get_ptr();}
T * get_ptr() const
Definition: service.h:45
template<typename T>
bool service_ptr_t< T >::operator< ( T p_item) const
throw (
)
inline

Definition at line 132 of file service.h.

132 {return this->m_ptr < p_item;}
template<typename T>
template<typename t_other >
t_self& service_ptr_t< T >::operator<< ( service_ptr_t< t_other > &  p_source)
throw (
)
inline

Definition at line 135 of file service.h.

135 {attach(p_source.detach());return *this;}
T * detach()
Definition: service.h:145
void attach(t_source *p_ptr)
Definition: service.h:150
template<typename T>
const t_self& service_ptr_t< T >::operator= ( const t_self p_source)
throw (
)
inline

Definition at line 92 of file service.h.

92 {copy(p_source); return *this;}
void copy(t_source *p_ptr)
Definition: service.h:79
template<typename T>
const t_self& service_ptr_t< T >::operator= ( t_self &&  p_source)
throw (
)
inline

Definition at line 93 of file service.h.

93 {copy(std::move(p_source)); return *this;}
void copy(t_source *p_ptr)
Definition: service.h:79
template<typename T>
const t_self& service_ptr_t< T >::operator= ( T p_ptr)
throw (
)
inline

Definition at line 94 of file service.h.

94 {copy(p_ptr); return *this;}
void copy(t_source *p_ptr)
Definition: service.h:79
template<typename T>
template<typename t_source >
t_self& service_ptr_t< T >::operator= ( const service_ptr_base_t< t_source > &  p_source)
throw (
)
inline

Definition at line 96 of file service.h.

96 {copy(p_source); return *this;}
void copy(t_source *p_ptr)
Definition: service.h:79
template<typename T>
template<typename t_source >
t_self& service_ptr_t< T >::operator= ( service_ptr_t< t_source > &&  p_source)
throw (
)
inline

Definition at line 97 of file service.h.

97 {copy(std::move(p_source)); return *this;}
void copy(t_source *p_ptr)
Definition: service.h:79
template<typename T>
template<typename t_source >
t_self& service_ptr_t< T >::operator= ( t_source *  p_ptr)
throw (
)
inline

Definition at line 98 of file service.h.

98 {copy(p_ptr); return *this;}
void copy(t_source *p_ptr)
Definition: service.h:79
template<typename T>
template<typename t_source >
t_self& service_ptr_t< T >::operator= ( const service_nnptr_t< t_source > &  p_ptr)
throw (
)
inline

Definition at line 100 of file service.h.

100  {
102  t_source * ptr = p_ptr.get_ptr();
103  ptr->service_add_ref();
104  this->m_ptr = ptr;
105  return *this;
106  }
T * get_ptr() const
Definition: service.h:225
static void service_release_safe(T *p_ptr)
Definition: service.h:31
template<typename T>
bool service_ptr_t< T >::operator== ( const service_ptr_base_t< T > &  p_item) const
throw (
)
inline

Definition at line 122 of file service.h.

122 {return this->m_ptr == p_item.get_ptr();}
T * get_ptr() const
Definition: service.h:45
template<typename T>
bool service_ptr_t< T >::operator== ( T p_item) const
throw (
)
inline

Definition at line 128 of file service.h.

128 {return this->m_ptr == p_item;}
template<typename T>
bool service_ptr_t< T >::operator> ( const service_ptr_base_t< T > &  p_item) const
throw (
)
inline

Definition at line 125 of file service.h.

125 {return this->m_ptr > p_item.get_ptr();}
T * get_ptr() const
Definition: service.h:45
template<typename T>
bool service_ptr_t< T >::operator> ( T p_item) const
throw (
)
inline

Definition at line 131 of file service.h.

131 {return this->m_ptr > p_item;}
template<typename T>
template<typename t_other >
t_self& service_ptr_t< T >::operator>> ( service_ptr_t< t_other > &  p_dest)
throw (
)
inline

Definition at line 137 of file service.h.

137 {p_dest.attach(detach());return *this;}
T * detach()
Definition: service.h:145
void attach(t_source *p_ptr)
Definition: service.h:150
template<typename T>
template<typename otherPtr_t >
void service_ptr_t< T >::operator^= ( otherPtr_t  other)
inline

Forced cast operator - obtains a valid service pointer to the expected class or crashes the app if such pointer cannot be obtained.

Definition at line 167 of file service.h.

167  {
168  PFC_ASSERT( other.is_valid() );
169  if (!other->cast(*this)) uBugCheck();
170  }
PFC_NORETURN void SHARED_EXPORT uBugCheck()
template<typename T>
void service_ptr_t< T >::release ( )
throw (
)
inline

Definition at line 109 of file service.h.

109  {
111  this->m_ptr = NULL;
112  }
static void service_release_safe(T *p_ptr)
Definition: service.h:31

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