00001 /* 00002 * ReaderInterface.h 00003 * 00004 * Created on: Jan 5, 2016 00005 * Author: nakazato 00006 */ 00007 00008 #ifndef SINGLEDISH_FILLER_READERINTERFACE_H_ 00009 #define SINGLEDISH_FILLER_READERINTERFACE_H_ 00010 00011 // std includes 00012 #include <string> 00013 00014 #include <singledish/Filler/FillerUtil.h> 00015 #include <singledish/Filler/AntennaRecord.h> 00016 #include <singledish/Filler/ObservationRecord.h> 00017 #include <singledish/Filler/ProcessorRecord.h> 00018 #include <singledish/Filler/FieldRecord.h> 00019 #include <singledish/Filler/SourceRecord.h> 00020 #include <singledish/Filler/SpectralWindowRecord.h> 00021 #include <singledish/Filler/DataRecord.h> 00022 00023 // casacore includes 00024 #include <casacore/casa/Containers/Record.h> 00025 #include <casacore/measures/Measures/MDirection.h> 00026 #include <casacore/tables/Tables/TableRecord.h> 00027 00028 namespace casa { //# NAMESPACE CASA - BEGIN 00029 00030 // NonCopyable Mixin (CRTP) 00031 template<class T> 00032 class NonCopyable { 00033 protected: 00034 NonCopyable() { 00035 } 00036 ~NonCopyable() { 00037 } 00038 private: 00039 NonCopyable(NonCopyable const &) { 00040 } 00041 T &operator=(T const &) { 00042 } 00043 }; 00044 00045 class ReaderInterface: private NonCopyable<ReaderInterface> { 00046 public: 00047 ReaderInterface(std::string const &name, bool const is_nro = false) : 00048 name_(name), is_nro_(is_nro) { 00049 } 00050 00051 virtual ~ReaderInterface() { 00052 } 00053 00054 std::string const &getName() const { 00055 return name_; 00056 } 00057 00058 bool isNROData() { 00059 return is_nro_; 00060 } 00061 00062 virtual int getNROArraySize() { 00063 return 0; 00064 } 00065 virtual int getNRONumBeam() { 00066 return 0; 00067 } 00068 virtual int getNRONumPol() { 00069 return 0; 00070 } 00071 virtual int getNRONumSpw() { 00072 return 0; 00073 } 00074 00075 virtual Bool isFloatData() const { 00076 return False; 00077 } 00078 00079 virtual MDirection::Types getDirectionFrame() const { 00080 return MDirection::J2000; 00081 } 00082 00083 void initialize() { 00084 initializeCommon(); 00085 initializeSpecific(); 00086 } 00087 00088 void finalize() { 00089 finalizeCommon(); 00090 finalizeSpecific(); 00091 } 00092 00093 // get number of rows for MAIN table 00094 virtual size_t getNumberOfRows() = 0; 00095 00096 // to get OBSERVATION table 00097 // The method should return True if row entry is available. 00098 // If it return False, row will be invalid so it should not be used. 00099 virtual Bool getObservationRow(sdfiller::ObservationRecord &record) = 0; 00100 00101 // to get ANTENNA table 00102 // The method should return True if row entry is available. 00103 // If it return False, row will be invalid so it should not be used. 00104 virtual Bool getAntennaRow(sdfiller::AntennaRecord &record) = 0; 00105 00106 // to get PROCESSOR table 00107 // The method should return True if row entry is available. 00108 // If it return False, row will be invalid so it should not be used. 00109 virtual Bool getProcessorRow(sdfiller::ProcessorRecord &record) = 0; 00110 00111 // to get SOURCE table 00112 // The method should return True if row entry is available. 00113 // If it return False, row will be invalid so it should not be used. 00114 virtual Bool getSourceRow(sdfiller::SourceRecord &row) = 0; 00115 00116 // to get FIELD table 00117 // The method should return True if row entry is available. 00118 // If it return False, row will be invalid so it should not be used. 00119 virtual Bool getFieldRow(sdfiller::FieldRecord &row) = 0; 00120 00121 // to get SPECTRAL WINDOW table 00122 // The method should return True if row entry is available. 00123 // If it return False, row will be invalid so it should not be used. 00124 virtual Bool getSpectralWindowRow(sdfiller::SpectralWindowRecord &row) = 0; 00125 00126 // for DataAccumulator 00127 virtual Bool getData(size_t irow, sdfiller::DataRecord &record) = 0; 00128 00129 protected: 00130 virtual void initializeSpecific() = 0; 00131 virtual void finalizeSpecific() = 0; 00132 00133 std::string const name_; 00134 bool const is_nro_; 00135 00136 private: 00137 // common initialization/finalization actions 00138 void initializeCommon() { 00139 } 00140 void finalizeCommon() { 00141 } 00142 }; 00143 00144 } //# NAMESPACE CASA - END 00145 00146 #endif /* SINGLEDISH_FILLER_READERINTERFACE_H_ */