Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::win::FileMapper Class Reference

Class wrapper around the Windows 32-bit file mapping functions which allow memory allocation using the page file for controlled swapping. This is especially useful for managing huge memory blocks. More...

#include <FileMapper.h>

Inheritance diagram for sf::win::FileMapper:
Collaboration diagram for sf::win::FileMapper:

Public Member Functions

 FileMapper ()
 
 ~FileMapper () override
 
bool createMapFile (const char *filename)
 
void initialize () override
 
void createView (size_t sz) override
 
bool closeFile ()
 
bool isFileOpen () const
 
bool createMap (const char *map_name, size_t map_size, bool unique, bool readonly)
 
bool openMap (const char *map_name, unsigned long map_size, bool readonly=true)
 
bool closeMap ()
 
bool isMapOpen () const
 
bool mapView () override
 
bool unmapView () override
 
bool flushView ()
 
std::string getFileName () const
 
std::string getMapName () const
 
size_t getMapSize () const
 
void * getPtr () override
 
const void * getPtr () const
 
 FileMapper (const FileMapper &)=delete
 
FileMapperoperator= (const FileMapper &)=delete
 
- Public Member Functions inherited from sf::IFileMapper
 IFileMapper ()=default
 Default constructor.
 
virtual ~IFileMapper ()=default
 Virtual destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from sf::IFileMapper
static IFileMapperinstantiate (bool native)
 Gets an instance of this interface using a native or non-native (Qt) implementation.
 

Detailed Description

Class wrapper around the Windows 32-bit file mapping functions which allow memory allocation using the page file for controlled swapping. This is especially useful for managing huge memory blocks.

Constructor & Destructor Documentation

◆ FileMapper() [1/2]

sf::win::FileMapper::FileMapper ( )

Default constructor

◆ ~FileMapper()

sf::win::FileMapper::~FileMapper ( )
override

Destructor

◆ FileMapper() [2/2]

sf::win::FileMapper::FileMapper ( const FileMapper )
delete

Deleted copy constructor to prevent copying.

Member Function Documentation

◆ closeFile()

bool sf::win::FileMapper::closeFile ( )

Closes the opened file handle by 'createMapFile'.

Returns
True on success.

◆ closeMap()

bool sf::win::FileMapper::closeMap ( )

Closes the map handle created by calling CreateMap or OpenMap.

Returns

◆ createMap()

bool sf::win::FileMapper::createMap ( const char *  map_name,
size_t  map_size,
bool  unique,
bool  readonly 
)

Called by a data server to create a named file map. When 'unique' is true there is no other map named as 'map_name' before calling this function.

Parameters
map_name
map_size
unique
readonly
Returns

◆ createMapFile()

bool sf::win::FileMapper::createMapFile ( const char *  filename)

Makes this instance use the passed file

Parameters
filename
Returns
True on success.

◆ createView()

void sf::win::FileMapper::createView ( size_t  sz)
overridevirtual

Sets the part of the file to be mapped. Calls createMap

Implements sf::IFileMapper.

◆ flushView()

bool sf::win::FileMapper::flushView ( )

Writes to the disk a byte range within a mapped view of the file.

Returns
True on success.

◆ getFileName()

std::string sf::win::FileMapper::getFileName ( ) const

Returns the file name when 'CreateMapFile' was called.

Returns

◆ getMapName()

std::string sf::win::FileMapper::getMapName ( ) const

Returns the map name when 'CreateMap' was called.

Returns

◆ getMapSize()

size_t sf::win::FileMapper::getMapSize ( ) const

Returns the size of the map.

Returns

◆ getPtr() [1/2]

const void * sf::win::FileMapper::getPtr ( ) const

Returns a pointer to the data if MapView is called.

Returns
Const Pointer

◆ getPtr() [2/2]

void * sf::win::FileMapper::getPtr ( )
overridevirtual

Returns a pointer to the data if MapView is called.

Returns
Pointer

Implements sf::IFileMapper.

◆ initialize()

void sf::win::FileMapper::initialize ( )
overridevirtual

Makes this instance create a map that is backed by the systems page file.

Returns

Implements sf::IFileMapper.

◆ isFileOpen()

bool sf::win::FileMapper::isFileOpen ( ) const

Returns true if a map file is open. (pagefile or not.)

Returns
True when open.

◆ isMapOpen()

bool sf::win::FileMapper::isMapOpen ( ) const

Returns true if the file map is open.

Returns
When open True.

◆ mapView()

bool sf::win::FileMapper::mapView ( )
overridevirtual

Called by a server and client to gain access of the map.

Returns
True on success.

Implements sf::IFileMapper.

◆ openMap()

bool sf::win::FileMapper::openMap ( const char *  map_name,
unsigned long  map_size,
bool  readonly = true 
)

Called by a data client to open an existing a named file map. When 'readonly' is true this instance opens the map in readonly mode. Writing to the map has no effect.

Parameters
map_name
map_size
readonly
Returns

◆ operator=()

FileMapper & sf::win::FileMapper::operator= ( const FileMapper )
delete

Deleted assignment operator to prevent copying.

Returns

◆ unmapView()

bool sf::win::FileMapper::unmapView ( )
overridevirtual

Called by a server and client to unaccess the map.

Returns
True on success.

Implements sf::IFileMapper.


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