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