soma-io  4.5.0
soma::DataSource Class Referenceabstract

Abstraction layer for various data sources (file, buffer, socket...). More...

#include <soma-io/datasource/datasource.h>

Inheritance diagram for soma::DataSource:
Collaboration diagram for soma::DataSource:

Public Types

enum  Mode { Read = 1, Write = 2, ReadWrite = 3 }
 
enum  IterateMode { DirectAccess = 1, SequentialAccess = 2 }
 

Public Member Functions

 DataSource ()
 
virtual ~DataSource ()
 
int mode () const
 access mode(s) (read/write): bitwise OR of Mode values More...
 
virtual DataSourceclone () const =0
 
virtual int iterateMode () const =0
 possible iteration mode(s): bitwise OR of IterateMode values More...
 
virtual bool isOpen () const =0
 
virtual bool eof () const
 
virtual bool operator! () const
 
virtual operator bool () const
 
virtual bool open (int mode)=0
 
virtual void close ()=0
 
virtual void flush ()
 
virtual offset_t size () const =0
 
virtual offset_t at () const =0
 
virtual bool at (offset_t pos)=0
 
virtual bool atEnd () const
 
bool reset ()
 
virtual long readBlock (char *data, unsigned long maxlen)=0
 
virtual long writeBlock (const char *data, unsigned long len)=0
 
virtual int getch ()=0
 
virtual int putch (int ch)=0
 
virtual bool ungetch (int ch)=0
 
virtual bool allowsMemoryMapping () const =0
 
virtual std::string url () const
 

Static Public Member Functions

static const carto::rc_ptr
< DataSource
none ()
 An empty ref-counter that is more convenient than calling a constructor of rc_ptr<DataSource> (useful when calling functions) More...
 

Protected Attributes

int _mode
 

Detailed Description

Abstraction layer for various data sources (file, buffer, socket...).

It can be seen as a stream, and is inspired by the QIODevice of Trolltech's Qt library (http://doc.trolltech.com/3.3/qiodevice.html)

Todo:
readBlock() and writeBlock() should use pointers of type void* instead of char*, because the type of contained objects is not specified. This would remove the need to reinterpret_cast, which is prone to error.

Definition at line 64 of file datasource.h.

Member Enumeration Documentation

Enumerator
DirectAccess 
SequentialAccess 

Definition at line 74 of file datasource.h.

Enumerator
Read 
Write 
ReadWrite 

Definition at line 67 of file datasource.h.

Constructor & Destructor Documentation

soma::DataSource::DataSource ( )
virtual soma::DataSource::~DataSource ( )
virtual

Member Function Documentation

virtual bool soma::DataSource::atEnd ( ) const
virtual
virtual bool soma::DataSource::eof ( ) const
virtual
virtual void soma::DataSource::flush ( )
virtual
virtual int soma::DataSource::iterateMode ( ) const
pure virtual
int soma::DataSource::mode ( ) const

access mode(s) (read/write): bitwise OR of Mode values

static const carto::rc_ptr<DataSource> soma::DataSource::none ( )
static

An empty ref-counter that is more convenient than calling a constructor of rc_ptr<DataSource> (useful when calling functions)

Referenced by soma::Reader< T >::dataSource().

virtual soma::DataSource::operator bool ( ) const
virtual
virtual bool soma::DataSource::operator! ( ) const
virtual
bool soma::DataSource::reset ( )

Member Data Documentation

int soma::DataSource::_mode
protected

Definition at line 113 of file datasource.h.


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