Files

72 lines
2.1 KiB
C++

/**
* @file include/ActivMiddleware/ActivBase/IFileMappedMemory.h
*
* @brief Header file for the file mapped memory interface class.
*/
#if (!defined ACTIV_BASE_IFILE_MAPPED_MEMORY_H)
#define ACTIV_BASE_IFILE_MAPPED_MEMORY_H
#include "ActivMiddleware/ActivBase/External.h"
#include "ActivMiddleware/ActivBase/IMappedMemory.h"
#include "ActivMiddleware/Misc/TypeSafeFlags.h"
//! Activ namespace.
namespace Activ
{
/**
* @brief Abstract base file mapped memory class.
*/
class IFileMappedMemory : public IMappedMemory
{
public:
static const size_t USE_CURRENT_FILE_SIZE = 0; ///< Used for creating a mapping of the current file size.
//! Flags.
class FileFlags : public TypeSafeFlags::Underlying<uint32_t>
{
public:
typedef TypeSafeFlags::Value<FileFlags, 0x00000000> None;
typedef TypeSafeFlags::Value<FileFlags, 0x00000001> CreateAlways; ///< Always create new file.
typedef TypeSafeFlags::Value<FileFlags, 0x00000002> OpenExisting; ///< Open existing file, fail if file doesn't exist.
typedef TypeSafeFlags::Value<FileFlags, 0x00000004> ReadOnly; ///< Open file in read only mode.
typedef TypeSafeFlags::Value<FileFlags, 0x00000008> DeleteAtClose; ///< Delete the file when the handle to it is closed.
typedef TypeSafeFlags::Type<FileFlags, None> Type;
};
//! Destructor.
virtual ~IFileMappedMemory() = 0;
/**
* @brief Resize a memory mapped file.
*
* @param size the new size of the memory mapped file.
*
* @return a pointer to the new mapped memory region.
*
* @throw Exception
*/
virtual void *Resize(const size_t size) = 0;
/**
* @brief Flush the memory mapped file to the disk.
*
* @param nBytesToFlush the number of bytes to flush, starting from the beginning of the file. Default flush all.
*
* @throw Exception
*/
virtual void Flush(const size_t nBytesToFlush = 0) const = 0;
};
// ---------------------------------------------------------------------------------------------------------------------------------
inline IFileMappedMemory::~IFileMappedMemory()
{
}
} // namespace Activ
#endif // (!defined ACTIV_BASE_IFILE_MAPPED_MEMORY_H)