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