casa
$Rev:20696$
|
00001 //# GBTDAPFillerBase: A base class for GBT Data Associated Parameter fillers 00002 //# Copyright (C) 2000 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_GBTDAPFILLERBASE_H 00030 #define NRAO_GBTDAPFILLERBASE_H 00031 00032 #include <nrao/FITS/GBTDAPFile.h> 00033 00034 #include <casa/aips.h> 00035 #include <casa/Containers/Block.h> 00036 #include <casa/Containers/Record.h> 00037 #include <casa/Containers/SimOrdMap.h> 00038 #include <casa/Quanta/MVTime.h> 00039 #include <tables/Tables/TableDesc.h> 00040 #include <casa/BasicSL/String.h> 00041 00042 #include <fits/FITS/FITSTable.h> 00043 00044 #include <casa/namespace.h> 00045 00046 // <summary> 00047 // A base class for GBT Data Associated Parameter fillers 00048 // </summary> 00049 00050 // <use visibility=local> 00051 00052 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00053 // </reviewed> 00054 00055 // <prerequisite> 00056 // <li> GBT DAP FITS files 00057 // </prerequisite> 00058 // 00059 // <etymology> 00060 // This provides the underlying mechanisms for filling GBT DAP FITS 00061 // files from the same device but many different samplers and managers. 00062 // </etymology> 00063 // 00064 // <synopsis> 00065 // </synopsis> 00066 // 00067 // <example> 00068 // </example> 00069 // 00070 // <motivation> 00071 // Various DAP fillers share their handling of the FITS files. 00072 // </motivation> 00073 // 00074 // <thrown> 00075 // <li> 00076 // <li> 00077 // </thrown> 00078 // 00079 00080 class GBTDAPFillerBase 00081 { 00082 public: 00083 // A virtual destructor is needed so that it will use the 00084 // actual destructor in the derived class. 00085 virtual ~GBTDAPFillerBase(); 00086 00087 // report the device name 00088 virtual const String &device() const = 0; 00089 00090 // this should do what it can to fill the data 00091 virtual void fill() = 0; 00092 00093 // prepare the filler to use the indicated manager, sampler, and filename 00094 // starting with the given startTime. The return value is the ID of 00095 // this sampler/manager combo. A negative return value indicates a problem. 00096 virtual Int prepare(const String &fileName, const String &manager, 00097 const String &sampler, const MVTime &startTime); 00098 00099 // A useful function to decode a filename into a device, manager, and sampler 00100 static Bool parseName(const String &fileName, 00101 String &device, String &manager, 00102 String &sampler); 00103 protected: 00104 // (Required) default constructor 00105 GBTDAPFillerBase(); 00106 00107 // (Required) copy constructor. 00108 GBTDAPFillerBase(const GBTDAPFillerBase &other); 00109 00110 // (Required) copy assignment. 00111 GBTDAPFillerBase &operator=(const GBTDAPFillerBase &other); 00112 00113 // how many rows are ready to be filled 00114 Int rowsToFill() {return rowsToFill_p;} 00115 00116 // Get the ID of the DAP holding the current row waiting to be filled 00117 Int currentId(); 00118 00119 // return the current row waiting to be filled 00120 const Record ¤tRow(); 00121 00122 // return the current sampler 00123 const String ¤tSampler(); 00124 00125 // return the current manager 00126 const String ¤tManager(); 00127 00128 // return the current interval 00129 Double currentInterval(); 00130 00131 // return the current time 00132 const MVTime ¤tTime() {return ctime_p;} 00133 00134 // advance to the next row to be filled - this decrements rowsToFill by 1 00135 // when rowsToFill reaches zero, next() has no effect 00136 void next(); 00137 00138 // get the TableDesc of the indicated sampler/manager ID - the value returned 00139 // by prepare 00140 TableDesc tableDesc(Int whichId) {return FITSTabular::tableDesc(*dapblock_p[whichId]);} 00141 00142 // get the currentRow of the indicated sampler/manager ID - the value returned 00143 // by prepare 00144 const Record &dapRecord(Int whichId) {return dapblock_p[whichId]->unhandledFields();} 00145 00146 private: 00147 // how man rows are ready to be filled 00148 Int rowsToFill_p; 00149 00150 // this maps the manager+sampler string to an integer 00151 SimpleOrderedMap<String, Int> dapmap_p; 00152 00153 // this is where the DAPs for each manager+sampler string are held 00154 PtrBlock<GBTDAPFile *> dapblock_p; 00155 00156 // This indicates that a particular DAP file is ready to fill 00157 // This is set to True on a successfull prepare and set to False when filled 00158 Block<Int> readyToFill_p; 00159 00160 // how many active DAPs do we have 00161 uInt ndap_p; 00162 00163 // which one is the next row waiting to be filled 00164 Int currentPtr_p; 00165 MVTime ctime_p; 00166 00167 // and empty record, to be returned as needed 00168 Record emptyRecord_p; 00169 String emptyString_p; 00170 00171 // find the minimum currentTime from the known DAP files 00172 MVTime minTime() const; 00173 }; 00174 00175 00176 #endif 00177 00178