Public Member Functions | Static Private Member Functions | Private Attributes | Related Functions
vil_smart_ptr< T > Class Template Reference

A templated smart pointer class. More...

#include <vil_smart_ptr.h>

Inheritance diagram for vil_smart_ptr< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 vil_smart_ptr ()
 vil_smart_ptr (vil_smart_ptr< T > const &p)
 vil_smart_ptr (T *p)
 ~vil_smart_ptr ()
vil_smart_ptr< T > & operator= (vil_smart_ptr< T > const &r)
 Assignment.
vil_smart_ptr< T > & operator= (T *r)
 operator safe_bool () const
 Cast to bool.
bool operator! () const
 Inverse bool.
T & operator* () const
 Dereferencing the pointer.
T * operator-> () const
 These methods all return the raw/dumb pointer.
T * ptr () const
 These methods all return the raw/dumb pointer.
T * as_pointer () const
 These methods all return the raw/dumb pointer.
bool operator== (T const *p) const
 Do a shallow equality.
bool operator!= (T const *p) const
 Do a shallow inequality.
bool operator== (vil_smart_ptr< T >const &p) const
 Do a shallow equality.
bool operator!= (vil_smart_ptr< T >const &p) const
 Do a shallow inequality.
bool operator< (vil_smart_ptr< T >const &p) const
bool operator> (vil_smart_ptr< T >const &p) const
bool operator<= (vil_smart_ptr< T >const &p) const
bool operator>= (vil_smart_ptr< T >const &p) const

Static Private Member Functions

static void ref (T *p)
static void unref (T *p)

Private Attributes

 VCL_SAFE_BOOL_DEFINE
T * ptr_
 Pointer to object, or 0.

Related Functions

(Note that these are not member functions.)

template<class T >
void vsl_b_write (vsl_b_ostream &os, const vil_smart_ptr< T > &v)
 Binary save vil_smart_ptr to stream.
template<class T >
void vsl_b_read (vsl_b_istream &is, vil_smart_ptr< T > &v)
 Binary load vil_smart_ptr from stream.
template<class T >
void vsl_print_summary (vcl_ostream &os, const vil_smart_ptr< T > &b)
 Print human readable summary of object to a stream.

Detailed Description

template<class T>
class vil_smart_ptr< T >

A templated smart pointer class.

This class requires that the class being templated over has the following signatures (methods) :

   void T::ref();
   void T::unref();

See also vbl_ref_count

Definition at line 34 of file vil_smart_ptr.h.


Constructor & Destructor Documentation

template<class T>
vil_smart_ptr< T >::vil_smart_ptr ( ) [inline]

Definition at line 38 of file vil_smart_ptr.h.

template<class T>
vil_smart_ptr< T >::vil_smart_ptr ( vil_smart_ptr< T > const &  p) [inline]

Definition at line 41 of file vil_smart_ptr.h.

template<class T>
vil_smart_ptr< T >::vil_smart_ptr ( T *  p) [inline]

Definition at line 44 of file vil_smart_ptr.h.

template<class T>
vil_smart_ptr< T >::~vil_smart_ptr ( ) [inline]

Definition at line 47 of file vil_smart_ptr.h.


Member Function Documentation

template<class T>
T* vil_smart_ptr< T >::as_pointer ( ) const [inline]

These methods all return the raw/dumb pointer.

WARNING : Do not add an automatic cast to T*. This is intrinsically incorrect as you loose the smartness! In cases where you really need the pointer, it is better to be explicit about it and use one of the methods.

Definition at line 107 of file vil_smart_ptr.h.

template<class T>
vil_smart_ptr< T >::operator safe_bool ( ) const [inline]

Cast to bool.

Definition at line 85 of file vil_smart_ptr.h.

template<class T>
bool vil_smart_ptr< T >::operator! ( ) const [inline]

Inverse bool.

Definition at line 89 of file vil_smart_ptr.h.

template<class T>
bool vil_smart_ptr< T >::operator!= ( T const *  p) const [inline]

Do a shallow inequality.

Do the smart pointers not point to the same object.

Definition at line 118 of file vil_smart_ptr.h.

template<class T>
bool vil_smart_ptr< T >::operator!= ( vil_smart_ptr< T >const &  p) const [inline]

Do a shallow inequality.

Do the smart pointers not point to the same object.

Definition at line 126 of file vil_smart_ptr.h.

template<class T>
T& vil_smart_ptr< T >::operator* ( ) const [inline]

Dereferencing the pointer.

Definition at line 93 of file vil_smart_ptr.h.

template<class T>
T* vil_smart_ptr< T >::operator-> ( ) const [inline]

These methods all return the raw/dumb pointer.

Definition at line 96 of file vil_smart_ptr.h.

template<class T>
bool vil_smart_ptr< T >::operator< ( vil_smart_ptr< T >const &  p) const [inline]

Definition at line 127 of file vil_smart_ptr.h.

template<class T>
bool vil_smart_ptr< T >::operator<= ( vil_smart_ptr< T >const &  p) const [inline]

Definition at line 129 of file vil_smart_ptr.h.

template<class T>
vil_smart_ptr<T>& vil_smart_ptr< T >::operator= ( vil_smart_ptr< T > const &  r) [inline]

Assignment.

Definition at line 58 of file vil_smart_ptr.h.

template<class T>
vil_smart_ptr<T>& vil_smart_ptr< T >::operator= ( T *  r) [inline]

Definition at line 63 of file vil_smart_ptr.h.

template<class T>
bool vil_smart_ptr< T >::operator== ( T const *  p) const [inline]

Do a shallow equality.

Do they point to the same object.

Definition at line 114 of file vil_smart_ptr.h.

template<class T>
bool vil_smart_ptr< T >::operator== ( vil_smart_ptr< T >const &  p) const [inline]

Do a shallow equality.

Do they point to the same object.

Definition at line 122 of file vil_smart_ptr.h.

template<class T>
bool vil_smart_ptr< T >::operator> ( vil_smart_ptr< T >const &  p) const [inline]

Definition at line 128 of file vil_smart_ptr.h.

template<class T>
bool vil_smart_ptr< T >::operator>= ( vil_smart_ptr< T >const &  p) const [inline]

Definition at line 130 of file vil_smart_ptr.h.

template<class T>
T* vil_smart_ptr< T >::ptr ( ) const [inline]

These methods all return the raw/dumb pointer.

Definition at line 99 of file vil_smart_ptr.h.

template<class T>
void vil_smart_ptr< T >::ref ( T *  p) [static, private]

Definition at line 12 of file vil_smart_ptr.txx.

template<class T>
void vil_smart_ptr< T >::unref ( T *  p) [static, private]

Definition at line 19 of file vil_smart_ptr.txx.


Friends And Related Function Documentation

template<class T >
void vsl_b_read ( vsl_b_istream &  is,
vil_smart_ptr< T > &  v 
) [related]

Binary load vil_smart_ptr from stream.

template<class T >
void vsl_b_write ( vsl_b_ostream &  os,
const vil_smart_ptr< T > &  v 
) [related]

Binary save vil_smart_ptr to stream.

template<class T >
void vsl_print_summary ( vcl_ostream &  os,
const vil_smart_ptr< T > &  b 
) [related]

Print human readable summary of object to a stream.


Member Data Documentation

template<class T>
T* vil_smart_ptr< T >::ptr_ [private]

Pointer to object, or 0.

Definition at line 141 of file vil_smart_ptr.h.

template<class T>
vil_smart_ptr< T >::VCL_SAFE_BOOL_DEFINE [private]

Definition at line 36 of file vil_smart_ptr.h.


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