Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Attributes
icl::io::icl_openni::ReadWriteBuffer< T > Class Template Reference

This is used for concurrent writing and reading of Buffers. More...

#include <OpenNIUtils.h>

List of all members.

Public Member Functions

 ReadWriteBuffer (ReadWriteBufferHandler< T > *buffer_handler)
 Constructor creates and initializes resources.
 ~ReadWriteBuffer ()
 Destructor frees allocated memory.
T * getNextReadBuffer ()
 returns a pointer to the most recent actualized buffer.
T * getNextReadBuffer (bool omit_double_frames=false, int omit_max_wait_millis=1000, int omit_sleep_micros=1000)
 returns pointer to most recent buffer.
T * getNextWriteBuffer ()
 returns a pointer to the next write Buffer.
void setReset ()
 mark buffers to be reset on next write-access.
void switchHandler (ReadWriteBufferHandler< T > *new_handler)
 switches the handler
bool newAvailable ()
 tells whether a new ConvBuffers is available

Private Attributes

ReadWriteBufferHandler< T > * m_BufferHandler
 the handler used to create new buffers
T * m_Buffers [3]
 current objects which alternately are read and written.
bool m_ResetBuffers [3]
 a bool for every buffer telling whether it needs a reset
utils::Mutex m_Mutex
 the mutex is used for concurrent reading and writing.
int m_Write
 the object currently written to.
int m_Next
 the write object currently not written to.
int m_Read
 the object currently read from.
bool m_Avail
 tells whether an actualized object was written.

Detailed Description

template<typename T>
class icl::io::icl_openni::ReadWriteBuffer< T >

This is used for concurrent writing and reading of Buffers.

This class holds three pointers to T of which one is the currently read and the other two are alternately written to.


Constructor & Destructor Documentation

template<typename T>
icl::io::icl_openni::ReadWriteBuffer< T >::ReadWriteBuffer ( ReadWriteBufferHandler< T > *  buffer_handler) [inline]

Constructor creates and initializes resources.

template<typename T>
icl::io::icl_openni::ReadWriteBuffer< T >::~ReadWriteBuffer ( ) [inline]

Destructor frees allocated memory.


Member Function Documentation

template<typename T>
T* icl::io::icl_openni::ReadWriteBuffer< T >::getNextReadBuffer ( ) [inline]

returns a pointer to the most recent actualized buffer.

Buffer will then be marked and not overwritten till the next call to getNextReadBuffer()

template<typename T>
T* icl::io::icl_openni::ReadWriteBuffer< T >::getNextReadBuffer ( bool  omit_double_frames = false,
int  omit_max_wait_millis = 1000,
int  omit_sleep_micros = 1000 
) [inline]

returns pointer to most recent buffer.

if omit_double_frames is true, this function will call sleep for omit_sleep_millis and retry until a new buffer is available or omit_max_wait_millis is reached. when no new buffer could be returned NULL will be returned.

Parameters:
omit_double_frameswhether double frames should be omitted default value is false.
omit_max_wait_millishow long to wait for a new image before returning null.
omit_sleep_microshow long to sleep between checking for new buffer (in microseconds). will return null when no new ReadBuffer available.
template<typename T>
T* icl::io::icl_openni::ReadWriteBuffer< T >::getNextWriteBuffer ( ) [inline]

returns a pointer to the next write Buffer.

sets the returned Buffer as current writeable and marks the old writeable as new.

template<typename T>
bool icl::io::icl_openni::ReadWriteBuffer< T >::newAvailable ( ) [inline]

tells whether a new ConvBuffers is available

template<typename T>
void icl::io::icl_openni::ReadWriteBuffer< T >::setReset ( ) [inline]

mark buffers to be reset on next write-access.

template<typename T>
void icl::io::icl_openni::ReadWriteBuffer< T >::switchHandler ( ReadWriteBufferHandler< T > *  new_handler) [inline]

switches the handler


Member Data Documentation

template<typename T>
bool icl::io::icl_openni::ReadWriteBuffer< T >::m_Avail [private]

tells whether an actualized object was written.

the handler used to create new buffers

template<typename T>
T* icl::io::icl_openni::ReadWriteBuffer< T >::m_Buffers[3] [private]

current objects which alternately are read and written.

template<typename T>
utils::Mutex icl::io::icl_openni::ReadWriteBuffer< T >::m_Mutex [private]

the mutex is used for concurrent reading and writing.

template<typename T>
int icl::io::icl_openni::ReadWriteBuffer< T >::m_Next [private]

the write object currently not written to.

template<typename T>
int icl::io::icl_openni::ReadWriteBuffer< T >::m_Read [private]

the object currently read from.

template<typename T>
bool icl::io::icl_openni::ReadWriteBuffer< T >::m_ResetBuffers[3] [private]

a bool for every buffer telling whether it needs a reset

template<typename T>
int icl::io::icl_openni::ReadWriteBuffer< T >::m_Write [private]

the object currently written to.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines