casacore
Loading...
Searching...
No Matches
TSMFile.h
Go to the documentation of this file.
1// # TSMFile.h: File object for Tiled Storage Manager
2// # Copyright (C) 1995,1996,1997,1999,2001
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 TABLES_TSMFILE_H
27#define TABLES_TSMFILE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/IO/BucketFile.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// # Forward Declarations
36class TSMOption;
37class TiledStMan;
38class MultiFileBase;
39class AipsIO;
40
41// <summary>
42// File object for Tiled Storage Manager.
43// </summary>
44
45// <use visibility=local>
46
47// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
48// </reviewed>
49
50// <prerequisite>
51// # Classes you should understand before using this one.
52// <li> <linkto class=TiledStMan>TiledStMan</linkto>
53// </prerequisite>
54
55// <etymology>
56// TSMFile represents a data file for the Tiled Storage Manager.
57// </etymology>
58
59// <synopsis>
60// A TSMFile object represents a data file. Currently it is meant
61// for the TiledStMan classes, but it can easily be turned into
62// a more general storage manager file class.
63// <br>
64// Creation of a TSMFile object does not open the file.
65// An explicit open call has to be given before the file can be used.
66// <p>
67// Underneath it uses a BucketFile to access the file.
68// In this way the IO details are well encapsulated.
69// </synopsis>
70
71// <motivation>
72// Encapsulate the Tiled Storage Manager file details.
73// </motivation>
74
75// # <todo asof="$DATE:$">
76// # </todo>
77
78class TSMFile {
79 public:
80 // Create a TSMFile object (with corresponding file).
81 // The sequence number gets part of the file name.
82 TSMFile(const TiledStMan* stMan, uInt fileSequenceNr, const TSMOption&,
83 const std::shared_ptr<MultiFileBase>& = std::shared_ptr<MultiFileBase>());
84
85 // Create a TSMFile object for the given existing file.
86 TSMFile(const String& fileName, Bool writable, const TSMOption&,
87 const std::shared_ptr<MultiFileBase>& = std::shared_ptr<MultiFileBase>());
88
89 // Read the object back.
90 // The file is not opened until the first access,
91 // thus until the file descriptor is asked for the first time.
92 // It checks if the sequence number matches the expected one.
93 TSMFile(const TiledStMan* stMan, AipsIO& ios, uInt seqnr, const TSMOption&,
94 const std::shared_ptr<MultiFileBase>& = std::shared_ptr<MultiFileBase>());
95
96 // The destructor closes the file.
98
99 // Forbid copy constructor.
100 TSMFile(const TSMFile&) = delete;
101
102 // Forbid assignment.
103 TSMFile& operator=(const TSMFile&) = delete;
104
105 // Write the object.
106 void putObject(AipsIO& ios) const;
107
108 // Get the object.
109 void getObject(AipsIO& ios);
110
111 // Open the file if not open yet.
112 void open();
113
114 // Return the BucketFile object (to be used in the BucketCache).
116
117 // Return the logical file length.
118 Int64 length() const;
119
120 // Return the file sequence number.
121 uInt sequenceNumber() const;
122
123 // Increment the logical file length.
124 void extend(Int64 increment);
125
126 private:
127 // The file sequence number.
129 // The file object.
131 // The (logical) length of the file.
133};
134
135inline Int64 TSMFile::length() const { return length_p; }
136
137inline uInt TSMFile::sequenceNumber() const { return fileSeqnr_p; }
138
139inline void TSMFile::extend(Int64 increment) { length_p += increment; }
140
142
143inline void TSMFile::open() { file_p->open(); }
144
145} // namespace casacore
146
147#endif
Abstract base class to combine multiple logical files in a single one.
String: the storage and methods of handling collections of characters.
Definition String.h:355
TSMFile(const String &fileName, Bool writable, const TSMOption &, const std::shared_ptr< MultiFileBase > &=std::shared_ptr< MultiFileBase >())
Create a TSMFile object for the given existing file.
~TSMFile()
The destructor closes the file.
TSMFile(const TiledStMan *stMan, AipsIO &ios, uInt seqnr, const TSMOption &, const std::shared_ptr< MultiFileBase > &=std::shared_ptr< MultiFileBase >())
Read the object back.
void getObject(AipsIO &ios)
Get the object.
BucketFile * bucketFile()
Return the BucketFile object (to be used in the BucketCache).
Definition TSMFile.h:141
Int64 length_p
The (logical) length of the file.
Definition TSMFile.h:132
uInt sequenceNumber() const
Return the file sequence number.
Definition TSMFile.h:137
void putObject(AipsIO &ios) const
Write the object.
Int64 length() const
Return the logical file length.
Definition TSMFile.h:135
void open()
Open the file if not open yet.
Definition TSMFile.h:143
BucketFile * file_p
The file object.
Definition TSMFile.h:130
uInt fileSeqnr_p
The file sequence number.
Definition TSMFile.h:128
void extend(Int64 increment)
Increment the logical file length.
Definition TSMFile.h:139
TSMFile & operator=(const TSMFile &)=delete
Forbid assignment.
TSMFile(const TiledStMan *stMan, uInt fileSequenceNr, const TSMOption &, const std::shared_ptr< MultiFileBase > &=std::shared_ptr< MultiFileBase >())
Create a TSMFile object (with corresponding file).
TSMFile(const TSMFile &)=delete
Forbid copy constructor.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40