ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MemoryMap::MmapBuffer Class Reference

Buffer whose underlying storage is from mmap. More...

#include <MemoryMap.h>

Inheritance diagram for MemoryMap::MmapBuffer:
Collaboration diagram for MemoryMap::MmapBuffer:

Public Member Functions

virtual ~MmapBuffer ()
 
virtual void resize (size_t n)
 Mmap buffers cannot be resized. More...
 
- Public Member Functions inherited from MemoryMap::ExternBuffer
virtual BufferPtr clone () const
 Create a new buffer from an existing buffer. More...
 
virtual const void * get_data_ptr () const
 Return pointer to low-level data. More...
 
virtual size_t read (void *, size_t offset, size_t nbytes) const
 Reads data from a buffer. More...
 
virtual size_t write (const void *, size_t offset, size_t nbytes)
 Writes data into a buffer. More...
 
- Public Member Functions inherited from MemoryMap::Buffer
virtual ~Buffer ()
 
virtual void save (const std::string &filename) const
 Saves data to a file. More...
 
virtual bool is_zero () const
 Returns true if the buffer's data is all zero. More...
 
virtual bool is_read_only () const
 Property indicating whether buffer is read-only. More...
 
virtual void set_read_only (bool b=true)
 Property indicating whether buffer is read-only. More...
 
void clear_read_only ()
 Property indicating whether buffer is read-only. More...
 
virtual std::string get_name () const
 Debug name for buffer. More...
 
virtual void set_name (const std::string &s)
 Debug name for buffer. More...
 
virtual size_t size () const
 Size of buffer in bytes. More...
 

Static Public Member Functions

static BufferPtr create (size_t length, int prot, int flags, int fd, off_t offset)
 Construct a new buffer from part of a file. More...
 
static BufferPtr create (const std::string &filename, int oflags, int mprot, int mflags)
 Construct a new buffer from part of a file. More...
 
- Static Public Member Functions inherited from MemoryMap::ExternBuffer
static BufferPtr create (void *data, size_t size)
 Construct from caller-supplied data. More...
 
static BufferPtr create (const void *data, size_t size)
 Construct from caller-supplied data. More...
 

Protected Member Functions

 MmapBuffer (uint8_t *data, size_t size, bool read_only)
 
- Protected Member Functions inherited from MemoryMap::ExternBuffer
 ExternBuffer (const uint8_t *data, size_t size)
 
 ExternBuffer (uint8_t *data, size_t size)
 
- Protected Member Functions inherited from MemoryMap::Buffer
 Buffer (size_t size)
 
std::string new_name ()
 

Additional Inherited Members

- Protected Attributes inherited from MemoryMap::ExternBuffer
uint8_t * p_data
 

Detailed Description

Buffer whose underlying storage is from mmap.

Definition at line 243 of file MemoryMap.h.

Constructor & Destructor Documentation

MemoryMap::MmapBuffer::~MmapBuffer ( )
virtual

Definition at line 345 of file MemoryMap.C.

MemoryMap::MmapBuffer::MmapBuffer ( uint8_t *  data,
size_t  size,
bool  read_only 
)
inlineprotected

Definition at line 262 of file MemoryMap.h.

References MemoryMap::Buffer::set_read_only().

Member Function Documentation

MemoryMap::BufferPtr MemoryMap::MmapBuffer::create ( size_t  length,
int  prot,
int  flags,
int  fd,
off_t  offset 
)
static

Construct a new buffer from part of a file.

The file is mapped into memory via mmap and unmapped when the last reference to the buffer is deleted. The arguments are the same as for mmap. A MemoryMap::Exception is thrown if the file cannot be mapped. The file is not closed after mapping.

Definition at line 337 of file MemoryMap.C.

Referenced by MemoryMap::insert_file().

MemoryMap::BufferPtr MemoryMap::MmapBuffer::create ( const std::string &  filename,
int  oflags,
int  mprot,
int  mflags 
)
static

Construct a new buffer from part of a file.

The file is opened with the flags oflags and then mapped into memory by calling mmap with the mprot and mflags arguments. The entire file is mapped. A MemoryMap::Exception is thrown if the file cannot be opened or the memory cannot be mapped. The file is closed immediately after mapping.

Definition at line 316 of file MemoryMap.C.

void MemoryMap::MmapBuffer::resize ( size_t  n)
virtual

Mmap buffers cannot be resized.

This method will abort if called.

Reimplemented from MemoryMap::ExternBuffer.

Definition at line 354 of file MemoryMap.C.


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