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
22 class Descriptor ;
23
30
31 class MapFile : public File {
32
33 public:
34
35 MapFile(const std::string &file, size_t size, size_t offset, bool read_mode, bool write_mode, mode_t permissions = 0666) ;
36 ~MapFile();
37
38 void zero() const ;
39 void map();
40 void unmap();
41 bool is_mapped() const;
42 bool is_loaded() const throw() ;
43 void *address() const throw() ;
44 size_t memory_size() const throw() ;
45 OksSystem::Descriptor* fd() const throw() ;
46
47 protected:
48
49 void open_fd();
50 void close_fd();
51 void map_mem();
52 void unmap_mem();
53
54 void * m_map_address ;
55 size_t m_map_size ;
56 size_t m_map_offset ;
59 bool m_map_read ;
62
63 private:
64
65 static const char* const MAP_LOAD_MSG ;
66 static const char* const MAP_NOT_LOAD_MSG ;
67 static const char* const PAGE_SIZE_MSG ;
68 static const char* const READ_OR_WRITE_MSG ;
69 static const char* const MAP_NOT_WRITE_MSG ;
70
71 } ; // MapFile
72
73} // ers
74
75#endif
File descriptor / Socket wrapper.
mode_t permissions() const
permissions for the file *‍/
Definition File.cpp:505
File(const std::string &name)
Definition File.cpp:301
size_t size() const
size of file *‍/
Definition File.cpp:535
void unmap_mem()
unmaps the file into memory
Definition MapFile.cpp:110
static const char *const MAP_NOT_LOAD_MSG
message pattern - map is not loaded
Definition MapFile.hpp:66
void * m_map_address
the address of the map in memory
Definition MapFile.hpp:54
void zero() const
builds a zeroed file with correct length
Definition MapFile.cpp:125
size_t m_map_offset
offset in the file of the map
Definition MapFile.hpp:56
size_t m_map_size
the size of the map
Definition MapFile.hpp:55
MapFile(const std::string &file, size_t size, size_t offset, bool read_mode, bool write_mode, mode_t permissions=0666)
Definition MapFile.cpp:36
bool is_mapped() const
is the file mopped im memory
Definition MapFile.cpp:186
bool m_map_write
is the map writable
Definition MapFile.hpp:60
void unmap()
unmaps the file
Definition MapFile.cpp:157
static const char *const MAP_LOAD_MSG
message pattern - map is loaded
Definition MapFile.hpp:65
static const char *const READ_OR_WRITE_MSG
message pattern - map mode is neither read nor write
Definition MapFile.hpp:68
Descriptor * m_map_descriptor
internal file descriptor
Definition MapFile.hpp:57
bool m_is_mapped
is the file mapped in memory
Definition MapFile.hpp:61
bool is_loaded() const
is the map loaded in memory
Definition MapFile.cpp:162
static const char *const PAGE_SIZE_MSG
message pattern - illegal page size
Definition MapFile.hpp:67
OksSystem::Descriptor * fd() const
the file descriptor. This method returns a valid pointer only if called after map().
Definition MapFile.cpp:190
void open_fd()
opens the file descriptor for the map
Definition MapFile.cpp:65
void close_fd()
closes the file descriptor for the map
Definition MapFile.cpp:75
size_t memory_size() const
the size of the map
Definition MapFile.cpp:180
void map_mem()
maps the file into memory
Definition MapFile.cpp:86
bool m_map_read
is the map readable
Definition MapFile.hpp:59
void map()
maps the file in memory
Definition MapFile.cpp:146
mode_t m_map_permission
permissions associated with the file
Definition MapFile.hpp:58
static const char *const MAP_NOT_WRITE_MSG
message pattern - map is not writable
Definition MapFile.hpp:69
void * address() const
the address of the memory mapped file
Definition MapFile.cpp:172
double offset