Documentation of SFML 1.6

Warning: this page refers to an old version of SFML. Click here to switch to the latest version.
sf::ResourcePtr< T > Class Template Reference

Safe pointer to a T resource (inheriting from sf::Resource<T>), its pointer is automatically reseted when the resource is destroyed. More...

#include <Resource.hpp>

Public Member Functions

 ResourcePtr ()
 Default constructor.
 
 ResourcePtr (const T *Resource)
 Construct from a raw resource.
 
 ResourcePtr (const ResourcePtr< T > &Copy)
 Copy constructor.
 
 ~ResourcePtr ()
 Destructor.
 
ResourcePtr< T > & operator= (const ResourcePtr< T > &Other)
 Assignment operator from another ResourcePtr.
 
ResourcePtr< T > & operator= (const T *Resource)
 Assignment operator from a raw resource.
 
 operator const T * () const
 Cast operator to implicitely convert the resource pointer to its raw pointer type.
 
const T & operator* () const
 Operator * overload to return a reference to the actual resource.
 
const T * operator-> () const
 Operator -> overload to return a pointer to the actual resource.
 
void OnResourceDestroyed ()
 Function called when the observed resource is about to be destroyed.
 

Detailed Description

template<typename T>
class sf::ResourcePtr< T >

Safe pointer to a T resource (inheriting from sf::Resource<T>), its pointer is automatically reseted when the resource is destroyed.

Definition at line 116 of file Resource.hpp.

Constructor & Destructor Documentation

template<typename T>
sf::ResourcePtr< T >::ResourcePtr ( )

Default constructor.

template<typename T>
sf::ResourcePtr< T >::ResourcePtr ( const T *  Resource)

Construct from a raw resource.

Parameters
Resource: Internal resource
template<typename T>
sf::ResourcePtr< T >::ResourcePtr ( const ResourcePtr< T > &  Copy)

Copy constructor.

Parameters
Copy: Instance to copy
template<typename T>
sf::ResourcePtr< T >::~ResourcePtr ( )

Destructor.

Member Function Documentation

template<typename T>
void sf::ResourcePtr< T >::OnResourceDestroyed ( )

Function called when the observed resource is about to be destroyed.

template<typename T>
sf::ResourcePtr< T >::operator const T * ( ) const

Cast operator to implicitely convert the resource pointer to its raw pointer type.

This might be dangerous in the general case, but in this context it is safe enough to define this operator

Returns
Pointer to the actual resource
template<typename T>
const T& sf::ResourcePtr< T >::operator* ( ) const

Operator * overload to return a reference to the actual resource.

Returns
Reference to the internal resource
template<typename T>
const T* sf::ResourcePtr< T >::operator-> ( ) const

Operator -> overload to return a pointer to the actual resource.

Returns
Pointer to the internal resource
template<typename T>
ResourcePtr<T>& sf::ResourcePtr< T >::operator= ( const ResourcePtr< T > &  Other)

Assignment operator from another ResourcePtr.

Parameters
Other: Resource pointer to assign
Returns
Reference to this
template<typename T>
ResourcePtr<T>& sf::ResourcePtr< T >::operator= ( const T *  Resource)

Assignment operator from a raw resource.

Parameters
Resource: Resource to assign
Returns
Reference to this

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