casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
VLACDA.h
Go to the documentation of this file.
00001 //# VLACDA: 
00002 //# Copyright (C) 1999
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 //#
00027 //# $Id$
00028 
00029 #ifndef NRAO_VLACDA_H
00030 #define NRAO_VLACDA_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/IO/ByteSource.h>
00034 #include <casa/Containers/Block.h>
00035 #include <nrao/VLA/VLABaselineRecord.h>
00036 
00037 #include <casa/namespace.h>
00038 // <summary></summary>
00039 
00040 // <use visibility=export>
00041 
00042 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00043 // </reviewed>
00044 
00045 // <prerequisite>
00046 //   <li> SomeClass
00047 //   <li> SomeOtherClass
00048 //   <li> some concept
00049 // </prerequisite>
00050 //
00051 // <etymology>
00052 // </etymology>
00053 //
00054 // <synopsis>
00055 // </synopsis>
00056 //
00057 // <example>
00058 // </example>
00059 //
00060 // <motivation>
00061 // </motivation>
00062 //
00063 // <templating arg=T>
00064 //    <li>
00065 //    <li>
00066 // </templating>
00067 //
00068 // <thrown>
00069 //    <li>
00070 //    <li>
00071 // </thrown>
00072 //
00073 // <todo asof="yyyy/mm/dd">
00074 //   <li> add this feature
00075 //   <li> fix this bug
00076 //   <li> start discussion of this possible extension
00077 // </todo>
00078 
00079 class VLACDA
00080 {
00081 public:
00082   // The default constructor creates a unusable object. Use the attach function
00083   // to turn an object constructed this way into a usable object.
00084   VLACDA();
00085 
00086   // Initialise this CDA from the given BytesSource (which must contain a VLA
00087   // logical record), and must be readable & seekable. The offset specifies
00088   // where the CDA starts in the logical record. The number of antennas and
00089   // channels in this CDA, as well as the size of a baseline record, 
00090   // must also be specified.
00091   VLACDA(ByteSource& record, uInt offset, uInt baselineSize, 
00092          uInt nant, uInt nChan);
00093 
00094   // The copy constructor uses copy semantics
00095   VLACDA(const VLACDA& other);
00096 
00097   // The destructor is trivial
00098   ~VLACDA();
00099 
00100   // The assignment constructor uses copy semantics
00101   VLACDA& operator=(const VLACDA& other);
00102     
00103   // Initialise this CDA from the given BytesSource (which must contain a VLA
00104   // logical record), and must be readable & seekable. The offset specifies
00105   // where the CDA starts in the logical record. The number of antennas and
00106   // channels in this CDA, as well as the size of a baseline record, 
00107   // must also be specified.
00108   void attach(ByteSource& record, uInt offset, uInt baselineSize, 
00109               uInt nant, uInt nChan);
00110   
00111   // Return True if the CDA contains valid data. This, and the copy functions,
00112   // will not throw an exception if the CDA does not contain data.
00113   Bool isValid() const;
00114 
00115   // return the specified baseline record corresponding to the specified
00116   // auto-correlation. The index must be less than the number of antennas in
00117   // this subarray otherwise an exception is thrown.
00118   const VLABaselineRecord& autoCorr(uInt which) const;
00119 
00120   // return the specified baseline record corresponding to the specified
00121   // cross-correlation. The index must be less than NANT*(NANT-1)/2 otherwise
00122   // an exception is thrown.
00123   const VLABaselineRecord& crossCorr(uInt which) const;
00124 
00125 private: 
00126   //# delete all the auto-correlation baseline pointers
00127   void deleteACorr(uInt startIndex);
00128   //# delete all the cross-correlation baseline pointers
00129   void deleteXCorr(uInt startIndex);
00130 
00131   //# Contains a logical record. It is mutable because functions which do not
00132   //# changes its contents do change its "location"
00133   mutable ByteSource itsRecord;
00134 
00135   // the offset to the start of this CDA in the record. An offset of zero means
00136   // this CDA is not used in this record.
00137   uInt itsOffset;
00138 
00139   // A cached value of the size, in bytes, of a baseline record.
00140   uInt itsBaselineSize;
00141 
00142   // A cached value of the number of antennas that this CDU has data for.
00143   uInt itsNant;
00144 
00145   // A cached value of the number of channels that this CDU has data for.
00146   uInt itsNchan;
00147 
00148   //# A block containing containing "cached" baseline records for the
00149   //# autocorrelations. The pointers are null until the data is actually
00150   //# accessed.
00151   mutable PtrBlock<VLABaselineRecord*> itsACorr; 
00152 
00153   //# A block containing containing "cached" baseline records for the
00154   //# crosscorrelations. The pointers are null until the data is actually
00155   //# accessed.
00156   mutable PtrBlock<VLABaselineRecord*> itsXCorr; 
00157 }; 
00158 #endif