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// <summary>
38// Memory-mapped IO on a file.
39// </summary>
40
41// <synopsis>
42// Memory-mapped IO lets the OS take care of caching file segments.
43// This is particularly useful for the Tiled Storage Manager which keeps a
44// cache of tiles. When using memory-mapped IO it does not need to do that
45// anymore.
46//
47// On 32-bit systems its use is limited because for large files the 4 GB
48// memory space is insufficient. However, for 64-bit systems the memory
49// space is large enough to make use of it.
50//
51// In the general case there is direct access to the mapped file space.
52// The read and write methods copies the data into/from a buffer.
53// However, to avoid the copying it is possible to get a direct pointer
54// to the mapped data. This should be used with care, because writing to
55// it will cause a segmentation if the file is readonly. If the file is
56// writable, writing into the mapped data segment means changing the file
57// contents.
58// </synopsis>
59
60class MMapIO : public MMapfdIO {
61 public:
62 // Open the given file and map it entirely into memory with read access.
63 // The map has write access if the file is opened for write.
64 explicit MMapIO(const RegularFile& regularFile, ByteIO::OpenOption = ByteIO::Old);
65
66 // Destructor.
67 // It will flush and unmap the file.
69
70 // Forbid copy constructor and assignment
71 // <group>
72 MMapIO(const MMapIO&) = delete;
73 MMapIO& operator=(const MMapIO&) = delete;
74 // </group>
75};
76
77} // namespace casacore
78
79#endif
OpenOption
Define the possible ByteIO open options.
Definition ByteIO.h:60
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.
MMapfdIO()
Default constructor.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28