casacore
Loading...
Searching...
No Matches
FileUnbufferedIO.h
Go to the documentation of this file.
1//# FileUnbufferedIO.h: Class for unbuffered IO on a file
2//# Copyright (C) 2022
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_FILEUNBUFFEREDIO_H
27#define CASA_FILEUNBUFFEREDIO_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/IO/FiledesIO.h>
32#include <casacore/casa/OS/RegularFile.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36// <summary>
37// Class for unbuffered IO on a file.
38// </summary>
39
40// <use visibility=export>
41
42// <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tByteIO" demos="">
43// </reviewed>
44
45// <prerequisite>
46// <li> <linkto class=ByteIO>ByteIO</linkto> class
47// <li> file descriptors
48// </prerequisite>
49
50// <synopsis>
51// This class is a specialization of class
52// <linkto class=ByteIO>FiledesIO</linkto> to make it easier to open a file.
53// It reads/writes the data directly instead of using a buffer to reduce the
54// number of IO-operations.
55// It is meant for file access using large reads and writes as done by MultiFile.
56//
57// Optionally the file can be used with O_DIRECT to bypass the system's file cache
58// for more predictable IO behaviour which can be of importance in
59// real-time applications.
60// </synopsis>
61
62// <motivation>
63// Make it possible to use the Casacore IO functionality on any file.
64// In this way any device can be hooked to the IO framework.
65// </motivation>
66
67
69{
70public:
71 // The constructor opens or creates a file.
72 // For option NewNoReplace it is checked if the file does not exist yet.
73 // If useODirect=True and if supported by the OS, the file will be opened
74 // with O_DIRECT which bypasses the kernel's file cache for more predictable
75 // I/O behaviour. It requires the size and the alignment of the data read
76 // or written to be a multiple of the the disk's logical block size.
78 ByteIO::OpenOption option,
79 Bool useODirect=False);
80
81 // The destructor closes the file.
83
84 // Copy constructor and assignment cannot be used.
87
88 // Reopen the file for read/write.
89 // Nothing is done if already opened for read/write.
90 // An exception is thrown if the file is readonly.
91 void reopenRW() override;
92
93private:
95};
96
97
98} //# NAMESPACE CASACORE - END
99
100#endif
OpenOption
Define the possible ByteIO open options.
Definition ByteIO.h:63
FileUnbufferedIO(const RegularFile &fileName, ByteIO::OpenOption option, Bool useODirect=False)
The constructor opens or creates a file.
void reopenRW() override
Reopen the file for read/write.
~FileUnbufferedIO() override
The destructor closes the file.
FileUnbufferedIO(const FileUnbufferedIO &)=delete
Copy constructor and assignment cannot be used.
FileUnbufferedIO & operator=(const FileUnbufferedIO &)=delete
virtual String fileName() const
Get the file name of the file attached.
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40