Public Member Functions | Static Private Member Functions | Private Attributes | Related Functions | List of all members
vil_smart_ptr< T > Class Template Reference

A templated smart pointer class. More...

#include <vil_fwd.h>

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

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

T * ptr_
 Pointer to object, or 0. More...
 

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. More...
 
template<class T >
void vsl_b_read (vsl_b_istream &is, vil_smart_ptr< T > &v)
 Binary load vil_smart_ptr from stream. More...
 
template<class T >
void vsl_print_summary (std::ostream &os, const vil_smart_ptr< T > &b)
 Print human readable summary of object to a stream. More...
 

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 16 of file vil_fwd.h.

Constructor & Destructor Documentation

◆ vil_smart_ptr() [1/3]

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

Definition at line 41 of file vil_smart_ptr.h.

◆ vil_smart_ptr() [2/3]

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

Definition at line 44 of file vil_smart_ptr.h.

◆ vil_smart_ptr() [3/3]

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

Definition at line 47 of file vil_smart_ptr.h.

◆ ~vil_smart_ptr()

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

Definition at line 50 of file vil_smart_ptr.h.

Member Function Documentation

◆ as_pointer()

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 110 of file vil_smart_ptr.h.

◆ operator *()

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

Dereferencing the pointer.

Definition at line 96 of file vil_smart_ptr.h.

◆ operator ->()

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

These methods all return the raw/dumb pointer.

Definition at line 99 of file vil_smart_ptr.h.

◆ operator bool()

template<class T>
vil_smart_ptr< T >::operator bool ( ) const
inlineexplicit

Cast to bool.

Definition at line 88 of file vil_smart_ptr.h.

◆ operator!()

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

Inverse bool.

Definition at line 92 of file vil_smart_ptr.h.

◆ operator!=() [1/2]

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 121 of file vil_smart_ptr.h.

◆ operator!=() [2/2]

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 129 of file vil_smart_ptr.h.

◆ operator<()

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.

◆ operator<=()

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

Definition at line 132 of file vil_smart_ptr.h.

◆ operator=() [1/2]

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

Assignment.

Definition at line 61 of file vil_smart_ptr.h.

◆ operator=() [2/2]

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

Definition at line 66 of file vil_smart_ptr.h.

◆ operator==() [1/2]

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 117 of file vil_smart_ptr.h.

◆ operator==() [2/2]

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 125 of file vil_smart_ptr.h.

◆ operator>()

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

Definition at line 131 of file vil_smart_ptr.h.

◆ operator>=()

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

Definition at line 133 of file vil_smart_ptr.h.

◆ ptr()

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

These methods all return the raw/dumb pointer.

Definition at line 102 of file vil_smart_ptr.h.

◆ ref()

template<class T>
void vil_smart_ptr< T >::ref ( T *  p)
staticprivate

Definition at line 15 of file vil_smart_ptr.hxx.

◆ unref()

template<class T>
void vil_smart_ptr< T >::unref ( T *  p)
staticprivate

Definition at line 22 of file vil_smart_ptr.hxx.

Friends And Related Function Documentation

◆ vsl_b_read()

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

Binary load vil_smart_ptr from stream.

◆ vsl_b_write()

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.

◆ vsl_print_summary()

template<class T >
void vsl_print_summary ( std::ostream &  os,
const vil_smart_ptr< T > &  b 
)
related

Print human readable summary of object to a stream.

Member Data Documentation

◆ ptr_

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

Pointer to object, or 0.

Definition at line 144 of file vil_smart_ptr.h.


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