MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
Public Member Functions | Data Fields
IPC::sharedFile Class Reference

A class for managing shared files. More...

#include <shared_memory.h>

Inheritance diagram for IPC::sharedFile:
IPC::sharedPage IPC::sharedPage

Public Member Functions

 sharedFile (std::string name_="", unsigned int len_=0, bool master_=false, bool autoBackoff=true)
 brief Creates a shared file More...
 
 sharedFile (std::string name_="", unsigned int len_=0, bool master_=false, bool autoBackoff=true)
 
 sharedFile (const sharedFile &rhs)
 Creates a copy of a shared page. More...
 
 sharedFile (const sharedFile &rhs)
 
 ~sharedFile ()
 Default destructor. More...
 
 ~sharedFile ()
 
void close ()
 Unmaps, closes and unlinks (if master and name is set) the shared file. More...
 
void close ()
 
void init (std::string name_, unsigned int len_, bool master_=false, bool autoBackoff=true)
 Initialize a page, de-initialize before if needed. More...
 
void init (std::string name_, unsigned int len_, bool master_=false, bool autoBackoff=true)
 
 operator bool () const
 Returns whether the shared file is valid or not. More...
 
 operator bool () const
 
bool operator< (const sharedFile &rhs) const
 
bool operator< (const sharedFile &rhs) const
 
void operator= (sharedFile &rhs)
 Assignment operator. More...
 
void operator= (sharedFile &rhs)
 
void unmap ()
 
void unmap ()
 Unmaps a shared file if allowed. More...
 

Data Fields

int handle
 The fd handle of the opened shared file. More...
 
long long int len
 The size in bytes of the opened shared file. More...
 
char * mapped
 A pointer to the payload of the file file. More...
 
bool master
 Whether this class should unlink the shared file upon deletion or not. More...
 
std::string name
 The name of the opened shared file. More...
 

Detailed Description

A class for managing shared files.

Constructor & Destructor Documentation

IPC::sharedFile::sharedFile ( std::string  name_ = "",
unsigned int  len_ = 0,
bool  master_ = false,
bool  autoBackoff = true 
)

brief Creates a shared file

Parameters
name_The name of the file to be created
len_The size to make the file
master_Whether to create or merely open the file
autoBackoffWhen only opening the file, wait for it to appear or fail
IPC::sharedFile::sharedFile ( const sharedFile rhs)

Creates a copy of a shared page.

Parameters
rhsThe page to copy
IPC::sharedFile::~sharedFile ( )

Default destructor.

IPC::sharedFile::sharedFile ( std::string  name_ = "",
unsigned int  len_ = 0,
bool  master_ = false,
bool  autoBackoff = true 
)
IPC::sharedFile::sharedFile ( const sharedFile rhs)
IPC::sharedFile::~sharedFile ( )

Member Function Documentation

void IPC::sharedFile::close ( )

Unmaps, closes and unlinks (if master and name is set) the shared file.

void IPC::sharedFile::close ( )
void IPC::sharedFile::init ( std::string  name_,
unsigned int  len_,
bool  master_ = false,
bool  autoBackoff = true 
)
void IPC::sharedFile::init ( std::string  name_,
unsigned int  len_,
bool  master_ = false,
bool  autoBackoff = true 
)

Initialize a page, de-initialize before if needed.

Parameters
name_The name of the page to be created
len_The size to make the page
master_Whether to create or merely open the page
autoBackoffWhen only opening the page, wait for it to appear or fail
Todo:
Use ACCESSPERMS instead of 0600?
IPC::sharedFile::operator bool ( ) const

Returns whether the shared file is valid or not.

IPC::sharedFile::operator bool ( ) const
bool IPC::sharedFile::operator< ( const sharedFile rhs) const
inline
bool IPC::sharedFile::operator< ( const sharedFile rhs) const
inline
void IPC::sharedFile::operator= ( sharedFile rhs)
void IPC::sharedFile::operator= ( sharedFile rhs)

Assignment operator.

void IPC::sharedFile::unmap ( )

Unmaps a shared file if allowed.

void IPC::sharedFile::unmap ( )

Field Documentation

int IPC::sharedFile::handle

The fd handle of the opened shared file.

long long int IPC::sharedFile::len

The size in bytes of the opened shared file.

char * IPC::sharedFile::mapped

A pointer to the payload of the file file.

bool IPC::sharedFile::master

Whether this class should unlink the shared file upon deletion or not.

std::string IPC::sharedFile::name

The name of the opened shared file.


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