DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
MapFile.hpp
Go to the documentation of this file.
1// DUNE DAQ modification notice:
2// This file has been modified from the original ATLAS system source for the DUNE DAQ project.
3// Fork baseline commit: system-00-00-20 (2020-09-25).
4// Renamed since fork: yes (from system/MapFile.h to include/okssystem/MapFile.hpp).
5
6/*
7 * MapFile.h
8 * OksSystem
9 *
10 * Created by Matthias Wiesmann on 07.01.05.
11 * Copyright 2005 CERN. All rights reserved.
12 *
13 */
14
15#ifndef OKSSYSTEM_MAP_FILE
16#define OKSSYSTEM_MAP_FILE
17
18#include "okssystem/File.hpp"
19
20namespace OksSystem {
21
22class Descriptor;
23
30
31class MapFile : public File
32{
33
34public:
35 MapFile(const std::string& file,
36 size_t size,
37 size_t offset,
38 bool read_mode,
39 bool write_mode,
40 mode_t permissions = 0666);
41 ~MapFile();
42
43 void zero() const;
44 void map();
45 void unmap();
46 bool is_mapped() const;
47 bool is_loaded() const throw();
48 void* address() const throw();
49 size_t memory_size() const throw();
51 throw();
52
53protected:
54 void open_fd();
55 void close_fd();
56 void map_mem();
57 void unmap_mem();
58
60 size_t m_map_size;
61 size_t m_map_offset;
67
68private:
69 static const char* const MAP_LOAD_MSG;
70 static const char* const MAP_NOT_LOAD_MSG;
71 static const char* const PAGE_SIZE_MSG;
72 static const char* const READ_OR_WRITE_MSG;
73 static const char* const MAP_NOT_WRITE_MSG;
74
75}; // MapFile
76
77} // ers
78
79#endif
File descriptor / Socket wrapper.
mode_t permissions() const
permissions for the file *‍/
Definition File.cpp:558
File(const std::string &name)
Definition File.cpp:327
size_t size() const
size of file *‍/
Definition File.cpp:593
void unmap_mem()
unmaps the file into memory
Definition MapFile.cpp:118
static const char *const MAP_NOT_LOAD_MSG
message pattern - map is not loaded
Definition MapFile.hpp:70
void * m_map_address
the address of the map in memory
Definition MapFile.hpp:59
void zero() const
builds a zeroed file with correct length
Definition MapFile.cpp:135
size_t m_map_offset
offset in the file of the map
Definition MapFile.hpp:61
size_t m_map_size
the size of the map
Definition MapFile.hpp:60
MapFile(const std::string &file, size_t size, size_t offset, bool read_mode, bool write_mode, mode_t permissions=0666)
Definition MapFile.cpp:35
bool is_mapped() const
is the file mopped im memory
Definition MapFile.cpp:206
bool m_map_write
is the map writable
Definition MapFile.hpp:65
void unmap()
unmaps the file
Definition MapFile.cpp:170
static const char *const MAP_LOAD_MSG
message pattern - map is loaded
Definition MapFile.hpp:69
static const char *const READ_OR_WRITE_MSG
message pattern - map mode is neither read nor write
Definition MapFile.hpp:72
Descriptor * m_map_descriptor
internal file descriptor
Definition MapFile.hpp:62
bool m_is_mapped
is the file mapped in memory
Definition MapFile.hpp:66
bool is_loaded() const
is the map loaded in memory
Definition MapFile.cpp:177
static const char *const PAGE_SIZE_MSG
message pattern - illegal page size
Definition MapFile.hpp:71
OksSystem::Descriptor * fd() const
the file descriptor. This method returns a valid pointer only if called after map().
Definition MapFile.cpp:212
void open_fd()
opens the file descriptor for the map
Definition MapFile.cpp:68
void close_fd()
closes the file descriptor for the map
Definition MapFile.cpp:79
size_t memory_size() const
the size of the map
Definition MapFile.cpp:198
void map_mem()
maps the file into memory
Definition MapFile.cpp:92
bool m_map_read
is the map readable
Definition MapFile.hpp:64
void map()
maps the file in memory
Definition MapFile.cpp:157
mode_t m_map_permission
permissions associated with the file
Definition MapFile.hpp:63
static const char *const MAP_NOT_WRITE_MSG
message pattern - map is not writable
Definition MapFile.hpp:73
void * address() const
the address of the memory mapped file
Definition MapFile.cpp:188
double offset