libmoost
moost::container::resource_stack< T > Class Template Reference

a resource_stack is a thread-safe collection of resources. Threads can get resources from the stack by using a scoped_resource. More...

#include <resource_stack.hpp>

List of all members.

Classes

class  scoped_resource
 Use a scoped_resource to get a resource from the resource_stack. More...

Public Types

typedef T resource_type

Public Member Functions

 resource_stack ()
 Constructs a resource.
 resource_stack (const std::string &resource_name)
void set_resource_name (const std::string &resource_name)
 Sets the name of the resource.
deprecated__ void add_resource (T *presource)
void add_resource (boost::shared_ptr< T > spresource)
size_t size ()
size_t total_size ()
 Gets the total size of the resource stack (the number of resources added via add_resource)

Private Attributes

std::stack< boost::shared_ptr
< T > > 
m_resources
boost::mutex m_mutex
boost::condition m_cond
size_t m_total_size
std::string m_resource_name

Detailed Description

template<typename T>
class moost::container::resource_stack< T >

a resource_stack is a thread-safe collection of resources. Threads can get resources from the stack by using a scoped_resource.

Definition at line 53 of file resource_stack.hpp.


Member Typedef Documentation

template<typename T>
typedef T moost::container::resource_stack< T >::resource_type

Definition at line 65 of file resource_stack.hpp.


Constructor & Destructor Documentation

template<typename T >
moost::container::resource_stack< T >::resource_stack ( )

Constructs a resource.

Definition at line 108 of file resource_stack.hpp.

template<typename T >
moost::container::resource_stack< T >::resource_stack ( const std::string &  resource_name)

Definition at line 121 of file resource_stack.hpp.


Member Function Documentation

template<typename T>
void moost::container::resource_stack< T >::add_resource ( T *  presource)

Adds a resource to the stack. IMPORTANT: this will take the ownership of the pointer!!

Definition at line 130 of file resource_stack.hpp.

Here is the caller graph for this function:

template<typename T>
void moost::container::resource_stack< T >::add_resource ( boost::shared_ptr< T >  spresource)

Definition at line 140 of file resource_stack.hpp.

template<typename T>
void moost::container::resource_stack< T >::set_resource_name ( const std::string &  resource_name) [inline]

Sets the name of the resource.

Definition at line 88 of file resource_stack.hpp.

template<typename T >
size_t moost::container::resource_stack< T >::size ( )

Gets the size of the resource stack Note that this returns the number of available resources, not the total number of resources ever added.

Definition at line 149 of file resource_stack.hpp.

template<typename T >
size_t moost::container::resource_stack< T >::total_size ( )

Gets the total size of the resource stack (the number of resources added via add_resource)

Definition at line 156 of file resource_stack.hpp.


Member Data Documentation

template<typename T>
boost::condition moost::container::resource_stack< T >::m_cond [private]

Definition at line 59 of file resource_stack.hpp.

template<typename T>
boost::mutex moost::container::resource_stack< T >::m_mutex [private]

Definition at line 58 of file resource_stack.hpp.

template<typename T>
std::string moost::container::resource_stack< T >::m_resource_name [private]

Definition at line 61 of file resource_stack.hpp.

template<typename T>
std::stack< boost::shared_ptr<T> > moost::container::resource_stack< T >::m_resources [private]

Definition at line 57 of file resource_stack.hpp.

template<typename T>
size_t moost::container::resource_stack< T >::m_total_size [private]

Definition at line 60 of file resource_stack.hpp.


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