LCOV - code coverage report
Current view: top level - singledishfiller/Filler - ReaderInterface.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 25 0.0 %
Date: 2024-10-12 00:35:29 Functions: 0 11 0.0 %

          Line data    Source code
       1             : /*
       2             :  * ReaderInterface.h
       3             :  *
       4             :  *  Created on: Jan 5, 2016
       5             :  *      Author: nakazato
       6             :  */
       7             : 
       8             : #ifndef SINGLEDISH_FILLER_READERINTERFACE_H_
       9             : #define SINGLEDISH_FILLER_READERINTERFACE_H_
      10             : 
      11             : // std includes
      12             : #include <string>
      13             : 
      14             : #include <casacore/casa/Containers/Record.h>
      15             : #include <casacore/measures/Measures/MDirection.h>
      16             : #include <casacore/tables/Tables/TableRecord.h>
      17             : #include <casacore/measures/Measures/Stokes.h>
      18             : #include <casacore/tables/Tables/Table.h>
      19             : #include <casacore/tables/Tables/ScaColDesc.h>
      20             : #include <casacore/tables/Tables/SetupNewTab.h>
      21             : 
      22             : #include <singledishfiller/Filler/AntennaRecord.h>
      23             : #include <singledishfiller/Filler/DataRecord.h>
      24             : #include <singledishfiller/Filler/FieldRecord.h>
      25             : #include <singledishfiller/Filler/FillerUtil.h>
      26             : #include <singledishfiller/Filler/ObservationRecord.h>
      27             : #include <singledishfiller/Filler/ProcessorRecord.h>
      28             : #include <singledishfiller/Filler/SourceRecord.h>
      29             : #include <singledishfiller/Filler/SpectralWindowRecord.h>
      30             : 
      31             : namespace casa { //# NAMESPACE CASA - BEGIN
      32             : 
      33             : // forward declaration
      34             : template<class T> class NullOptionalTables;
      35             : 
      36             : // NonCopyable Mixin (CRTP)
      37             : template<class T>
      38             : class NonCopyable {
      39             : protected:
      40           0 :   NonCopyable() {
      41           0 :   }
      42           0 :   ~NonCopyable() {
      43           0 :   }
      44             : private:
      45             :   NonCopyable(NonCopyable const &) {
      46             :   }
      47             :   T &operator=(T const &) {
      48             :   }
      49             : };
      50             : 
      51             : class ReaderInterface: private NonCopyable<ReaderInterface> {
      52             : public:
      53             :   // OptionalTables must have a public static method, Generate,
      54             :   // whose signature is as follows:
      55             :   //
      56             :   // static void Generate(casacore::Table &, Reader const &)
      57             :   //
      58             :   // OptionalTables::Generate is responsible for generating
      59             :   // optional subtables that stores supplemental information
      60             :   // not being able to stored into any other tables.
      61             :   // NullOptionalTables is an implementation of "do nothing".
      62             :   using OptionalTables = NullOptionalTables<ReaderInterface>;
      63             : 
      64           0 :   ReaderInterface(std::string const &name) :
      65           0 :     name_(name) {
      66           0 :   }
      67             : 
      68           0 :   virtual ~ReaderInterface() {
      69           0 :   }
      70             : 
      71           0 :   std::string const &getName() const {
      72           0 :     return name_;
      73             :   }
      74             : 
      75             :   // getDataUnit should return a string representing the unit
      76             :   // of the data. If physical unit is not yet set (e.g. before
      77             :   // calibration), please return empty sting.
      78             :   virtual casacore::String getDataUnit() const = 0;
      79             : 
      80             :   // isFloatData should return
      81             :   // *True* if resulting MS should have FLOAT_DATA column, while
      82             :   // *False* if the MS require DATA column instead
      83             :   virtual casacore::Bool isFloatData() const = 0;
      84             : 
      85             :   // getDirectionFrame should return appropriate direction
      86             :   // frame information as a form of MDirection::Types enum
      87             :   virtual casacore::MDirection::Types getDirectionFrame() const = 0;
      88             : 
      89           0 :   void initialize() {
      90           0 :     initializeCommon();
      91           0 :     initializeSpecific();
      92           0 :   }
      93             : 
      94           0 :   void finalize() {
      95           0 :     finalizeCommon();
      96           0 :     finalizeSpecific();
      97           0 :   }
      98             : 
      99             :   // get number of rows for MAIN table
     100             :   virtual size_t getNumberOfRows() const = 0;
     101             : 
     102             :   // to get OBSERVATION table
     103             :   // The method should return true if row entry is available.
     104             :   // If it return false, row will be invalid so it should not be used.
     105             :   virtual casacore::Bool getObservationRow(sdfiller::ObservationRecord &record) = 0;
     106             : 
     107             :   // to get ANTENNA table
     108             :   // The method should return true if row entry is available.
     109             :   // If it return false, row will be invalid so it should not be used.
     110             :   virtual casacore::Bool getAntennaRow(sdfiller::AntennaRecord &record) = 0;
     111             : 
     112             :   // to get PROCESSOR table
     113             :   // The method should return true if row entry is available.
     114             :   // If it return false, row will be invalid so it should not be used.
     115             :   virtual casacore::Bool getProcessorRow(sdfiller::ProcessorRecord &record) = 0;
     116             : 
     117             :   // to get SOURCE table
     118             :   // The method should return true if row entry is available.
     119             :   // If it return false, row will be invalid so it should not be used.
     120             :   virtual casacore::Bool getSourceRow(sdfiller::SourceRecord &row) = 0;
     121             : 
     122             :   // to get FIELD table
     123             :   // The method should return true if row entry is available.
     124             :   // If it return false, row will be invalid so it should not be used.
     125             :   virtual casacore::Bool getFieldRow(sdfiller::FieldRecord &row) = 0;
     126             : 
     127             :   // to get SPECTRAL WINDOW table
     128             :   // The method should return true if row entry is available.
     129             :   // If it return false, row will be invalid so it should not be used.
     130             :   virtual casacore::Bool getSpectralWindowRow(sdfiller::SpectralWindowRecord &row) = 0;
     131             : 
     132             :   // for DataAccumulator
     133             :   virtual casacore::Bool getData(size_t irow, sdfiller::DataRecord &record) = 0;
     134             : 
     135             : protected:
     136             :   virtual void initializeSpecific() = 0;
     137             :   virtual void finalizeSpecific() = 0;
     138             : 
     139             :   std::string const name_;
     140             : 
     141             : private:
     142             :   // common initialization/finalization actions
     143           0 :   void initializeCommon() {
     144           0 :   }
     145           0 :   void finalizeCommon() {
     146           0 :   }
     147             : };
     148             : 
     149             : // empty OptionalTables class
     150             : template<class Reader>
     151             : class NullOptionalTables {
     152             : public:
     153           0 :   static void Generate(casacore::Table &/*table*/, Reader const &/*reader*/) {
     154             :     //std::cout << "This is default. NullOptionalTables::Generate" << std::endl;
     155           0 :   }
     156             : };
     157             : 
     158             : } //# NAMESPACE CASA - END
     159             : 
     160             : #endif /* SINGLEDISH_FILLER_READERINTERFACE_H_ */

Generated by: LCOV version 1.16