GENERICRW Class Reference

Base class for generic read/write data source/target. More...

#include <mi32/genericrw.h>

Inheritance diagram for GENERICRW:

Inheritance graph
FILE_RAWGENERICRW_MEMORYMISOCKET
[legend]
List of all members.

Public Types

enum  CAPABILITIES {
  CAPABILITY_None = 0x0000, CAPABILITY_Read = 0x0001, CAPABILITY_Write = 0x0002, CAPABILITY_Seek = 0x0004,
  CAPABILITY_Resize = 0x0008, CAPABILITY_Accept = 0x0010, CAPABILITY_Bind = 0x0020, CAPABILITY_NonBlocking = 0x0040,
  CAPABILITY_Size = 0x0080, CAPABILITIES_All = 0x00FF
}
enum  SEEKFROM { SEEKFROM_Beginning = 0, SEEKFROM_Current, SEEKFROM_End }

Public Member Functions

CAPABILITIES GetCapabilities () const
void * GetMappedMemory (INT64 &size, INT64 offset=0)
INT64 GetSize () const
INT64 GetSizeLimit () const
INT32 Read (void *buffer, INT32 numbytes, bool AllowPartial=false)
ERRVALUE Resize (INT64 newsize)
INT64 Seek (INT64 offset, SEEKFROM from=SEEKFROM_Beginning)
ERRVALUE SeekAndRead (INT64 offset, void *buffer, INT32 numbytes)
ERRVALUE SeekAndWrite (INT64 offset, const void *buffer, INT32 numbytes)
INT64 Tell () const
ERRVALUE Write (const void *buffer, INT32 numbytes)

Protected Member Functions

 ~GENERICRW ()

Private Member Functions

virtual CAPABILITIES v_GetCapabilities () const=0
virtual void * v_GetMappedMemory (INT64 &size, INT64 offset)
virtual INT64 v_GetSize () const=0
virtual INT64 v_GetSizeLimit () const=0
virtual INT32 v_Read (void *buffer, INT32 numbytes, bool AllowPartial)=0
virtual ERRVALUE v_Resize (INT64 newsize)=0
virtual INT64 v_Seek (INT64 offset, SEEKFROM from)=0
virtual INT64 v_Tell () const=0
virtual ERRVALUE v_Write (const void *buffer, INT32 numbytes)=0

Detailed Description

Base class for generic read/write data source/target.

Definition at line 73 of file genericrw.h.


Member Enumeration Documentation

enum GENERICRW::CAPABILITIES

Enumeration for instance capabilities.

Enumerator:
CAPABILITY_None 
CAPABILITY_Read 
CAPABILITY_Write 
CAPABILITY_Seek 
CAPABILITY_Resize 
CAPABILITY_Accept  Can accept incoming connections (Sockets implement this).
CAPABILITY_Bind  Can bind to a specific port (Sockes implement this).
CAPABILITY_NonBlocking  Can be set to have read/write return immediately if not ready.
CAPABILITY_Size  We can find the size.
CAPABILITIES_All 

Definition at line 84 of file genericrw.h.

enum GENERICRW::SEEKFROM

Enumeration for where to seek from.

Enumerator:
SEEKFROM_Beginning 
SEEKFROM_Current 
SEEKFROM_End 

Definition at line 77 of file genericrw.h.


Constructor & Destructor Documentation

GENERICRW::~GENERICRW (  )  [protected]

Destructor.


Member Function Documentation

CAPABILITIES GENERICRW::GetCapabilities (  )  const

Get instance capabilities.

Returns:
Capabilities

void* GENERICRW::GetMappedMemory ( INT64 size,
INT64  offset = 0 
)

Get memory-mapped buffer containing data.

Returns:
Pointer to mapped memory, or null if operation is not supported.
Parameters:
size  size of buffer returned
offset  offset into data

INT64 GENERICRW::GetSize (  )  const

Get current size of data.

Note, if instance does not support seeking then size returned may be less than ultimate amount of data which may be read.

Returns:
Current size or error < 0

INT64 GENERICRW::GetSizeLimit (  )  const

Get maximum possible size of data.

Returns:
Maximum possible size in bytes.

INT32 GENERICRW::Read ( void *  buffer,
INT32  numbytes,
bool  AllowPartial = false 
)

Read data into buffer.

Returns:
Number of bytes read (may be less than requested), 0 if no more available at present, -1 if end of data, < -1 if error
Parameters:
buffer  Buffer to read into
numbytes  Number of bytes to read
AllowPartial  Allow partial reads, if false will return error if less than requested number of bytes were read.

ERRVALUE GENERICRW::Resize ( INT64  newsize  ) 

Resize data.

May be used to truncate or extend the data, if used to extend, the contents beyond the old end of data and the new size are undefined.

Parameters:
newsize  New size in bytes

INT64 GENERICRW::Seek ( INT64  offset,
SEEKFROM  from = SEEKFROM_Beginning 
)

Seek to specified location.

Returns:
Offset from beginning of data, < 0 if error
Parameters:
offset  Location to seek to
from  Relative position to seek from

ERRVALUE GENERICRW::SeekAndRead ( INT64  offset,
void *  buffer,
INT32  numbytes 
)

Seek to specified position and read.

Returns:
Number of bytes read (may be less than requested), 0 if no more available at present, -1 if end of data, < -1 if error
Parameters:
offset  Offset from beginning of data stream
buffer  Buffer to contain data
numbytes  Number of bytes to read

ERRVALUE GENERICRW::SeekAndWrite ( INT64  offset,
const void *  buffer,
INT32  numbytes 
)

Seek to specified position and write.

Parameters:
offset  Offset from beginning of data stream
buffer  Buffer containing data to write
numbytes  Number of bytes to write

INT64 GENERICRW::Tell (  )  const

Return current read/write position.

Returns:
Current offset from start of data or error < 0.

virtual CAPABILITIES GENERICRW::v_GetCapabilities (  )  const [private, pure virtual]

Override to get instance capabilities.

virtual void* GENERICRW::v_GetMappedMemory ( INT64 size,
INT64  offset 
) [private, virtual]

Override to get mapped memory.

virtual INT64 GENERICRW::v_GetSize (  )  const [private, pure virtual]

Override to get data size.

virtual INT64 GENERICRW::v_GetSizeLimit (  )  const [private, pure virtual]

Override to get maximum possible data size.

virtual INT32 GENERICRW::v_Read ( void *  buffer,
INT32  numbytes,
bool  AllowPartial 
) [private, pure virtual]

Override to read data.

Returns:
Number of bytes read (may be less than requested), 0 if no more available at present, -1 if end of data, < -1 if error

virtual ERRVALUE GENERICRW::v_Resize ( INT64  newsize  )  [private, pure virtual]

Override to resize.

virtual INT64 GENERICRW::v_Seek ( INT64  offset,
SEEKFROM  from 
) [private, pure virtual]

Override to seek.

virtual INT64 GENERICRW::v_Tell (  )  const [private, pure virtual]

Override to return current position.

virtual ERRVALUE GENERICRW::v_Write ( const void *  buffer,
INT32  numbytes 
) [private, pure virtual]

Override to write data.

ERRVALUE GENERICRW::Write ( const void *  buffer,
INT32  numbytes 
)

Write data from buffer.

Parameters:
buffer  Buffer to write from
numbytes  Number of bytes to write


The documentation for this class was generated from the following file:
Generated on Thu Apr 26 04:47:08 2007 for TNTsdk by  doxygen 1.5.2