Back to index

libsfml  1.6+dfsg2
Protected Member Functions | Private Member Functions | Private Attributes | Friends
sf::Resource< T > Class Template Reference

Base class for every resource that needs to notify dependent classes about its destruction /////////////////////////////////////////////////////////. More...

#include <Resource.hpp>

Inheritance diagram for sf::Resource< T >:
Inheritance graph
[legend]
Collaboration diagram for sf::Resource< T >:
Collaboration graph
[legend]

List of all members.

Protected Member Functions

 Resource ()
 Default constructor.
 Resource (const Resource< T > &Copy)
 Copy constructor.
 ~Resource ()
 Destructor.
Resource< T > & operator= (const Resource< T > &Other)
 Assignment operator.

Private Member Functions

void Connect (ResourcePtr< T > &Observer) const
 Connect a ResourcePtr to this resource.
void Disconnect (ResourcePtr< T > &Observer) const
 Disconnect a ResourcePtr from this resource.

Private Attributes

std::set< ResourcePtr< T > * > myObservers

Friends

class ResourcePtr< T >

Detailed Description

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

Base class for every resource that needs to notify dependent classes about its destruction /////////////////////////////////////////////////////////.

Definition at line 50 of file Resource.hpp.


Constructor & Destructor Documentation

template<typename T>
Resource::Resource ( ) [protected]

Default constructor.

Default constructor /////////////////////////////////////////////////////////.

/////////////////////////////////////////////////////////

Definition at line 30 of file Resource.inl.

{
    // Nothing to do
}
template<typename T>
sf::Resource< T >::Resource ( const Resource< T > &  Copy) [protected]

Copy constructor.

Parameters:
Copy: Resource to copy

/////////////////////////////////////////////////////////

template<typename T>
Resource::~Resource ( ) [protected]

Destructor.

Destructor /////////////////////////////////////////////////////////.

/////////////////////////////////////////////////////////

Definition at line 50 of file Resource.inl.

{
    // Notify all observers
    for (typename std::set<ResourcePtr<T>*>::iterator i = myObservers.begin(); i != myObservers.end(); ++i)
    {
        (*i)->OnResourceDestroyed();
    }
}

Member Function Documentation

template<typename T>
void Resource::Connect ( ResourcePtr< T > &  Observer) const [private]

Connect a ResourcePtr to this resource.

Connect a ResourcePtr to this resource /////////////////////////////////////////////////////////.

Parameters:
Observer: Observer to add

/////////////////////////////////////////////////////////

Definition at line 75 of file Resource.inl.

{
    myObservers.insert(&Observer);
}
template<typename T>
void Resource::Disconnect ( ResourcePtr< T > &  Observer) const [private]

Disconnect a ResourcePtr from this resource.

Disconnect a ResourcePtr from this resource /////////////////////////////////////////////////////////.

Parameters:
Observer: Observer to remove

/////////////////////////////////////////////////////////

Definition at line 85 of file Resource.inl.

{
    myObservers.erase(&Observer);
}
template<typename T>
Resource< T > & Resource::operator= ( const Resource< T > &  Other) [protected]

Assignment operator.

Assignment operator /////////////////////////////////////////////////////////.

Parameters:
Other: Resource to copy
Returns:
Reference to this

/////////////////////////////////////////////////////////

Definition at line 64 of file Resource.inl.

{
    // Nothing to do, we don't want to copy observers
    return *this;
}

Friends And Related Function Documentation

template<typename T>
friend class ResourcePtr< T > [friend]

Definition at line 86 of file Resource.hpp.


Member Data Documentation

template<typename T>
std::set<ResourcePtr<T>*> sf::Resource< T >::myObservers [mutable, private]

Definition at line 107 of file Resource.hpp.


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