SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
CBinaryStream< T > Class Template Reference

Detailed Description

template<class T>
class shogun::CBinaryStream< T >

memory mapped emulation via binary streams (files)

Implements memory mapped file emulation (

See Also
CMemoryMappedFile) via standard file operations like fseek, fread etc

Definition at line 27 of file BinaryStream.h.

Inheritance diagram for CBinaryStream< T >:
Inheritance graph
[legend]

Public Member Functions

 CBinaryStream ()
 CBinaryStream (const char *fname, const char *flag="r")
 CBinaryStream (const CBinaryStream &bs)
virtual ~CBinaryStream ()
void open_stream (const char *fname, const char *flag="r")
void close_stream ()
uint64_t get_length ()
uint64_t get_size ()
char * get_line (uint64_t &len, uint64_t &offs)
int32_t get_num_lines ()
void pre_buffer (T *buffer, long index, long num) const
read_next () const
operator[] (int32_t index) const
virtual const char * get_name () const
- Public Member Functions inherited from CSGObject
 CSGObject ()
 CSGObject (const CSGObject &orig)
virtual ~CSGObject ()
virtual bool is_generic (EPrimitiveType *generic) const
template<class T >
void set_generic ()
void unset_generic ()
virtual void print_serializable (const char *prefix="")
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
void set_global_io (SGIO *io)
SGIOget_global_io ()
void set_global_parallel (Parallel *parallel)
Parallelget_global_parallel ()
void set_global_version (Version *version)
Versionget_global_version ()
SGVector< char * > get_modelsel_names ()
char * get_modsel_param_descr (const char *param_name)
index_t get_modsel_param_index (const char *param_name)

Protected Attributes

FILE * fd
uint64_t length
char * rw
char * m_fname

Additional Inherited Members

- Public Attributes inherited from CSGObject
SGIOio
Parallelparallel
Versionversion
Parameterm_parameters
Parameterm_model_selection_parameters
- Protected Member Functions inherited from CSGObject
virtual void load_serializable_pre () throw (ShogunException)
virtual void load_serializable_post () throw (ShogunException)
virtual void save_serializable_pre () throw (ShogunException)
virtual void save_serializable_post () throw (ShogunException)

Constructor & Destructor Documentation

default constructor

Definition at line 32 of file BinaryStream.h.

CBinaryStream ( const char *  fname,
const char *  flag = "r" 
)

constructor

open a file for read mode

Parameters
fnamename of file, zero terminated string
flagdetermines read or read write mode (currently only 'r' is supported)

Definition at line 47 of file BinaryStream.h.

CBinaryStream ( const CBinaryStream< T > &  bs)

copy constructor

Parameters
bsbinary stream to copy from

Definition at line 59 of file BinaryStream.h.

virtual ~CBinaryStream ( )
virtual

destructor

Definition at line 67 of file BinaryStream.h.

Member Function Documentation

void close_stream ( )

close a file stream

Definition at line 95 of file BinaryStream.h.

uint64_t get_length ( )

get the number of objects of type T cointained in the file

Returns
length of file

Definition at line 112 of file BinaryStream.h.

char* get_line ( uint64_t &  len,
uint64_t &  offs 
)

get next line from file

The returned line may be modfied in case the file was opened read/write. It is otherwise read-only.

Parameters
lenlength of line (returned via reference)
offsoffset to be passed for reading next line, should be 0 initially (returned via reference)
Returns
line (NOT ZERO TERMINATED)

Definition at line 137 of file BinaryStream.h.

virtual const char* get_name ( ) const
virtual
Returns
object name

Implements CSGObject.

Definition at line 207 of file BinaryStream.h.

int32_t get_num_lines ( )

count the number of lines in a file

Returns
number of lines

Definition at line 146 of file BinaryStream.h.

uint64_t get_size ( )

get the size of the file in bytes

Returns
size of file in bytes

Definition at line 121 of file BinaryStream.h.

void open_stream ( const char *  fname,
const char *  flag = "r" 
)

open file stream

Parameters
fnamefile name
flagflags "r" for reading etc

Definition at line 77 of file BinaryStream.h.

T operator[] ( int32_t  index) const

operator overload for file read only access

Parameters
indexindex
Returns
element at index

Definition at line 192 of file BinaryStream.h.

void pre_buffer ( T *  buffer,
long  index,
long  num 
) const

read num elements starting from index into buffer

Parameters
bufferbuffer that has to be at least num elements long
indexindex into file starting from which elements are read
numnumber of elements to be read

Definition at line 157 of file BinaryStream.h.

T read_next ( ) const

read next

Returns
next element

Definition at line 176 of file BinaryStream.h.

Member Data Documentation

FILE* fd
protected

file descriptor

Definition at line 211 of file BinaryStream.h.

uint64_t length
protected

size of file

Definition at line 213 of file BinaryStream.h.

char* m_fname
protected

fname

Definition at line 217 of file BinaryStream.h.

char* rw
protected

mode

Definition at line 215 of file BinaryStream.h.


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

SHOGUN Machine Learning Toolbox - Documentation