Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cQueueRW< TYPE > Class Template Reference

#include <cQueue.h>

Inheritance diagram for Gray::cQueueRW< TYPE >:
Gray::cQueueRead< BYTE > Gray::cQueueBase Gray::cQueueDyn< BYTE > Gray::cQueueDyn< TYPE > Gray::cQueueBytes Gray::cQueueChunked< TYPE >::cQueueChunk Gray::cStreamQueue Gray::cStreamStackInp Gray::cStreamStackOut GrayLib::cThreadQueue Gray::cStreamTextReader GrayCodec::cAudioAACDec GrayCodec::cAudioMP3Dec GrayCodec::cAudioOpusDec GrayLib::cAudioADPCMDec GrayLib::cStreamBZ2Decompress GrayLib::cStreamCipherDec GrayLib::cStreamZLibDecompress Gray::cStreamStackPackets GrayCodec::cAudioAACEnc GrayCodec::cAudioMP3Enc GrayCodec::cAudioOpusEnc GrayLib::cAudioADPCMEnc GrayLib::cStreamBZ2Compress GrayLib::cStreamCipherEnc GrayLib::cStreamZLibCompress

Public Member Functions

 cQueueRW () noexcept
 
 cQueueRW (TYPE *pData, ITERATE_t iDataAlloc, ITERATE_t iReadLast, ITERATE_t iWriteLast, ITERATE_t iAutoReadCommit=0)
 
 cQueueRW (const TYPE *pData, ITERATE_t iDataMax)
 
 ~cQueueRW ()
 
void ReadCommitCheck ()
 
ITERATE_t get_AutoReadCommit () const
 
void put_AutoReadCommit (ITERATE_t iAutoReadCommit=8 *1024)
 
void put_ReadIndex (ITERATE_t iReadLo)
 
STREAM_SEEKRET_t SeekQ (STREAM_OFFSET_t iOffset, SEEK_ORIGIN_TYPE eSeekOrigin=SEEK_Set)
 
HRESULT ReadQty (TYPE *pData, ITERATE_t iDataMaxQty)
 
HRESULT ReadX (void *pData, size_t nDataSize)
 
bool isFullQ () const
 
ITERATE_t get_WriteQty () const
 
TYPEget_WritePtr () const
 
HRESULT WriteQty (const TYPE *pData, ITERATE_t iQtyMax)
 
HRESULT WriteX (const void *pData, size_t nDataSize)
 
void AdvanceWrite (ITERATE_t iCount=1)
 
- Public Member Functions inherited from Gray::cQueueRead< BYTE >
 cQueueRead (const BYTE *pData=nullptr, ITERATE_t iReadLast=0, ITERATE_t iWriteLast=0) noexcept
 
 ~cQueueRead ()
 
const BYTE * get_ReadPtr () const
 
void SetQueueRead (const BYTE *pData, ITERATE_t iReadLast=0, ITERATE_t iWriteLast=0)
 
BYTE Read1 (void)
 
HRESULT ReadPeek (BYTE *pData, ITERATE_t iDataMaxQty)
 
HRESULT ReadQty (BYTE *pData, ITERATE_t iDataMaxQty)
 
void ReadCommitNow ()
 
- Public Member Functions inherited from Gray::cQueueBase
 cQueueBase (ITERATE_t iReadLast=0, ITERATE_t iWriteLast=0) noexcept
 
void InitQ (ITERATE_t iReadLast=0, ITERATE_t iWriteLast=0) noexcept
 
bool isEmptyQ () const noexcept
 
void EmptyQ () noexcept
 
ITERATE_t get_ReadIndex () const noexcept
 
ITERATE_t get_WriteIndex () const noexcept
 
ITERATE_t get_ReadQty () const
 
void AdvanceRead (ITERATE_t iCount=1)
 
STREAM_SEEKRET_t SeekQ (STREAM_OFFSET_t iOffset, SEEK_ORIGIN_TYPE eSeekOrigin=SEEK_Set)
 

Protected Member Functions

void WriteQN (const TYPE *pData, ITERATE_t iQtyMax)
 

Protected Attributes

ITERATE_t m_iDataSizeAlloc
 The max qty we can write into m_pData. Maybe NOT exactly same as m_pData true OS allocated size? More...
 
ITERATE_t m_iAutoReadCommit
 Read data is destroyed once read more than this amount. make more room for writing. 0 = don't do this, just fail write if we run out of space. More...
 
- Protected Attributes inherited from Gray::cQueueRead< BYTE >
BYTE * m_pData
 NOT owned/managed block of memory I read from. not freed on destruct. More...
 
- Protected Attributes inherited from Gray::cQueueBase
ITERATE_t m_iReadLast
 old items removed/read from here. More...
 
ITERATE_t m_iWriteLast
 new items added/written here. end of read. More...
 

Detailed Description

template<class TYPE = BYTE>
class Gray::cQueueRW< TYPE >

Create an simple arbitrary queue of TYPE elements. can read and write.

Note
This queue does NOT wrap. Does NOT grow. Non managed memory.
This is NOT thread safe
Does NOT free memory on destruct. Use cQueueBytes for that. Does NOT auto expand buffer to hold more data if write past end.

Constructor & Destructor Documentation

◆ cQueueRW() [1/3]

template<class TYPE = BYTE>
Gray::cQueueRW< TYPE >::cQueueRW ( )
inlinenoexcept

◆ cQueueRW() [2/3]

template<class TYPE = BYTE>
Gray::cQueueRW< TYPE >::cQueueRW ( TYPE pData,
ITERATE_t  iDataAlloc,
ITERATE_t  iReadLast,
ITERATE_t  iWriteLast,
ITERATE_t  iAutoReadCommit = 0 
)
inlineexplicit

◆ cQueueRW() [3/3]

template<class TYPE = BYTE>
Gray::cQueueRW< TYPE >::cQueueRW ( const TYPE pData,
ITERATE_t  iDataMax 
)
inlineexplicit

◆ ~cQueueRW()

template<class TYPE = BYTE>
Gray::cQueueRW< TYPE >::~cQueueRW ( )
inline

Does NOT free m_pData memory.

Member Function Documentation

◆ AdvanceWrite()

template<class TYPE = BYTE>
void Gray::cQueueRW< TYPE >::AdvanceWrite ( ITERATE_t  iCount = 1)
inline

paired with GetWritePrepared

◆ get_AutoReadCommit()

template<class TYPE = BYTE>
ITERATE_t Gray::cQueueRW< TYPE >::get_AutoReadCommit ( ) const
inline

◆ get_WritePtr()

template<class TYPE = BYTE>
TYPE* Gray::cQueueRW< TYPE >::get_WritePtr ( ) const
inline

get start of data i could write directly. contiguous

◆ get_WriteQty()

template<class TYPE = BYTE>
ITERATE_t Gray::cQueueRW< TYPE >::get_WriteQty ( ) const
inline

How much space is avail for write into buffer? (given the current m_iDataSizeAlloc allocation size)

Returns
Qty of TYPE

◆ isFullQ()

template<class TYPE = BYTE>
bool Gray::cQueueRW< TYPE >::isFullQ ( ) const
inline

◆ put_AutoReadCommit()

template<class TYPE = BYTE>
void Gray::cQueueRW< TYPE >::put_AutoReadCommit ( ITERATE_t  iAutoReadCommit = 8 * 1024)
inline

For SetSeekSizeMin

  • iAutoReadCommit = the size at which we 'commit' contents and erase already read data. to make room for more writing. 0 = never do auto commit. we are reading and we may need to Seek back.

◆ put_ReadIndex()

template<class TYPE = BYTE>
void Gray::cQueueRW< TYPE >::put_ReadIndex ( ITERATE_t  iReadLo)
inline

Reset the read index back to some new place.

◆ ReadCommitCheck()

template<class TYPE = BYTE>
void Gray::cQueueRW< TYPE >::ReadCommitCheck ( )
inline

is it time to attempt to reclaim the space in the queue

Note
beware of the roll back that protocols like to do if they get a bad request/underflow. can't Seek back now ?

◆ ReadQty()

template<class TYPE = BYTE>
HRESULT Gray::cQueueRW< TYPE >::ReadQty ( TYPE pData,
ITERATE_t  iDataMaxQty 
)
inline

Just read a block. like ReadX but for TYPE

Returns
iQty i actually read.

◆ ReadX()

template<class TYPE = BYTE>
HRESULT Gray::cQueueRW< TYPE >::ReadX ( void *  pData,
size_t  nDataSize 
)
inline

bytes

◆ SeekQ()

template<class TYPE = BYTE>
STREAM_SEEKRET_t Gray::cQueueRW< TYPE >::SeekQ ( STREAM_OFFSET_t  iOffset,
SEEK_ORIGIN_TYPE  eSeekOrigin = SEEK_Set 
)
inline

move the current read start location.

  • iOffset = quantity of TYPE eSeekOrigin = SEEK_CUR, etc
    Returns
    the New position, <0=FAILED = INVALID_SET_FILE_POINTER

◆ WriteQN()

template<class TYPE = BYTE>
void Gray::cQueueRW< TYPE >::WriteQN ( const TYPE pData,
ITERATE_t  iQtyMax 
)
inlineprotected

Copy stuff into the Q ASSUME iQtyMax is safe size.

◆ WriteQty()

template<class TYPE = BYTE>
HRESULT Gray::cQueueRW< TYPE >::WriteQty ( const TYPE pData,
ITERATE_t  iQtyMax 
)
inline

add iQty * TYPE data to the q. like WriteX but for TYPE

Returns
How much can did write in to the queue, before it gets full.

◆ WriteX()

template<class TYPE = BYTE>
HRESULT Gray::cQueueRW< TYPE >::WriteX ( const void *  pData,
size_t  nDataSize 
)
inline

nDataSize = bytes NOT instances of TYPE

Member Data Documentation

◆ m_iAutoReadCommit

template<class TYPE = BYTE>
ITERATE_t Gray::cQueueRW< TYPE >::m_iAutoReadCommit
protected

Read data is destroyed once read more than this amount. make more room for writing. 0 = don't do this, just fail write if we run out of space.

◆ m_iDataSizeAlloc

template<class TYPE = BYTE>
ITERATE_t Gray::cQueueRW< TYPE >::m_iDataSizeAlloc
protected

The max qty we can write into m_pData. Maybe NOT exactly same as m_pData true OS allocated size?


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