casacore
Loading...
Searching...
No Matches
MMapIO.h
Go to the documentation of this file.
1//# MMapIO.h: Memory-mapped IO on a file
2//#
3//# Copyright (C) 2009
4//# Associated Universities, Inc. Washington DC, USA.
5//#
6//# This library is free software; you can redistribute it and/or modify it
7//# under the terms of the GNU Library General Public License as published by
8//# the Free Software Foundation; either version 2 of the License, or (at your
9//# option) any later version.
10//#
11//# This library is distributed in the hope that it will be useful, but WITHOUT
12//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14//# License for more details.
15//#
16//# You should have received a copy of the GNU Library General Public License
17//# along with this library; if not, write to the Free Software Foundation,
18//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19//#
20//# Correspondence concerning AIPS++ should be addressed as follows:
21//# Internet email: casa-feedback@nrao.edu.
22//# Postal address: AIPS++ Project Office
23//# National Radio Astronomy Observatory
24//# 520 Edgemont Road
25//# Charlottesville, VA 22903-2475 USA
26
27#ifndef CASA_MMAPIO_H
28#define CASA_MMAPIO_H
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/casa/IO/MMapfdIO.h>
33#include <casacore/casa/OS/RegularFile.h>
34
35namespace casacore
36{
37
38// <summary>
39// Memory-mapped IO on a file.
40// </summary>
41
42// <synopsis>
43// Memory-mapped IO lets the OS take care of caching file segments.
44// This is particularly useful for the Tiled Storage Manager which keeps a
45// cache of tiles. When using memory-mapped IO it does not need to do that
46// anymore.
47//
48// On 32-bit systems its use is limited because for large files the 4 GB
49// memory space is insufficient. However, for 64-bit systems the memory
50// space is large enough to make use of it.
51//
52// In the general case there is direct access to the mapped file space.
53// The read and write methods copies the data into/from a buffer.
54// However, to avoid the copying it is possible to get a direct pointer
55// to the mapped data. This should be used with care, because writing to
56// it will cause a segmentation if the file is readonly. If the file is
57// writable, writing into the mapped data segment means changing the file
58// contents.
59// </synopsis>
60
61class MMapIO: public MMapfdIO
62{
63public:
64 // Open the given file and map it entirely into memory with read access.
65 // The map has write access if the file is opened for write.
66 explicit MMapIO (const RegularFile& regularFile,
68
69 // Destructor.
70 // It will flush and unmap the file.
72
73 // Forbid copy constructor and assignment
74 // <group>
75 MMapIO (const MMapIO&) = delete;
76 MMapIO& operator= (const MMapIO&) = delete;
77 // </group>
78};
79
80} // end namespace
81
82#endif
OpenOption
Define the possible ByteIO open options.
Definition ByteIO.h:63
MMapIO(const RegularFile &regularFile, ByteIO::OpenOption=ByteIO::Old)
Open the given file and map it entirely into memory with read access.
~MMapIO()
Destructor.
MMapIO & operator=(const MMapIO &)=delete
MMapIO(const MMapIO &)=delete
Forbid copy constructor and assignment.
this file contains all the compiler specific defines
Definition mainpage.dox:28