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.
- Public Member Functions inherited from ucommon::stack
size_t getCount (void)
 Get number of object points currently in the stack.
bool push (ObjectProtocol *object, timeout_t timeout=0)
 Push an object into the stack by it's pointer.
bool remove (ObjectProtocol *object)
 Remove a specific object pointer for the queue.
 stack (mempager *pager=((void *) 0), size_t number=0)
 Create a stack that uses a memory pager for internally managed member objects for a specified maximum number of object pointers.
 ~stack ()
 Destroy queue.

Additional Inherited Members

- Static Public Member Functions inherited from ucommon::stack
static size_t count (stack &stack)
 Convenience function to get count of objects in the stack.
static ObjectProtocolpull (stack &stack, timeout_t timeout=0)
 Convenience function pull last object from the stack.
static bool push (stack &stack, ObjectProtocol *object, timeout_t timeout=0)
 Convenience function to push object into the stack.
static bool remove (stack &stack, ObjectProtocol *object)
 Convenience function to remove an object from the stacl.
- Static Protected Member Functions inherited from ucommon::Conditional
static void gettimeout (timeout_t timeout, struct timespec *hires)
 Convert a millisecond timeout into use for high resolution conditional timers.
static pthread_condattr_t * initializer (void)
 Support function for getting conditional attributes for realtime scheduling.
- Protected Attributes inherited from ucommon::stack
size_t limit

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.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..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: