version 3.3

VRS::FileDataResource Class Reference

Class for mapping file contents to memory. More...

#include <vrs/io/filedataresource.h>

Inheritance diagram for VRS::FileDataResource:

VRS::DataResource VRS::SharedObj VRS::Visitable

List of all members.

Public Member Functions

 FileDataResource (const std::string &filename, bool isWritable=false)
 FileDataResource (const std::string &filename, unsigned int size, bool persistent=true)
virtual ~FileDataResource ()
const std::string & filename () const
 Return the filename of the mapped file.
virtual void * pointer () const
virtual unsigned int size () const
 Return the size of mapped bytes.
virtual bool isWritable () const
 Data resources can be writable, otherwise are read-only.
 VRS_TYPEINFO (FileDataResource, DataResource)
 VRS_SERIALIZABLE (FileDataResource)

Protected Member Functions

 FileDataResource ()


Detailed Description

Class for mapping file contents to memory.

Constructor & Destructor Documentation

VRS::FileDataResource::FileDataResource ( const std::string &  filename,
bool  isWritable = false 
)

Open the file 'filename' in read-only or read-write-modus (depending on 'isWritable'). If the read-write-modus is chosen all modifications to the data are persistent! If the file cannot be opened, an IOError exception is thrown.

VRS::FileDataResource::FileDataResource ( const std::string &  filename,
unsigned int  size,
bool  persistent = true 
)

Create a file 'filename' of given 'size' and open it in read-write-modus. If 'persistent' is set to 'false' the file will be deleted when the FileDataResource object is destroyed!

virtual VRS::FileDataResource::~FileDataResource (  )  [virtual]

VRS::FileDataResource::FileDataResource (  )  [protected]


Member Function Documentation

const std::string& VRS::FileDataResource::filename (  )  const

Return the filename of the mapped file.

virtual void* VRS::FileDataResource::pointer (  )  const [virtual]

Return the start address of the mapped file contents. The file contents are mapped to the addresses [pointer(), ..., pointer() + size() - 1]. You can access these memory locations as every other "normal" memory location (e.g. using memcpy, memset, ...). But for writing to these addresses the object must be opened in read-write-mode! (If not, you get a seg fault!)

Implements VRS::DataResource.

virtual unsigned int VRS::FileDataResource::size (  )  const [virtual]

Return the size of mapped bytes.

Implements VRS::DataResource.

virtual bool VRS::FileDataResource::isWritable (  )  const [virtual]

Data resources can be writable, otherwise are read-only.

Implements VRS::DataResource.

VRS::FileDataResource::VRS_TYPEINFO ( FileDataResource  ,
DataResource   
)

VRS::FileDataResource::VRS_SERIALIZABLE ( FileDataResource   ) 


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

Generated on Mon May 21 06:00:19 2012 by Doxygen 1.5.6
© 2001-2010 Hasso-Plattner-Institut | Impressum | Contact