OGRE  1.9.0
Ogre::StaticCache< cacheSize > Class Template Reference

Template version of cache based on static array. More...

#include <OgreDataStream.h>

Public Member Functions

 StaticCache ()
 Constructor.
 
size_t avail () const
 Returns number of bytes available for reading in cache after rewinding.
 
size_t cacheData (const void *buf, size_t count)
 Cache data pointed by 'buf'.
 
void clear ()
 Clear the cache.
 
bool ff (size_t count)
 Step forward in cached stream by 'count' bytes.
 
size_t read (void *buf, size_t count)
 Read data from cache to 'buf' (maximum 'count' bytes).
 
bool rewind (size_t count)
 Step back in cached stream by 'count' bytes.
 

Protected Attributes

char mBuffer [cacheSize]
 Static buffer.
 
size_t mPos
 Current read position.
 
size_t mValidBytes
 Number of bytes valid in cache (written from the beginning of static buffer)
 

Detailed Description

template<size_t cacheSize>
class Ogre::StaticCache< cacheSize >

Template version of cache based on static array.

'cacheSize' defines size of cache in bytes.

Definition at line 42 of file OgreDataStream.h.

Constructor & Destructor Documentation

◆ StaticCache()

template<size_t cacheSize>
Ogre::StaticCache< cacheSize >::StaticCache ( )

Constructor.

Definition at line 55 of file OgreDataStream.h.

References mPos, and mValidBytes.

Member Function Documentation

◆ avail()

template<size_t cacheSize>
size_t Ogre::StaticCache< cacheSize >::avail ( ) const

Returns number of bytes available for reading in cache after rewinding.

Definition at line 136 of file OgreDataStream.h.

References mPos, and mValidBytes.

Referenced by cacheData(), ff(), and read().

◆ cacheData()

template<size_t cacheSize>
size_t Ogre::StaticCache< cacheSize >::cacheData ( const void * buf,
size_t count )

Cache data pointed by 'buf'.

If 'count' is greater than cache size, we cache only last bytes. Returns number of bytes written to cache.

Definition at line 63 of file OgreDataStream.h.

References avail(), mBuffer, mPos, and mValidBytes.

◆ clear()

template<size_t cacheSize>
void Ogre::StaticCache< cacheSize >::clear ( )

Clear the cache.

Definition at line 142 of file OgreDataStream.h.

References mPos, and mValidBytes.

Referenced by ff(), and rewind().

◆ ff()

template<size_t cacheSize>
bool Ogre::StaticCache< cacheSize >::ff ( size_t count)

Step forward in cached stream by 'count' bytes.

Returns 'true' if cache contains resulting position.

Definition at line 121 of file OgreDataStream.h.

References avail(), clear(), and mPos.

◆ read()

template<size_t cacheSize>
size_t Ogre::StaticCache< cacheSize >::read ( void * buf,
size_t count )

Read data from cache to 'buf' (maximum 'count' bytes).

Returns number of bytes read from cache.

Definition at line 97 of file OgreDataStream.h.

References avail(), mBuffer, and mPos.

◆ rewind()

template<size_t cacheSize>
bool Ogre::StaticCache< cacheSize >::rewind ( size_t count)

Step back in cached stream by 'count' bytes.

Returns 'true' if cache contains resulting position.

Definition at line 107 of file OgreDataStream.h.

References clear(), and mPos.

Member Data Documentation

◆ mBuffer

template<size_t cacheSize>
char Ogre::StaticCache< cacheSize >::mBuffer[cacheSize]
protected

Static buffer.

Definition at line 46 of file OgreDataStream.h.

Referenced by cacheData(), and read().

◆ mPos

template<size_t cacheSize>
size_t Ogre::StaticCache< cacheSize >::mPos
protected

Current read position.

Definition at line 51 of file OgreDataStream.h.

Referenced by StaticCache(), avail(), cacheData(), clear(), ff(), read(), and rewind().

◆ mValidBytes

template<size_t cacheSize>
size_t Ogre::StaticCache< cacheSize >::mValidBytes
protected

Number of bytes valid in cache (written from the beginning of static buffer)

Definition at line 49 of file OgreDataStream.h.

Referenced by StaticCache(), avail(), cacheData(), and clear().


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