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
78
80{
81public:
82 // Create a TSMFile object (with corresponding file).
83 // The sequence number gets part of the file name.
84 TSMFile (const TiledStMan* stMan, uInt fileSequenceNr,
85 const TSMOption&,
86 const std::shared_ptr<MultiFileBase>& = std::shared_ptr<MultiFileBase>());
87
88 // Create a TSMFile object for the given existing file.
89 TSMFile (const String& fileName, Bool writable, const TSMOption&,
90 const std::shared_ptr<MultiFileBase>& = std::shared_ptr<MultiFileBase>());
91
92 // Read the object back.
93 // The file is not opened until the first access,
94 // thus until the file descriptor is asked for the first time.
95 // It checks if the sequence number matches the expected one.
96 TSMFile (const TiledStMan* stMan, AipsIO& ios, uInt seqnr,
97 const TSMOption&,
98 const std::shared_ptr<MultiFileBase>& = std::shared_ptr<MultiFileBase>());
99
100 // The destructor closes the file.
102
103 // Forbid copy constructor.
104 TSMFile (const TSMFile&) = delete;
105
106 // Forbid assignment.
107 TSMFile& operator= (const TSMFile&) = delete;
108
109 // Write the object.
110 void putObject (AipsIO& ios) const;
111
112 // Get the object.
113 void getObject (AipsIO& ios);
114
115 // Open the file if not open yet.
116 void open();
117
118 // Return the BucketFile object (to be used in the BucketCache).
120
121 // Return the logical file length.
122 Int64 length() const;
123
124 // Return the file sequence number.
125 uInt sequenceNumber() const;
126
127 // Increment the logical file length.
128 void extend (Int64 increment);
129
130
131private:
132 // The file sequence number.
134 // The file object.
136 // The (logical) length of the file.
138};
139
140
141inline Int64 TSMFile::length() const
142 { return length_p; }
143
145 { return fileSeqnr_p; }
146
147inline void TSMFile::extend (Int64 increment)
148 { length_p += increment; }
149
151 { return file_p; }
152
153inline void TSMFile::open()
154 { file_p->open(); }
155
156
157
158} //# NAMESPACE CASACORE - END
159
160#endif
virtual void open()
Open the file if not open yet.
String: the storage and methods of handling collections of characters.
Definition String.h:223
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:150
Int64 length_p
The (logical) length of the file.
Definition TSMFile.h:137
uInt sequenceNumber() const
Return the file sequence number.
Definition TSMFile.h:144
void putObject(AipsIO &ios) const
Write the object.
Int64 length() const
Return the logical file length.
Definition TSMFile.h:141
void open()
Open the file if not open yet.
Definition TSMFile.h:153
BucketFile * file_p
The file object.
Definition TSMFile.h:135
uInt fileSeqnr_p
The file sequence number.
Definition TSMFile.h:133
void extend(Int64 increment)
Increment the logical file length.
Definition TSMFile.h:147
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.
this file contains all the compiler specific defines
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