78 lines
2.5 KiB
C++
78 lines
2.5 KiB
C++
/**
|
|
* @file include/ActivMiddleware/ActivBase/FileMappedMemoryFactory.h
|
|
*
|
|
* @brief Header file for the file mapped memory factory class.
|
|
*/
|
|
|
|
#if (!defined ACTIV_BASE_FILE_MAPPED_MEMORY_FACTORY_H)
|
|
#define ACTIV_BASE_FILE_MAPPED_MEMORY_FACTORY_H
|
|
|
|
#include "ActivMiddleware/ActivBase/External.h"
|
|
#include "ActivMiddleware/ActivBase/IFileMappedMemory.h"
|
|
#include "ActivMiddleware/ActivBase/Timeout.h"
|
|
#include "ActivMiddleware/Misc/Singleton.h"
|
|
|
|
//! Activ namespace.
|
|
namespace Activ
|
|
{
|
|
|
|
/**
|
|
* @brief File mapped memory factory class.
|
|
*/
|
|
class FileMappedMemoryFactory : public Singleton<FileMappedMemoryFactory>
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Create a memory mapped file that can be shared via name.
|
|
*
|
|
* @param fileName the name of the file to map into memory.
|
|
* @param size the size to the memory segment to be mapped.
|
|
* @param canShare flag indicating whether the memory mapped file can be shared.
|
|
* @param fileFlags flags to use when creating or opening the file.
|
|
* @param mappingFlags flags to use when creating the mapped memory segment.
|
|
*
|
|
* @return Pointer to an object providing an IFileMappedMemory interface.
|
|
*
|
|
* @throw Exception
|
|
*/
|
|
ACTIV_BASE_API IFileMappedMemory *Create(const String &fileName, const size_t size, const bool canShare,
|
|
const IFileMappedMemory::FileFlags::Type fileFlags = IFileMappedMemory::FileFlags::None(),
|
|
const IMappedMemory::MappingFlags::Type mappingFlags = IMappedMemory::MappingFlags::None());
|
|
|
|
/**
|
|
* @brief Open an existing memory mapped file.
|
|
*
|
|
* @param fileName the name of the file to map into memory.
|
|
* @param fileFlags flags to use when creating or opening the file.
|
|
* @param mappingFlags flags to use when creating the mapped memory segment.
|
|
* @param timeout object specifying how long to wait for the memory mapped file to exist, in ms.
|
|
*
|
|
* @return pointer to an object providing an IFileMappedMemory interface.
|
|
*
|
|
* @throw Exception
|
|
*/
|
|
ACTIV_BASE_API IFileMappedMemory *Open(const String &fileName,
|
|
const IFileMappedMemory::FileFlags::Type fileFlags = IFileMappedMemory::FileFlags::None(),
|
|
const IMappedMemory::MappingFlags::Type mappingFlags = IMappedMemory::MappingFlags::None(),
|
|
Timeout &timeout = Timeout::GetInfinite());
|
|
|
|
/**
|
|
* @brief Get a reference to the singleton instance.
|
|
*
|
|
* @return Reference.
|
|
*/
|
|
ACTIV_BASE_API static FileMappedMemoryFactory &GetInstance();
|
|
|
|
private:
|
|
/**
|
|
* @brief Default constructor.
|
|
*/
|
|
ACTIV_BASE_API FileMappedMemoryFactory();
|
|
|
|
friend class Singleton<FileMappedMemoryFactory>;
|
|
};
|
|
|
|
} // namespace Activ
|
|
|
|
#endif // (!defined ACTIV_BASE_FILE_MAPPED_MEMORY_FACTORY_H)
|