Image Component Library (ICL)
Public Member Functions | Private Attributes | List of all members
icl::io::icl_openni::ReadWriteBuffer< T > Class Template Reference

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

#include <OpenNIUtils.h>

Public Member Functions

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

Private Attributes

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

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

◆ ReadWriteBuffer()

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

Constructor creates and initializes resources.

◆ ~ReadWriteBuffer()

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

Destructor frees allocated memory.

Member Function Documentation

◆ getNextReadBuffer() [1/2]

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()

◆ getNextReadBuffer() [2/2]

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.

◆ getNextWriteBuffer()

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.

◆ newAvailable()

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

tells whether a new ConvBuffers is available

◆ setReset()

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

mark buffers to be reset on next write-access.

◆ switchHandler()

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

switches the handler

Member Data Documentation

◆ m_Avail

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

tells whether an actualized object was written.

◆ m_BufferHandler

template<typename T>
ReadWriteBufferHandler<T>* icl::io::icl_openni::ReadWriteBuffer< T >::m_BufferHandler
private

the handler used to create new buffers

◆ m_Buffers

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

current objects which alternately are read and written.

◆ m_Mutex

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

the mutex is used for concurrent reading and writing.

◆ m_Next

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

the write object currently not written to.

◆ m_Read

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

the object currently read from.

◆ m_ResetBuffers

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

◆ m_Write

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: