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

Wrapper for the linux mmap. More...

#include <FileMapper.h>

Inheritance diagram for sf::lnx::FileMapper:
Collaboration diagram for sf::lnx::FileMapper:

Public Member Functions

 FileMapper ()
 Default constructor.
 
 FileMapper (const std::string &filepath, size_t ofs=0, size_t sz=0)
 Initializing constructor.
 
void initialize () override
 Use temporary files to map.
 
 ~FileMapper () override
 Destructor.
 
void initialize (const std::string &filepath, size_t ofs=0, size_t sz=0)
 Initializes the mapper passing a file instance.
 
void createView (size_t size) override
 Sets the size of the file to be mapped.
 
void setView (size_t ofs, size_t sz)
 Sets the part of the file to be mapped.
 
void reset ()
 Unlocks the locked file and removes the file reference.
 
void * getPtr () override
 Gets the pointer of the mapped area.
 
template<typename T >
T * lock (bool readonly=false)
 Locks the set area.
 
void unlock (bool sync=false)
 
bool mapView () override
 Locks a pointer in memory which can be unlocked using unmapView().
 
bool unmapView () override
 Unlocks the pointer locked with mapView().
 
const FilegetFile ()
 
bool isLocked () const
 
void sync (bool async)
 
size_t getSize () const
 
- 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

Wrapper for the linux mmap.

Constructor & Destructor Documentation

◆ FileMapper() [1/2]

sf::lnx::FileMapper::FileMapper ( )

Default constructor.

◆ FileMapper() [2/2]

sf::lnx::FileMapper::FileMapper ( const std::string &  filepath,
size_t  ofs = 0,
size_t  sz = 0 
)
explicit

Initializing constructor.

◆ ~FileMapper()

sf::lnx::FileMapper::~FileMapper ( )
override

Destructor.

Member Function Documentation

◆ createView()

void sf::lnx::FileMapper::createView ( size_t  size)
overridevirtual

Sets the size of the file to be mapped.

Implements sf::IFileMapper.

◆ getFile()

const File & sf::lnx::FileMapper::getFile ( )
inline

Returns the underlying file.

Returns
File instance reference.

◆ getPtr()

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

Gets the pointer of the mapped area.

Implements sf::IFileMapper.

◆ getSize()

size_t sf::lnx::FileMapper::getSize ( ) const

Returns the set size.

◆ initialize() [1/2]

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

Use temporary files to map.

Implements sf::IFileMapper.

◆ initialize() [2/2]

void sf::lnx::FileMapper::initialize ( const std::string &  filepath,
size_t  ofs = 0,
size_t  sz = 0 
)

Initializes the mapper passing a file instance.

◆ isLocked()

bool sf::lnx::FileMapper::isLocked ( ) const

Returns true when locked.

◆ lock()

template<typename T >
T * sf::lnx::FileMapper::lock ( bool  readonly = false)
inline

Locks the set area.

Template Parameters
TType of the pointer
Parameters
readonlyFlag making the resulting pointer readonly.
Returns
NULL on failure otherwise pointer of specified type.

◆ mapView()

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

Locks a pointer in memory which can be unlocked using unmapView().

Returns
True on success.

Implements sf::IFileMapper.

◆ reset()

void sf::lnx::FileMapper::reset ( )

Unlocks the locked file and removes the file reference.

◆ setView()

void sf::lnx::FileMapper::setView ( size_t  ofs,
size_t  sz 
)

Sets the part of the file to be mapped.

◆ sync()

void sf::lnx::FileMapper::sync ( bool  async)

Returns true on success to invalidated data so it is written to disk. When async is false the function returns after the data is written to disk. When true the function returns immediately.

◆ unlock()

void sf::lnx::FileMapper::unlock ( bool  sync = false)

Unlocks the set area and syncs the data when sync is set.

◆ unmapView()

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

Unlocks the pointer locked with mapView().

Returns
True on success.

Implements sf::IFileMapper.


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