TSMFile.h

Go to the documentation of this file.
00001 //# TSMFile.h: File object for Tiled Storage Manager
00002 //# Copyright (C) 1995,1996,1997,1999,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef TABLES_TSMFILE_H
00029 #define TABLES_TSMFILE_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/IO/BucketFile.h>
00034 
00035 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00036 
00037 //# Forward Declarations
00038 class TSMOption;
00039 class TiledStMan;
00040 class MultiFileBase;
00041 class AipsIO;
00042 
00043 // <summary>
00044 // File object for Tiled Storage Manager.
00045 // </summary>
00046 
00047 // <use visibility=local>
00048 
00049 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00050 // </reviewed>
00051 
00052 // <prerequisite>
00053 //# Classes you should understand before using this one.
00054 //   <li> <linkto class=TiledStMan>TiledStMan</linkto>
00055 // </prerequisite>
00056 
00057 // <etymology>
00058 // TSMFile represents a data file for the Tiled Storage Manager.
00059 // </etymology>
00060 
00061 // <synopsis>
00062 // A TSMFile object represents a data file. Currently it is meant
00063 // for the TiledStMan classes, but it can easily be turned into
00064 // a more general storage manager file class.
00065 // <br>
00066 // Creation of a TSMFile object does not open the file.
00067 // An explicit open call has to be given before the file can be used.
00068 // <p>
00069 // Underneath it uses a BucketFile to access the file.
00070 // In this way the IO details are well encapsulated.
00071 // </synopsis> 
00072 
00073 // <motivation>
00074 // Encapsulate the Tiled Storage Manager file details.
00075 // </motivation>
00076 
00077 //# <todo asof="$DATE:$">
00078 //# </todo>
00079 
00080 
00081 class TSMFile
00082 {
00083 public:
00084     // Create a TSMFile object (with corresponding file).
00085     // The sequence number gets part of the file name.
00086     TSMFile (const TiledStMan* stMan, uInt fileSequenceNr,
00087              const TSMOption&, MultiFileBase* mfile=0);
00088 
00089     // Create a TSMFile object for the given existing file.
00090     TSMFile (const String& fileName, Bool writable, const TSMOption&,
00091              MultiFileBase* mfile=0);
00092 
00093     // Read the object back.
00094     // The file is not opened until the first access,
00095     // thus until the file descriptor is asked for the first time.
00096     // It checks if the sequence number matches the expected one.
00097     TSMFile (const TiledStMan* stMan, AipsIO& ios, uInt seqnr,
00098              const TSMOption&, MultiFileBase* mfile=0);
00099 
00100     // The destructor closes the file.
00101     ~TSMFile();
00102 
00103     // Write the object.
00104     void putObject (AipsIO& ios) const;
00105 
00106     // Get the object.
00107     void getObject (AipsIO& ios);
00108 
00109     // Open the file if not open yet.
00110     void open();
00111 
00112     // Return the BucketFile object (to be used in the BucketCache).
00113     BucketFile* bucketFile();
00114 
00115     // Return the logical file length.
00116     Int64 length() const;
00117 
00118     // Return the file sequence number.
00119     uInt sequenceNumber() const;
00120 
00121     // Increment the logical file length.
00122     void extend (Int64 increment);
00123 
00124 
00125 private:
00126     // The file sequence number.
00127     uInt fileSeqnr_p;
00128     // The file object.
00129     BucketFile* file_p;
00130     // The (logical) length of the file.
00131     Int64 length_p;
00132             
00133 
00134     // Forbid copy constructor.
00135     TSMFile (const TSMFile&);
00136 
00137     // Forbid assignment.
00138     TSMFile& operator= (const TSMFile&);
00139 };
00140 
00141 
00142 inline Int64 TSMFile::length() const
00143     { return length_p; }
00144 
00145 inline uInt TSMFile::sequenceNumber() const
00146     { return fileSeqnr_p; }
00147 
00148 inline void TSMFile::extend (Int64 increment)
00149     { length_p += increment; }
00150 
00151 inline BucketFile* TSMFile::bucketFile()
00152     { return file_p; }
00153 
00154 inline void TSMFile::open()
00155     { file_p->open(); }
00156 
00157 
00158 
00159 } //# NAMESPACE CASACORE - END
00160 
00161 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1