UCommon
Public Member Functions
ucommon::stackof< T > Class Template Reference

A templated typed class for thread-safe stack of object pointers. More...

#include <containers.h>

Inheritance diagram for ucommon::stackof< T >:
Inheritance graph
[legend]
Collaboration diagram for ucommon::stackof< T >:
Collaboration graph
[legend]

Public Member Functions

T * operator[] (unsigned offset)
 Examine past item in the stack.
T * peek (unsigned offset=0)
 Examine past item in the stack.
T * pull (timeout_t timeout=0)
 Get and remove last typed object posted to the stack.
bool push (T *object, timeout_t timeout=0)
 Push a typed object into the stack by it's pointer.
bool remove (T *object)
 Remove a specific typed object pointer for the stack.
 stackof (mempager *memory, size_t size=0)
 Create templated stack of typed objects.

Detailed Description

template<class T>
class ucommon::stackof< T >

A templated typed class for thread-safe stack of object pointers.

This allows one to use the stack class in a typesafe manner for a specific object type derived from Object rather than generically for any derived object class.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 600 of file containers.h.


Constructor & Destructor Documentation

template<class T >
ucommon::stackof< T >::stackof ( mempager memory,
size_t  size = 0 
) [inline]

Create templated stack of typed objects.

Parameters:
memorypool for internal use of stack.
sizeof stack to construct. Uses 0 if no size limit.

Definition at line 608 of file containers.h.


Member Function Documentation

template<class T >
T* ucommon::stackof< T >::operator[] ( unsigned  offset) [inline]

Examine past item in the stack.

This is a typecast of the peek operation.

Parameters:
offsetin stack.
Returns:
item pointer if valid or NULL.

Reimplemented from ucommon::stack.

Definition at line 656 of file containers.h.

template<class T >
T* ucommon::stackof< T >::peek ( unsigned  offset = 0) [inline]

Examine past item in the stack.

This is a typecast of the peek operation.

Parameters:
offsetin stack.
Returns:
item pointer if valid or NULL.

Reimplemented from ucommon::stack.

Definition at line 647 of file containers.h.

template<class T >
T* ucommon::stackof< T >::pull ( timeout_t  timeout = 0) [inline]

Get and remove last typed object posted to the stack.

This can wait for a specified timeout of the stack is empty. The object is still retained and must be released or deleted by the receiving function.

Parameters:
timeoutto wait if empty in milliseconds.
Returns:
object from queue or NULL if empty and timed out.

Reimplemented from ucommon::stack.

Definition at line 638 of file containers.h.

Here is the call graph for this function:

template<class T >
bool ucommon::stackof< T >::push ( T *  object,
timeout_t  timeout = 0 
) [inline]

Push a typed object into the stack by it's pointer.

This can wait for a specified timeout if the queue is full, for example, for another thread to remove an object pointer. This retains the object.

Parameters:
objectto push.
timeoutto wait if queue is full in milliseconds.
Returns:
true if object pushed, false if queue full and timeout expired.

Definition at line 628 of file containers.h.

Here is the call graph for this function:

template<class T >
bool ucommon::stackof< T >::remove ( T *  object) [inline]

Remove a specific typed object pointer for the stack.

This can remove a member from any location in the stack, whether beginning, end, or somewhere in the middle. This releases the object.

Parameters:
objectto remove.
Returns:
true if object was removed, false if not found.

Definition at line 617 of file containers.h.

Here is the call graph for this function:


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