Nebula
Loading...
Searching...
No Matches
IO::CachedStream Class Referenceabstract

#include <cachedstream.h>

Detailed Description

Wraps an underlying mappable stream object to avoid reopening it more than once (e.

g. httpstreams)

Inherits IO::Stream.

Inherited by IO::CachedHttpStream.

Public Member Functions

 CachedStream ()
 constructor
virtual ~CachedStream ()
 destructor
virtual bool CanRead () const
 memory streams support reading
virtual bool CanSeek () const
 memory streams support seeking
virtual bool CanBeMapped () const
 memory streams are mappable
virtual Size GetSize () const
 get the size of the stream in bytes
virtual Position GetPosition () const
 get the current position of the read/write cursor
virtual bool Open ()
 open the stream
virtual void Close ()
 close the stream
virtual Size Read (void *ptr, Size numBytes)
 directly read from the stream
virtual void Seek (Offset offset, SeekOrigin origin)
 seek in stream
virtual bool Eof () const
 return true if end-of-stream reached
virtual void * Map ()
 map for direct memory-access
virtual void * MemoryMap ()
 map for direct memory-access
virtual void Unmap ()
 unmap a mapped stream
void * GetRawPointer () const
 get a direct "raw" pointer to the data
Public Member Functions inherited from IO::Stream
 Stream ()
 constructor
virtual ~Stream ()
 destructor
void SetURI (const URI &u)
 set stream location as URI
const URIGetURI () const
 get stream URI
virtual bool CanWrite () const
 return true if the stream supports writing
virtual void SetSize (Size s)
 set a new size for the stream
void SetAccessMode (AccessMode m)
 set the access mode of the stream (default is ReadAccess)
AccessMode GetAccessMode () const
 get the access mode of the stream
void SetAccessPattern (AccessPattern p)
 set the prefered access pattern (default is Sequential)
AccessPattern GetAccessPattern () const
 get the prefered access pattern
void SetMediaType (const MediaType &t)
 set optional media type of stream content
const MediaTypeGetMediaType () const
 get optional media type
bool IsOpen () const
 return true if currently open
virtual void Write (const void *ptr, Size numBytes)
 directly write to the stream
virtual void Flush ()
 flush unsaved data
virtual void MemoryUnmap ()
 unmap memory stream
bool IsMapped () const
 return true if stream is currently mapped to memory
Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Protected Member Functions

virtual Core::Rtti const & GetParentRtti ()=0
Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)

Protected Attributes

Ptr< IO::StreamparentStream
Size size
Position position
unsigned char * buffer
Protected Attributes inherited from IO::Stream
URI uri
AccessMode accessMode
AccessPattern accessPattern
bool isOpen
bool isMapped
MediaType mediaType

Friends

class IO::StreamCache

Additional Inherited Members

Public Types inherited from IO::Stream
enum  AccessMode { ReadAccess , WriteAccess , AppendAccess , ReadWriteAccess }
 access modes More...
enum  AccessPattern { Random , Sequential }
 access prefered pattern More...
enum  SeekOrigin { Begin , Current , End }
 seek origins More...
typedef int64_t Position
 typedefs
typedef int64_t Offset
typedef int64_t Size
Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)

Constructor & Destructor Documentation

◆ CachedStream()

IO::CachedStream::CachedStream ( )

constructor

◆ ~CachedStream()

IO::CachedStream::~CachedStream ( )
virtual

destructor

Member Function Documentation

◆ CanBeMapped()

bool IO::CachedStream::CanBeMapped ( ) const
virtual

memory streams are mappable

Reimplemented from IO::Stream.

◆ CanRead()

bool IO::CachedStream::CanRead ( ) const
virtual

memory streams support reading

Reimplemented from IO::Stream.

◆ CanSeek()

bool IO::CachedStream::CanSeek ( ) const
virtual

memory streams support seeking

Reimplemented from IO::Stream.

◆ Close()

void IO::CachedStream::Close ( )
virtual

close the stream

Reimplemented from IO::Stream.

◆ Eof()

bool IO::CachedStream::Eof ( ) const
virtual

return true if end-of-stream reached

Reimplemented from IO::Stream.

◆ GetParentRtti()

virtual Core::Rtti const & IO::CachedStream::GetParentRtti ( )
protectedpure virtual

Implemented in IO::CachedHttpStream.

◆ GetPosition()

Stream::Position IO::CachedStream::GetPosition ( ) const
virtual

get the current position of the read/write cursor

Reimplemented from IO::Stream.

◆ GetRawPointer()

void * IO::CachedStream::GetRawPointer ( ) const

get a direct "raw" pointer to the data

Get a direct pointer to the raw data.

This is a convenience method and only works for memory streams.

◆ GetSize()

Stream::Size IO::CachedStream::GetSize ( ) const
virtual

get the size of the stream in bytes

Reimplemented from IO::Stream.

◆ Map()

void * IO::CachedStream::Map ( )
virtual

map for direct memory-access

Reimplemented from IO::Stream.

◆ MemoryMap()

void * IO::CachedStream::MemoryMap ( )
virtual

map for direct memory-access

Reimplemented from IO::Stream.

◆ Open()

bool IO::CachedStream::Open ( )
virtual

open the stream

Reimplemented from IO::Stream.

◆ Read()

Stream::Size IO::CachedStream::Read ( void * ptr,
Size numBytes )
virtual

directly read from the stream

Reimplemented from IO::Stream.

◆ Seek()

void IO::CachedStream::Seek ( Offset offset,
SeekOrigin origin )
virtual

seek in stream

Reimplemented from IO::Stream.

◆ Unmap()

void IO::CachedStream::Unmap ( )
virtual

unmap a mapped stream

Unmap a memory-mapped stream.

Reimplemented from IO::Stream.

◆ IO::StreamCache

friend class IO::StreamCache
friend

Member Data Documentation

◆ buffer

unsigned char* IO::CachedStream::buffer
protected

◆ parentStream

Ptr<IO::Stream> IO::CachedStream::parentStream
protected

◆ position

Position IO::CachedStream::position
protected

◆ size

Size IO::CachedStream::size
protected

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