00001 //# MirDataBuffer.h: this defines a container for filler data buffers 00002 //# Copyright (C) 2000,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 //# 00027 //# $Id: MirDataBuffer.h,v 1.1 2009/09/03 18:54:47 pteuben Exp $ 00028 00029 #ifndef BIMA_MIRDATABUFFER_H 00030 #define BIMA_MIRDATABUFFER_H 00031 00032 #include <casa/Containers/Block.h> 00033 #include <casa/Arrays/Matrix.h> 00034 #include <casa/Arrays/Cube.h> 00035 00036 #include <casa/namespace.h> 00037 //# Forward Declarations 00038 class MirDataBufferIter; 00039 00040 // <summary> 00041 // a buffer for data read in from a Miriad datatset 00042 // </summary> 00043 // 00044 // <use visibility=local> 00045 // 00046 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00047 // </reviewed> 00048 // 00049 // <etymology> 00050 // this class buffers data from a Miriad dataset 00051 // </etymology> 00052 // 00053 // <motivation> 00054 // MSes filled from Miriad data feature multiple windows of differing shapes. 00055 // Performance during MS reads can be aided by collecting together MS table 00056 // records of the same shape (e.g. of the same window). MirFiller accoplishes 00057 // this by reading all baselines from a single timestamp at once, so that 00058 // they written out in order of spectral window. This class provides a 00059 // container for holding the data from different baselines. 00060 // </motivation> 00061 // 00062 // <synopsis> 00063 // At the moment, this is intended for use only by the MirFiller class. 00064 // 00065 // 00066 // </synopsis> 00067 // 00068 // <example> 00069 // 00070 // 00071 // </example> 00072 // 00073 // <todo asof="2001/02/22"> 00074 // 00075 // </todo> 00076 // 00077 class MirDataBuffer { 00078 private: 00079 Boolean upd; 00080 Boolean hasmore; 00081 00082 Block<int> pol; 00083 Block<double *> preamble; 00084 Block<float *> narrow; 00085 Block<float *> wide; 00086 Int nrec, nnar, nwide; 00087 00088 MirDataBuffer(MirDataBuffer&); 00089 public: 00090 // create the container 00091 MirDataBuffer(...); 00092 00093 // return true if there is still data to be read from the dataset 00094 Boolean hasMore() { return hasmore; } 00095 00096 // set the variable update state. A value of True means that some 00097 // variables have changed and should be checked for new values. False 00098 // means that the variables have not changed since the last time 00099 // they were checked. 00100 void varUpdated(Boolean val) { upd = val; } 00101 00102 // return the variable update state. A value of True means that some 00103 // variables have changed and should be checked for new values. False 00104 // means that the variables have not changed since the last time 00105 // they were checked. 00106 Boolean isVarUpdated() { return upd; } 00107 00108 // return a pointer to the i-th record in this buffer 00109 float *operator[](Int i) { return recs[i]; } 00110 00111 // return the preamble for the i-th record 00112 double *getPreamble(Int i) { return preamble[i]; } 00113 00114 // return the current Miriad timestamp 00115 double getTime() { return preamble[0][3]; } 00116 00117 // return the baseline number for the i-th record 00118 Int getBaselineNum(Int i) { return Int(preamble[i][4]); } 00119 00120 // return the baseline vector as a 3-element array holding u, v, & w 00121 double *getBaselineVec(Int i) { return preamble[i]; } 00122 00123 // return the Miriad polarization code for the i-th record 00124 Int getPol(Int i) { return pol[i]; } 00125 00126 // return the number of records held in this buffer 00127 Int size() { nrec; } 00128 00129 // update the number of records held by the buffer 00130 00131 // reset the buffer for a new time slot 00132 void reset() { 00133 if (hasmore) { 00134 00135 // switch cached record into first position 00136 double *tmppre = preamble[0]; 00137 float *tmpnar = narrow[0]; 00138 float *tmpwid = wide[0]; 00139 preamble[0] = preamble[n]; 00140 narrow[0] = narrow[n]; 00141 wide[0] = wide[n]; 00142 pol[0] = pol[n]; 00143 preamble[n] = tmppre; 00144 narrow[n] = tmpnar; 00145 wide[n] = tmpwid; 00146 00147 hasmore = False; 00148 n=1; 00149 } else { 00150 n=0; 00151 } 00152 } 00153 00154 00155 00156 }; 00157 00158 #endif