LCOV - code coverage report
Current view: top level - alma/ASDMBinaries - SDMDataObject.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 29 46 63.0 %
Date: 2025-12-19 19:56:21 Functions: 11 21 52.4 %

          Line data    Source code
       1             : #ifndef SDMDataObject_CLASS
       2             : #define SDMDataObject_CLASS
       3             : 
       4             : #include <string>
       5             : #include <set>
       6             : #include <vector>
       7             : #include <map>
       8             : #include <sstream>
       9             : 
      10             : #ifdef WITHOUT_ACS
      11             : #else
      12             : #include "almaEnumerations_IFC.h"
      13             : #endif
      14             : 
      15             : #include <alma/ASDMBinaries/SDMDataObjectPartTypes.h>
      16             : 
      17             : #include <alma/Enumerations/CAtmPhaseCorrection.h>
      18             : #include <alma/Enumerations/CAxisName.h>
      19             : #include <alma/Enumerations/CBasebandName.h>
      20             : #include <alma/Enumerations/CCorrelationMode.h>
      21             : #include <alma/Enumerations/CPrimitiveDataType.h>
      22             : #include <alma/Enumerations/CSpectralResolutionType.h>
      23             : #include <alma/Enumerations/CProcessorType.h>
      24             : #include <alma/Enumerations/CCorrelatorType.h>
      25             : #include <alma/Enumerations/CStokesParameter.h>
      26             : #include <alma/Enumerations/CNetSideband.h>
      27             : 
      28             : #include <regex>
      29             : 
      30             : #ifdef REG_BASIC
      31             : #undef REG_BASIC
      32             : #endif
      33             : 
      34             : #ifdef REG_EXTENDED 
      35             : #undef REG_EXTENDED
      36             : #endif 
      37             : 
      38             : #ifdef REG_ICASE
      39             : #undef REG_ICASE
      40             : #endif
      41             : 
      42             : #ifdef REG_NOSUB
      43             : #undef REG_NOSUB
      44             : #endif
      45             : 
      46             : #ifdef REG_NEWLINE
      47             : #undef REG_NEWLINE
      48             : #endif
      49             : 
      50             : #ifdef REG_NOTBOL
      51             : #undef REG_NOTBOL
      52             : #endif
      53             : 
      54             : #ifdef REG_NOTEOL
      55             : #undef REG_NOTEOL
      56             : #endif
      57             : 
      58             : #ifdef REG_STARTEND
      59             : #undef REG_STARTEND
      60             : #endif
      61             : 
      62             : #ifdef REG_NOERROR
      63             : #undef REG_NOERROR
      64             : #endif
      65             : 
      66             : #ifdef REG_NOMATCH
      67             : #undef REG_NOMATCH
      68             : #endif
      69             : 
      70             : #ifdef REG_BADPAT
      71             : #undef REG_BADPAT
      72             : #endif
      73             : 
      74             : #ifdef REG_ECOLLATE
      75             : #undef REG_ECOLLATE
      76             : #endif
      77             : 
      78             : #if defined(__APPLE__)
      79             : #include <machine/endian.h>
      80             : #else 
      81             : #include <endian.h>
      82             : #endif
      83             : 
      84             : /**
      85             :  * @mainpage
      86             :  *
      87             :  * This is the documentation of a set of C++ classes dedicated to the processing of ALMA binary data. 
      88             :  * 
      89             :  * @section low-level Low level classes.
      90             :  * All those classess are grouped under the same namespace asdmbinaries.
      91             :  * ALMA binary data are kept on storage media in files whose content is formally
      92             :  * described by <b>the Science Data Model Binary Data Format</b> (BDF). The so called low level classes documented here
      93             :  * provide their users with an in-memory representation of those ALMA binary data and tools to write BDF files from
      94             :  * such representations and conversely to build in-memory representations from BDF files in a given number of use cases.
      95             :  *
      96             :  * <ul>
      97             :  * <li> asdmbinaries::SDMDataObject is a class to represent in-memory ALMA binary data.</li>
      98             :  * <li> asdmbinaries::SDMDataObjectWriter is a class to build an SDMDataObject and to write it as a BDF document. </li>
      99             :  * <li> asdmbinaries::SDMDataObjectReader is a class to read entirely in memory a BDF document and to parse it into an SDMDataObject. </li>
     100             :  * <li> asdmbinaries::SDMDataObjectStreamReader is a class to read sequentially a BDF document and to parse it sequentially into an SDMDataObject. </li>
     101             :  * </ul>
     102             :  * 
     103             :  * 
     104             :  */
     105             : 
     106             : /**
     107             :  * The asdmbinaries namespace contains all the classes dedicated to the processing of ALMA binary data.
     108             :  */
     109             : namespace asdmbinaries {
     110             : 
     111             :   /**
     112             :    * The XML schema version of the XML instances that those classes claim to be compatible with.
     113             :    */
     114             :   const int SCHEMAVERSION=2;
     115             : 
     116             : 
     117             :   /**
     118             :    * A class to represent an exception thrown during an access to an SDMDataObject. 
     119             :    */ 
     120             :   class SDMDataObjectException {
     121             :     
     122             :   public:
     123             :     /**
     124             :      * An empty contructor.
     125             :      */
     126             :     SDMDataObjectException();
     127             : 
     128             :     /**
     129             :      * A constructor with a message associated with the exception.
     130             :      * @param m a string containing the message.
     131             :      */
     132             :     SDMDataObjectException(const std::string& m);
     133             :     
     134             :     /**
     135             :      * The destructor.
     136             :      */
     137             :     virtual ~SDMDataObjectException();
     138             : 
     139             :     /**
     140             :      * Returns the message associated to this exception.
     141             :      * @return a string.
     142             :      */
     143             :     std::string getMessage() const;
     144             :     
     145             :   protected:
     146             :     std::string message;
     147             :     
     148             :   };
     149             : 
     150             :   inline SDMDataObjectException::SDMDataObjectException() : message ("SDMDataObjectReaderException") {}
     151           0 :   inline SDMDataObjectException::SDMDataObjectException(const std::string& m) : message(m) {}
     152           0 :   inline SDMDataObjectException::~SDMDataObjectException() {}
     153           0 :   inline std::string SDMDataObjectException::getMessage() const {
     154           0 :     return "SDMDataObjectException : " + message;
     155             :   }
     156             :   
     157             :   /**
     158             :    * \defgroup optional Material related to optional values.
     159             :    */
     160             : 
     161             :   /**
     162             :    * \ingroup optional
     163             :    * A class to embed optional information.
     164             :    *
     165             :    */
     166             :   template<class Enum, class EnumHelper> 
     167             :     class Optional {
     168             :     private:
     169             :     bool present_;
     170             :     Enum literal_;
     171             :     
     172             :     public:
     173             :     /**
     174             :      * The empty constructor.
     175             :      * 
     176             :      * To be used whenever an optional value has to be declared as absent.
     177             :      */
     178        1472 :     Optional() {
     179        1472 :       present_=false;
     180        1472 :     }
     181             :     
     182             :     /**
     183             :      * The full constructor.
     184             :      *
     185             :      * To be used whenever an optional value has to be declared as present.
     186             :      *
     187             :      * @param literal the value of type Enum to embed in the Optional class.
     188             :      */
     189        3491 :     Optional(Enum literal) {
     190        3491 :       literal_ = literal;
     191        3491 :       present_ = true;
     192        3491 :     }
     193             :     
     194             :     /**
     195             :      * Test of presence.
     196             :      *
     197             :      * @return true (resp. false)  if this represents a present (resp. false) optional value.
     198             :      */
     199         536 :     bool present() const { return present_; }
     200             : 
     201             :     /**
     202             :      * Returns the optional value 
     203             :      *
     204             :      * @return an Enum
     205             :      *
     206             :      * @note the returned value is meaningful if and only if present() == true !
     207             :      *
     208             :      */
     209         536 :     Enum literal() const { return literal_; }
     210             :   };
     211             : 
     212             :   /**
     213             :    * \ingroup optional
     214             :    * A typedef definition for an optional spectral resolution type.
     215             :    *
     216             :    */
     217             :   typedef Optional<SpectralResolutionTypeMod::SpectralResolutionType, CSpectralResolutionType> OptionalSpectralResolutionType;
     218             : 
     219             : 
     220             :   /**
     221             :    * A class to represent byte order information.
     222             :    *
     223             :    */
     224             :   class ByteOrder {
     225             :   public:
     226             :     static const ByteOrder* Little_Endian; /*< A unique object to represent a little endian byte order. */
     227             :     static const ByteOrder* Big_Endian;    /*< A unique object to represent a big endian byte order. */
     228             :     static const ByteOrder* Machine_Endianity; /*< A unique object storing the endianity of the machine. */
     229             : 
     230             :     /**
     231             :      * Returns a string representation of this.
     232             :      *
     233             :      * <ul>
     234             :      * <li> Little_Endian is returned as "Little_Endian", </li>
     235             :      * <li> Big_Endian is returned as "Big_Endian", </li>
     236             :      * </ul>
     237             :      */
     238             :     std::string toString() const ;
     239             : 
     240             :   private:
     241             :     std::string name_;
     242             : 
     243             :     ByteOrder(const std::string & name);
     244             :     virtual ~ByteOrder();
     245             :     static const ByteOrder* machineEndianity(); 
     246             :   };
     247             : 
     248             :   // forward declarations.
     249             :   class SDMDataSubset;
     250             :   class SDMDataObject;
     251             : 
     252             : 
     253             :   
     254             :   class SDMDataObjectReader;
     255             : 
     256             :   // SDMDataObject:: declarations
     257             :   //
     258             : 
     259             :   /**
     260             :    * A class to represent ALMA binary data.
     261             :    * Three situations can be handled by this class:
     262             :    * <ul>
     263             :    * <li> Correlator data </li>
     264             :    * <li> Total power data </li>
     265             :    * <li> WVR data </li>
     266             :    * </ul>
     267             :    *
     268             :    * At the time of writing:
     269             :    * <ul>
     270             :    * <li> Correlator data (isCorrelation() returns true) are stored in an SDMDataObject which is organized as a global header containing descriptive informations
     271             :    * valid for all the recorded binary data, followed by a sequence of SDMDataSubsets - local header, binary data pairs - . Each SDMDataSubset
     272             :    * corresponds to one integration and the full SDMDataObject corresponds to one subscan  (hasPackedData returns false).
     273             :    *
     274             :    * <li> Total Power (TP) data (isTP() returns true) are stored like Correlator data i.e in a sequence of SDMDataSubsets (hasPackedData() returns false) <b>or</b> for TP data recorded before Cycle 3 
     275             :    * in a SDMDataObject containing the global header followed by <b>one unique</b> SDMDataSubset containing the data recorded during the whole subscan (hasPackedData() returns true). 
     276             :    * </li>
     277             :    *
     278             :    * <li> WVR data (isWVR() returns true) are stored in an SDMDataObject organized as one global header followed by <b>one unique</b> SDMDataSubset containing the data recorded during the whole subscan (hasPackedData() returns true). 
     279             :    *
     280             :    * <ul> 
     281             :    *
     282             :    * An instance of an SDMDataObject is never created explicitely by calling some constructors or setters methods. Instances
     283             :    * of SDMDataObject are rather created implicitely :
     284             :    * <ul>
     285             :    * <li> on output, while creating a MIME message containing ALMA binary data by using the class SDMDataObjectWriter; actual parameters passed to methods of this class are assembled together to
     286             : form an SDMDataObject which is in turn converted into a MIME message, </li>
     287             :    * <li> on input, while reading a MIME message containing ALMA binary data by using the class SDMDataObjectReader; the result of the parsing of the MIME message is returned in an SDMDataObject. </li>
     288             :    * </ul>
     289             :    * 
     290             :    * @section content-access Accessing the different parts of an SDMDataObject.
     291             :    * We give here a quick list of the method which allows to retrieve the different parts of an SDMDataObject :
     292             :    * <ul>
     293             :    * <li>title() : the general title for these binary data.</li>
     294             :    * <li>startTime() : Epoch when started the observation for the data collected in this SDMDataObject. This must be equal to the mid-point interval minus half the interval of the first data dump.
     295             :    * <li>numTime() : number of (sub)integrations stored in this SDMDataObject. </li>
     296             :    * <li>dataOID() : Data object identifier given to this SDMDataObject once it's been converted into a MIME message and archived in the bulkstore.
     297             :    * <li>execBlockUID() : the archive UID of the exec block.
     298             :    * <li>execBlockNum() : the execblock number (one-based). </li>
     299             :    * <li>scanNum() : the scan number (one-based). </li>
     300             :    * <li>subscanNum() : the subscan number (one-based). </li>
     301             :    * <li>projectPath() : a string built from the string representations of execBlockNum, scanNum and subscanNum prefixed with '/' characters. E.g. if execBlockNum==10 && scanNum==1 &&  subscanNum==1
     302             :    * then projectPath=="/10/1/1".</li>
     303             :    * <li>numAntenna() : Number of antenna scheduled to produce the data.</li>
     304             :    * <li>correlationMode() : the correlation mode encoded as a value of the enumeration CorrelationMode.</li>
     305             :    * <li>spectralResolutionType() : the type of spectral resolution defined as a value of the enumeration SpectralResolutionType.</li>
     306             :    * <li>dataStruct() : a instance of DataStruct describing the structure of the binary data.</li>
     307             :    * <li>sdmDataSubsets() : a reference to the vector of SDMDataSubsets contained in this. This should be the preferred method to retrieve
     308             :    *  the data independantly of their origin (Correlator, TP, WVR). The rignt way to interpret the reference to the vector of 
     309             :    * SDMDataSubsets  will be driven by an appropriate utilization of isCorrelation(), isTP(), isWVR() and hasPackedData(). </li>
     310             :    * <li>corrDataSubsets() : a vector of SDMDataSubset containing the collection of (sub) integrations in the case of correlator data.
     311             :    * Use preferably sdmDataSubsets(). </li>
     312             :    * <li>sdmDataSubset() : an SDMDataSubset given its project path.
     313             :    * <li>tpDataSubset() : a single SDMDataSubset containing all the binary data of a subscan in the case of total power data. To be used 
     314             :    * <b>only</b> when TP data are stored in one unique subset. Use preferably sdmDataSubsets()</li>
     315             :    * </ul>
     316             :    *
     317             :    */ 
     318             : 
     319             :   class SDMDataObject {
     320             :     friend class SDMDataObjectStreamReader;
     321             :     friend class SDMDataObjectReader;
     322             :     friend class SDMDataObjectWriter;
     323             :     friend class HeaderParser;
     324             :     friend class SDMDataSubset;
     325             :     friend class CorrSubsetHeaderParser;
     326             : 
     327             :   public:
     328             : 
     329             :     // SDMDataObject::SpectralWindow:: declarations
     330             :     //
     331             :     /**
     332             :      * A class to describe a spectral window in use during an observation.
     333             :      * An instance of this class collects the following informations :
     334             :      * <ul>
     335             :      * <li> The description of polarization products for the interferometric data , if any (crossPolProducts()). </li>
     336             :      * <li> The description of polarization products for the single dish data , if any (sdPolProducts()). </li>
     337             :      * <li> The scale factor used in the representation of spectral visibilities, if any (scaleFactor()).</li>
     338             :      * <li> The number of spectral points (numSpectralPoint()).</li>
     339             :      * <li> The number of bins (numBin()). </li>
     340             :      * </ul>
     341             :      *
     342             :      */
     343             :     class SpectralWindow {
     344             :       friend class SDMDataObject;
     345             :       friend class DataStruct;
     346             :       friend class Baseband;
     347             :       friend class HeaderParser;
     348             : 
     349             :     private:
     350             :       std::vector<StokesParameterMod::StokesParameter> crossPolProducts_;
     351             :       std::vector<StokesParameterMod::StokesParameter> sdPolProducts_;
     352             :       float scaleFactor_;
     353             :       unsigned int numSpectralPoint_;
     354             :       unsigned int numBin_;
     355             :       NetSidebandMod::NetSideband sideband_;
     356             :       std::string strSw_;
     357             :       std::string strImage_;
     358             :       void strSw(const std::string& s);
     359             :       const std::string & strSw() const;
     360             :       void strImage(const std::string& s);
     361             :       const std::string & strImage() const;
     362             : 
     363             :       const SDMDataObject* owner_;
     364             : 
     365             :       void owner(const SDMDataObject* o);
     366             : 
     367             :     public:
     368             :       /**
     369             :        * An empty constructor.
     370             :        * 
     371             :        * @note This constructor should never be used.
     372             :        */
     373             :       SpectralWindow();
     374             : 
     375             : 
     376             :       /**
     377             :        * The destructor.
     378             :        */
     379             :       virtual ~SpectralWindow();
     380             : 
     381             :       /**
     382             :        * A constructor of SpectralWindow to use when there are only interferometric data (correlationMode == CROSS_ONLY).
     383             :        */
     384             :       SpectralWindow(const std::vector<StokesParameterMod::StokesParameter>& crossPolProducts,
     385             :                      float scaleFactor,
     386             :                      unsigned int numSpectralPoint,
     387             :                      unsigned int numBin,
     388             :                      NetSidebandMod::NetSideband sideband);
     389             : 
     390             :       /**
     391             :        * A constructor of SpectralWindow to use when there are only single dish data (correlationMode == AUTO_ONLY).
     392             :        */
     393             :       SpectralWindow(const std::vector<StokesParameterMod::StokesParameter>& sdPolProducts,
     394             :                      unsigned int numSpectralPoint,
     395             :                      unsigned numBin,
     396             :                      NetSidebandMod::NetSideband sideband);
     397             : 
     398             :       /**
     399             :        * A constructor of SpectralWindow to use when there are both single dish and  interferometric data (correlationMode == CROSS_AND_AUTO).
     400             :        */
     401             :       SpectralWindow(const std::vector<StokesParameterMod::StokesParameter>& crossPolProducts,
     402             :                      const std::vector<StokesParameterMod::StokesParameter>& sdPolProduct,
     403             :                      float scaleFactor,
     404             :                      unsigned int numSpectralPoint,
     405             :                      unsigned int numBin,
     406             :                      NetSidebandMod::NetSideband sideband);
     407             : 
     408             :       /**
     409             :        * Returns the vector of polarization products (for the interferometric data).
     410             :        * @return a reference to a vector of StokesParameter.
     411             :        *
     412             :        * @throw SDMDataObjectException when correlationMode() == AUTO_ONLY.
     413             :        */
     414             :       const std::vector<StokesParameterMod::StokesParameter>& crossPolProducts() const;
     415             :       //void crossPolProducts(const vector<StokesParameter>& value);
     416             : 
     417             :       /**
     418             :        * Returns the vector of polarization products (for the single dish data).
     419             :        * @return a reference to a vector of StokesParameter.
     420             :        *
     421             :        * @throw SDMDataObjectException when correlationMode() == CROSS_ONLY.
     422             :        */
     423             :       const std::vector<StokesParameterMod::StokesParameter>& sdPolProducts() const;
     424             :       //void sdPolProducts(const vector<StokesParameter>& value);
     425             : 
     426             :       /**
     427             :        * Returns the scale factor.
     428             :        * @return a float.
     429             :        *
     430             :        * @throw SDMDataObjectException when correlationMode() == AUTO_ONLY.
     431             :        * 
     432             :        */
     433             :       float scaleFactor() const;
     434             :       //void scaleFactor(float value);
     435             : 
     436             :       /**
     437             :        * Returns the number of spectral points.
     438             :        * @return an unsigned int.
     439             :        */
     440             :       unsigned int numSpectralPoint() const;
     441             :       //void numSpectralPoint(unsigned int value);
     442             : 
     443             :       /**
     444             :        * Returns the number of bins.
     445             :        * For ALMA this is the number of steps in a switch-cycle and a value of 1 means no switching cycle.
     446             :        * @return an unsigned int.
     447             :        *
     448             :        */
     449             :       unsigned int numBin() const;
     450             :       //void numBin(unsigned int value);
     451             : 
     452             :       /**
     453             :        * Returns the netsideband.
     454             :        *
     455             :        * @return a NetSidebandMod::NetSideband
     456             :        */ 
     457             :       NetSidebandMod::NetSideband sideband() const;
     458             : 
     459             :     }; // SpectralWindow::
     460             : 
     461             : 
     462             :     // SDMDataObject::Baseband:: declarations
     463             :     //
     464             :     /**
     465             :      * A class to describe a baseband in use during an observation.
     466             :      * 
     467             :      * An instance of this class collects the following informations:
     468             :      * <ul>
     469             :      * <li> possibly a name (ref()).
     470             :      * <li> the description of one or many spectral windows (spectralWindows()).
     471             :      * </ul>
     472             :      *
     473             :      */
     474             :     class Baseband {
     475             :       friend class SDMDataObject;
     476             :       friend class DataStruct;
     477             :       friend class HeaderParser;
     478             : 
     479             :     private:
     480             :       BasebandNameMod::BasebandName name_;
     481             :       std::vector<SpectralWindow> spectralWindows_;
     482             : 
     483             :       const SDMDataObject* owner_;
     484             : 
     485             :       void owner(const SDMDataObject* o);
     486             : 
     487             :     public:
     488             :       /**
     489             :        * An empty constructor.
     490             :        *
     491             :        * @note This constructor should never be used.
     492             :        */
     493             :       Baseband();
     494             : 
     495             :       /**
     496             :        * The destructor.
     497             :        */
     498             :       ~Baseband();
     499             : 
     500             :       /**
     501             :        * The constructor of Baseband.
     502             :        */
     503             :       Baseband(BasebandNameMod::BasebandName name, const std::vector<SpectralWindow>& spectralWindows);
     504             : 
     505             :       /**
     506             :        * Returns the name of the baseband.
     507             :        * @return a BasebandName value.
     508             :        */
     509             :       BasebandNameMod::BasebandName name() const;
     510             :       //void ref(BasebandName value);
     511             : 
     512             :       /**
     513             :        * Returns the spectral windows of this baseband.
     514             :        * @return a reference to a vector of SpectralWindow.
     515             :        */
     516             :       const std::vector<SpectralWindow>& spectralWindows() const;
     517             :       void spectralWindows(const std::vector<SpectralWindow>& value);
     518             :     }; // Baseband::
     519             : 
     520             : 
     521             :     // SDMDataObject::BinaryPart:: declarations
     522             :     //
     523             :     /**
     524             :      * A class to describe binary data, i.e. :
     525             :      * <ul>
     526             :      * <li> flags. </li>
     527             :      * <li> actualTimes. </li>
     528             :      * <li> actualDurations. </li>
     529             :      * <li> zeroLags. </li>
     530             :      * <li> crossData. </li>
     531             :      * <li> autoData. </li>
     532             :      * </ul>
     533             :      *
     534             :      * An instance of this class collects information about :
     535             :      * <ul>
     536             :      * <li> The size of the binary part i.e. the number of values that it contains. (e.g. the number of float numbers in the case of autoData). (size()) </li>
     537             :      * <li> The ordered list of the names of axis of the hierarchical structure which contains these binary data. (axes())</li>
     538             :      * </ul>
     539             :      */
     540             :     class BinaryPart {
     541             :       friend class DataStruct;
     542             :       friend class SDMDataObject;
     543             :       friend class HeaderParser;
     544             :       friend class SDMDataObjectWriter;
     545             : 
     546             :     protected:
     547             :       unsigned int size_;
     548             :       std::vector<AxisNameMod::AxisName> axes_;
     549             : 
     550             :       const SDMDataObject* owner_;
     551             :     
     552             :       void owner(const SDMDataObject* o);
     553             :     public:
     554             : 
     555             :       /**
     556             :        * An empty constructor.
     557             :        */
     558             :       BinaryPart();
     559             : 
     560             :       /**
     561             :        * The destructor.
     562             :        */
     563             :       virtual ~BinaryPart();
     564             : 
     565             :       /**
     566             :        * The full constructor.
     567             :        */
     568             :       BinaryPart( unsigned int size,
     569             :                   const std::vector<AxisNameMod::AxisName>& axes);
     570             :       
     571             :       /**
     572             :        * Returns the size of a binary attachment as a <b>number of values</b> (e.g. a number of long long for the actualDurations, or 
     573             :        * a number of short int for crossData when they are encoded as short ints).
     574             :        */
     575             :       virtual unsigned int size() const; 
     576             :       //      virtual void size (unsigned int value); 
     577             :       
     578             :       /**
     579             :        * Returns a vector of axis names.
     580             :        * The vector contains the list of axis names relevant for this binary part ordered from the less (1st) to the more (last)
     581             :        * rapidly varying.
     582             :        * @return a vector of AxisName.
     583             :        */
     584             :       virtual const std::vector<AxisNameMod::AxisName>& axes() const ; 
     585             :       //      virtual void axes (const vector<AxisName>& axes); 
     586             :     }; // BinaryPart::
     587             : 
     588             :     /**
     589             :      * A subclass of binaryPart to describe the autodata.
     590             :      *
     591             :      * The description of autodata contains one extra information stored in a boolean which indicates
     592             :      * if the auto data are normalized or not. 
     593             :      *
     594             :      */
     595             :     class AutoDataBinaryPart : public BinaryPart {
     596             :       friend class DataStruct;
     597             :       friend class SDMDataObject;
     598             :       friend class HeaderParser;
     599             :       friend class SDMDataObjectWriter;
     600             :       
     601             :     protected:
     602             :       bool normalized_;
     603             : 
     604             :     public:
     605             :       /**
     606             :        * An empty constructor.
     607             :        */
     608             :       AutoDataBinaryPart();
     609             :       
     610             :       /**
     611             :        * The destructor.
     612             :        */
     613             :       ~AutoDataBinaryPart();
     614             :       
     615             :       /**
     616             :        * The full constructor.
     617             :        */
     618             :       AutoDataBinaryPart(unsigned int size,
     619             :                          const std::vector<AxisNameMod::AxisName>& axes,
     620             :                          bool normalized);
     621             :       
     622             :       /**
     623             :        * Returns true (resp.false) if auto data are normalized (resp. not normalized).
     624             :        * @return a boolean.
     625             :        */
     626             :       virtual bool normalized() const;
     627             :       
     628             :     }; // AutoDataBinaryPart
     629             :     
     630             :     /**
     631             :      * A subclass of binaryPart to describe the zeroLags.
     632             :      *
     633             :      * The description of zeroLags contains one extra information stored in a CorrelatorType field which indicates
     634             :      * the type of correlator which has produced them.
     635             :      *
     636             :      */
     637             :     class ZeroLagsBinaryPart : public BinaryPart {
     638             :       friend class DataStruct;
     639             :       friend class SDMDataObject;
     640             :       friend class HeaderParser;
     641             :       friend class SDMDataObjectWriter;
     642             : 
     643             :     protected:
     644             :       CorrelatorTypeMod::CorrelatorType correlatorType_;
     645             :       
     646             :     public:
     647             :       
     648             :       /**
     649             :        * An empty constructor.
     650             :        */
     651             :       ZeroLagsBinaryPart() ;
     652             : 
     653             :       /**
     654             :        * The destructor.
     655             :        */
     656             :       ~ZeroLagsBinaryPart();
     657             : 
     658             :       /**
     659             :        * The full constructor.
     660             :        */
     661             :       ZeroLagsBinaryPart(unsigned int size,
     662             :                          const std::vector<AxisNameMod::AxisName>& axes,
     663             :                          CorrelatorTypeMod::CorrelatorType correlatorType);
     664             : 
     665             :       /**
     666             :        * Returns the correlator type.
     667             :        * @return a value of the enumeration CorrelatorType.
     668             :        */
     669             :       virtual CorrelatorTypeMod::CorrelatorType correlatorType() const;
     670             :     };
     671             : 
     672             :     // SDMDataObject::DataStruct:: declarations
     673             :     //
     674             :     /**
     675             :      * A class to represent the structure of binary data.
     676             :      * An instance of this class collects informations :
     677             :      * <ul>
     678             :      * <li> about atmospheric phase correction when relevant (correlationMode != AUTO_ONLY) (apc()).</li>
     679             :      * <li> about basebands (basebands()).</li>
     680             :      * <li> about binary data (flags(), actualTimes(), actualDurations(), zeroLags(), crossData(), autoData()) .</li>
     681             :      * </ul>
     682             :      */
     683             :     class DataStruct {
     684             :       friend class SDMDataObject;
     685             :       friend class HeaderParser;
     686             :       friend class SDMDataObjectWriter;
     687             : 
     688             :     public:
     689             :       /**
     690             :        * An empty constructor.
     691             :        *
     692             :        * @note This constructor should never be used.
     693             :        */
     694             :       DataStruct();
     695             : 
     696             :       /**
     697             :        * The destructor.
     698             :        */
     699             :       virtual ~DataStruct();
     700             : 
     701             :       /**
     702             :        * A full constructor.
     703             :        *
     704             :        * @param apc a vector of AtmPhaseCorrection. If apc is not relevant pass an empty vector.
     705             :        * @param basebands a vector of Baseband.
     706             :        * @param flags a BinaryPart object describing the flags. If flags is not relevant 
     707             :        * pass an empty BinaryPart object.
     708             :        * @param actualTimes  a BinaryPart object describing the actual times. If actualTimes is not relevant 
     709             :        * pass an empty BinaryPart object.
     710             :        * @param actualDurations  a BinaryPart object describing the actual durations. If actualDurations is not relevant 
     711             :        * pass an empty BinaryPart object.
     712             :        * @param zeroLags  a ZeroLagsBinaryPart object describing the zero lags. If zeroLags is not relevant pass an empty 
     713             :        * ZeroLagsBinaryPart object.
     714             :        * @param crossData a BinaryPart object describing the cross data. If crossData is not relevant pass an empty 
     715             :        * BinaryPart object.
     716             :        * @param autoData an AutoDataBinaryPart object describing the auto data. If autoData is not relevant pass an empty 
     717             :        * AutoDataBinaryPart object.
     718             :        *
     719             :        */
     720             :       DataStruct(const std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection>& apc,
     721             :                  const std::vector<Baseband>& basebands,
     722             :                  const BinaryPart& flags,
     723             :                  const BinaryPart& actualTimes,
     724             :                  const BinaryPart& actualDurations,
     725             :                  const ZeroLagsBinaryPart& zeroLags,
     726             :                  const BinaryPart& crossData,
     727             :                  const AutoDataBinaryPart& autoData);
     728             :       
     729             :       
     730             :       /**
     731             :        * Returns the radiometric atmospheric phase correction codes.
     732             :        * @return a vector of AtmPhaseCorrectionMod::AtmPhaseCorrection.
     733             :        */       
     734             :       const std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection>& apc() const;
     735             :       //      void apc(const vector<AtmPhaseCorrectionMod::AtmPhaseCorrection>& value);
     736             : 
     737             :       /**
     738             :        * Returns the vector of basebands.
     739             :        * @return a reference to a vector of Baseband.
     740             :        */
     741             :       const std::vector<Baseband>& basebands() const;
     742             :       //      void basebands(const vector<Baseband>& value);
     743             :       
     744             :       /**
     745             :        * Returns the description the flags attachment.
     746             :        * @return a reference to a BinaryPart value.
     747             :        */
     748             :       const BinaryPart& flags() const;
     749             :       //      void flags(const BinaryPart& value);
     750             : 
     751             :       /**
     752             :        * Returns the description the actualTimes attachment.
     753             :        * @return a reference to a BinaryPart value.
     754             :        */
     755             :       const BinaryPart& actualTimes() const;
     756             :       //      void actualTimes(const BinaryPart& value);
     757             :  
     758             : 
     759             :       /**
     760             :        * Returns the description the actualDurations attachment.
     761             :        * @return a reference to a BinaryPart value.
     762             :        */
     763             :       const BinaryPart& actualDurations() const;
     764             :       //      void actualDurations(const BinaryPart& value);
     765             : 
     766             : 
     767             :       /**
     768             :        * Returns the description the zeroLags attachment.
     769             :        * @return a reference to a ZeroLagsBinaryPart value.
     770             :        */
     771             :       const ZeroLagsBinaryPart& zeroLags() const;
     772             :       //      void zeroLags(const BinaryPart& value);
     773             : 
     774             : 
     775             :       /**
     776             :        * Returns the description the crossData attachment.
     777             :        * @return a reference to a BinaryPart value.
     778             :        */
     779             :       const BinaryPart& crossData() const;
     780             :       //      void crossData(const BinaryPart& value);
     781             : 
     782             : 
     783             :       /**
     784             :        * Returns the description the autoData attachment.
     785             :        * @return a reference to an AutoDataBinaryPart value.
     786             :        */
     787             :       const AutoDataBinaryPart& autoData() const;
     788             :       //      void autoData(const BinaryPart& value);
     789             : 
     790             :       /**
     791             :        * Defines an association "spw1 has image spw2" between two spectral windows spw1 and spw2.
     792             :        * Assuming that a spectral window can be located by a pair (ibb, ispw) of integer, where ibb denotes the index of the
     793             :        * baseband this spectral window belongs to, and ispw its index in that baseband, this method declares that
     794             :        * the spectral window with coordinates (ibb, ispw1) has the spectral window with coordinates (ibb, ispw2) as an image.
     795             :        *
     796             :        * @param ibb  1st common coordinate of spw1 and spw2
     797             :        * @param ispw1 2nd coordinate of spw1.
     798             :        * @param ispw2 2nd coordinate of spw2.
     799             :        *
     800             :        * @throw SDMDataObjectException
     801             :        */
     802             :       void imageSPW(unsigned int ibb,
     803             :                     unsigned int ispw1,
     804             :                     unsigned int ispw2);
     805             : 
     806             :       /**
     807             :        * Returns a pointer to the spectral window image of a spectral window.
     808             :        * Assuming that a spectral window spw can be located by a pair (ibb, ispw) of integer, where ibb denotes the index of the
     809             :        * baseband this spectral window belongs to, and ispw its index in that baseband, this method returns
     810             :        * a pointer to the spectral window defined as the image of spw. If spw has no image defined then null is returned.
     811             :        *
     812             :        * @param ibb  1st coordinate of spw
     813             :        * @param ispw 2nd coordinate of spw
     814             :        *
     815             :        * @throw SDMDataObjectException
     816             :        */
     817             :       const SpectralWindow* imageSPW(unsigned int ibb,
     818             :                                      unsigned int ispw) const;
     819             : 
     820             :       /**
     821             :        * Defines an association "spw1 is image of spw2" between two spectral windows spw1 and spw2.
     822             :        * Assuming that a spectral window can be located by a pair (ibb, ispw) of integer, where ibb denotes the index of the
     823             :        * baseband this spectral window belongs to, and ispw its index in that baseband, this method declares that
     824             :        * the spectral window with coordinates (ibb1, ispw1) is the image of the spectral window with coordinates (ibb2, ispw2).
     825             :        *
     826             :        * @param ibb  1st common coordinate of spw1
     827             :        * @param ispw1 2nd coordinate of spw1.
     828             :        * @param ispw2 2nd coordinate of spw2.
     829             :        *
     830             :        * @throw SDMDataObjectException
     831             :        */
     832             :       void imageOfSPW(unsigned int ibb,
     833             :                       unsigned int ispw1,
     834             :                       unsigned int ispw2);
     835             :       
     836             : 
     837             :       /**
     838             :        * Returns a pointer to the spectral window whom the spectral window passed in argument is the image.
     839             :        * Assuming that a spectral window spw can be located by a pair (ibb, ispw) of integer, where ibb denotes the index of the
     840             :        * baseband this spectral window belongs to, and ispw its index in that baseband, this method returns
     841             :        * a pointer to the spectral window defined as the image of spw. If spw is not an image then null is returned.
     842             :        *
     843             :        * @param ibb  1st coordinate of spw
     844             :        * @param ispw 2nd coordinate of spw
     845             :        *
     846             :        * @throw SDMDataObjectException
     847             :        */
     848             :       const SpectralWindow* imageOfSPW(unsigned int ibb,
     849             :                                        unsigned int ispw) const;
     850             :       
     851             : 
     852             :     private:
     853             :       std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection> apc_;
     854             :       std::vector<Baseband> basebands_;
     855             :       BinaryPart flags_;
     856             :       BinaryPart actualTimes_;
     857             :       BinaryPart actualDurations_;
     858             :       ZeroLagsBinaryPart zeroLags_;
     859             :       BinaryPart crossData_;
     860             :       AutoDataBinaryPart autoData_;
     861             : 
     862             :       const SDMDataObject* owner_;
     863             :       void owner(const SDMDataObject* o);
     864             : 
     865             :       std::map<std::string, std::string> imageSPW_;
     866             :       std::map<std::string, std::string> imageOfSPW_;
     867             : 
     868             :       void checkCoordinate(unsigned int ibb, unsigned int ispw) const;
     869             :       bool associatedSPW(unsigned int ibb,
     870             :                          unsigned int ispw1,
     871             :                          unsigned int ispw2);
     872             : 
     873             :       void divorceSPW(unsigned int ibb, unsigned int ispw)   ;
     874             : 
     875             :     }; //DataStruct::
     876             : 
     877             :     SDMDataObject();
     878             :     SDMDataObject(unsigned long long startTime,
     879             :                   const std::string& dataOID,
     880             :                   unsigned int dimensionality,
     881             :                   const std::string& execBlockUID,
     882             :                   unsigned int execBlockNum,
     883             :                   unsigned int scanNum,
     884             :                   unsigned int subscanNum,
     885             :                   unsigned int numAntenna,
     886             :                   CorrelationModeMod::CorrelationMode correlatorMode,
     887             :                   const SDMDataObject::DataStruct& dataStruct);
     888             : 
     889             :     SDMDataObject(unsigned long long startTime,
     890             :                   const std::string& dataOID,
     891             :                   unsigned int dimensionality,
     892             :                   unsigned int numTime,
     893             :                   const std::string& execBlockUID,
     894             :                   unsigned int execBlockNum,
     895             :                   unsigned int scanNum,
     896             :                   unsigned int subscanNum,
     897             :                   unsigned int numAntenna,
     898             :                   const SDMDataObject::DataStruct& dataStruct);
     899             : 
     900             :     /**
     901             :      * Returns the title of the SDMDataObject.
     902             :      * @return a string.
     903             :      */
     904             :     std::string title() const;
     905             :     void title(const std::string& value) ;
     906             : 
     907             :      /**
     908             :       * Returns the byte order of the binary parts.
     909             :       * @return a pointer of a ByteOrder instance.
     910             :       */
     911             :     const ByteOrder* byteOrder() const;
     912             : 
     913             :     /**
     914             :      * Returns the start time.
     915             :      * @return a long long.
     916             :      */
     917             :     unsigned long long startTime() const;
     918             :     void startTime(unsigned long long value);    
     919             : 
     920             :     /**
     921             :      * Returns the number of (sub) integrations.
     922             :      * @return an unsigned int.
     923             :      *
     924             :      */
     925             :     unsigned int numTime() const;
     926             :     void numTime(unsigned int value);
     927             : 
     928             :     /**
     929             :      * Returns the dataOID.
     930             :      * @return a string.
     931             :      */
     932             :     std::string dataOID() const;
     933             :     void dataOID(const std::string& value);
     934             : 
     935             : 
     936             :     /**
     937             :      * Returns the UID of the ExecBlock.
     938             :      * @return a string.
     939             :      */
     940             :     std::string execBlockUID() const;
     941             :     void execBlockUID(const std::string& value);
     942             : 
     943             :     /**
     944             :      * Returns the number of the ExecBlock.
     945             :      * @return an unsigned int.
     946             :      */
     947             :     unsigned int execBlockNum() const;
     948             :     void execBlockNum (unsigned int value );
     949             : 
     950             :     /**
     951             :      * Returns the number of the scan.
     952             :      * @return an unsigned int.
     953             :      */
     954             :     unsigned int scanNum() const;
     955             :     void scanNum( unsigned int value);
     956             : 
     957             :     /**
     958             :      * Returns the number of the subscan.
     959             :      * @return an unsigned int.
     960             :      */
     961             :     unsigned int subscanNum() const;
     962             :     void subscanNum(int value);
     963             : 
     964             :     /**
     965             :      * Returns the project path.
     966             :      * The project path is a string of the form "/<s>execBlockNum</s>/<s>scanNum</s>/<s>subscanNum</s>"
     967             :      */
     968             :     std::string projectPath() const;
     969             : 
     970             :     /**
     971             :      * Returns the projects paths of all the data subsets present in this SDMDataObject
     972             :      *
     973             :      * @return a vector of string.
     974             :      */
     975             :     std::vector<std::string> projectPaths() const;
     976             : 
     977             :     /**
     978             :      * Returns the number of antenna.
     979             :      * @return an unsigned int.
     980             :      */
     981             :     unsigned int numAntenna() const;
     982             :     void numAntenna (unsigned int value);
     983             : 
     984             :     /**
     985             :      * Returns the correlation mode.
     986             :      * @return a value from enumeration CorrelationMode.
     987             :      */
     988             :     CorrelationModeMod::CorrelationMode correlationMode() const;
     989             : 
     990             : 
     991             :     /**
     992             :      * Returns the spectral resolution.
     993             :      * Due to this optional nature, the spectral resolution type is not returned directly as a literal of the enumeration
     994             :      * SpectralResolutionType, but as an instance of the class OptionalSpectralResolutionType. This instance can be queried to
     995             :      * check if the spectral resolution type information is present and if it is its value as an SpectralResolutionType literal.
     996             :      *
     997             :      * @return a value from enumeration SpectralResolutionType.
     998             :      */
     999             :     OptionalSpectralResolutionType spectralResolutionType() const;
    1000             : 
    1001             :     /**
    1002             :      * Returns the processor type.
    1003             :      * @return a value from the enumeration ProcessorType.
    1004             :      */
    1005             :     ProcessorTypeMod::ProcessorType processorType() const;
    1006             :     
    1007             : 
    1008             :     /**
    1009             :      * Returns the correlator type.
    1010             :      *
    1011             :      * @return a value from the enumeration CorrelatorType if processorType == CORRELATOR else an SDMDataObjectException is thrown.
    1012             :      * @throw SDMDataException
    1013             :      */
    1014             :     CorrelatorTypeMod::CorrelatorType correlatorType() const;
    1015             : 
    1016             :     /**
    1017             :      * Returns true if the data are total power data and false otherwise.
    1018             :      * @return a bool.
    1019             :      *
    1020             :      * @note data are considered as total power data if title contains the words "Total Power".
    1021             :      */
    1022             :     bool isTP() const ;
    1023             : 
    1024             :     /**
    1025             :      * Returns true if the data are wvr data and false otherwise.
    1026             :      * @return a bool.
    1027             :      *
    1028             :      * @note data are considered as WVR data if title contains the acronym "WVR".
    1029             :      */
    1030             :     bool isWVR() const ;
    1031             : 
    1032             :     /**
    1033             :      * Returns true if the data are correlator data and false otherwise.
    1034             :      * @return a bool.
    1035             :      *
    1036             :      * @note data are considered as correlator data if SpectralResolutionType != BASEBAND_WIDE.
    1037             :      */
    1038             :     bool isCorrelation() const;
    1039             : 
    1040             :     /**
    1041             :      * hasPackedData returns true if all the integrations are grouped in one subset for all the timestamps and conversely false if 
    1042             :      * there is one subset per integration (i.e. per timestamp). Equivalent to the method dimensionality as follows :
    1043             :      *   "hasPackedData returns true is equivalent to dimensionality returns 0"
    1044             :      */
    1045             :     bool hasPackedData() const;
    1046             :        
    1047             :     /**
    1048             :      * Returns the structure of the data.
    1049             :      * @returns a reference to a DataStruct.
    1050             :      */
    1051             :     const DataStruct& dataStruct() const;
    1052             :     void dataStruct(const DataStruct& dataStruct);
    1053             : 
    1054             : 
    1055             :     /**
    1056             :      * Return all the SDMDataSubsets contained in this.
    1057             :      *
    1058             :      * @return a reference on the vector of SDMDataSubsets contained in this instance of SDMDataObject. It's the responsibility
    1059             :      * of the user to determine what's in the element(s) of this vector from what's returned by a call to the method hasPackedData.
    1060             :      * If packedData returns true then the vector contains only one element containing all the data (typically this happens for WVR data), 
    1061             :      * conversely if it returns false then the vector may have more than one element and the data are distributed over the elements on 
    1062             :      * the basis of one integration per element.
    1063             :      */
    1064             :     const std::vector<SDMDataSubset>& sdmDataSubsets() const;
    1065             : 
    1066             :     /**
    1067             :      * Returns the binary data as a sequence of integrations.
    1068             :      * This method must be used only when the SDMDataObject contains correlator data (i.e. isCorrelation() == true)
    1069             :      * @return a reference to a vector of SDMDataSubset.
    1070             :      */
    1071             :     const std::vector<SDMDataSubset>& corrDataSubsets() const;
    1072             :     void corrDataSubsets(const std::vector<SDMDataSubset>& value);
    1073             : 
    1074             :     /**
    1075             :      * Returns a reference to a SDMDataSubset given its projectPath.
    1076             :      * 
    1077             :      * @param projectPath a string containing the project path of the SDMDataSubset.
    1078             :      * @return a pointer to an SDMDataSubset.
    1079             :      *
    1080             :      * @throw SDMDataObjectException.
    1081             :      */
    1082             :     const SDMDataSubset& sdmDataSubset(const std::string& projectPath) const;
    1083             : 
    1084             : 
    1085             :     /**
    1086             :      * Returns true if the observation has been aborted.
    1087             :      * This method must be used on an SDMDataObject containing correlator data,otherwise a SDMDataObjectException is thrown.
    1088             :      *
    1089             :      * @return a bool.
    1090             :      * 
    1091             :      * @throw SDMDataObjectException.
    1092             :      */
    1093             :     bool aborted() const ;
    1094             : 
    1095             :     /**
    1096             :      * Returns the time, as an unsigned long long, at which the observation has been aborted.
    1097             :      * The returned value is significant only if the observation has been aborted, therefore the method must always be used in 
    1098             :      * conjuction with the aborted method. This method must be used on an SDMDataObject containing correlator data,
    1099             :      * otherwise a SDMDataObjectException is thrown.
    1100             :      *
    1101             :      * @return an unsigned long long.
    1102             :      *
    1103             :      * @throw SDMDataObjectException
    1104             :      */
    1105             :     unsigned long long abortTime() const ;
    1106             : 
    1107             : 
    1108             : 
    1109             :     /**
    1110             :      * Returns the reason, as a string, why the observation has been aborted.
    1111             :      * The returned value is significant only if the observation has been aborted, therefore the method must always be used in 
    1112             :      * conjuction with the aborted method. This method must be used on an SDMDataObject containing correlator data,
    1113             :      * otherwise a SDMDataObjectException is thrown.
    1114             :      *
    1115             :      * @return a string.
    1116             :      *
    1117             :      * @throw SDMDataObjectException
    1118             :      */
    1119             :     std::string abortReason() const ;
    1120             : 
    1121             : 
    1122             :     /**
    1123             :      * Returns the binary data for a subscan.
    1124             :      * This method must be used only when the SDMDataObject contains total power data (i.e. isTP() == true)
    1125             :      * @return a reference to an SDMDataSubset.
    1126             :      */
    1127             :     const SDMDataSubset& tpDataSubset() const;
    1128             :     void tpDataSubset(const SDMDataSubset& value);
    1129             : 
    1130             :     /**
    1131             :      * Returns a string representation of the global header of this SDMDataObject.
    1132             :      * @return a string.
    1133             :      */
    1134             :     std::string toString() const;
    1135             : 
    1136             :     /**
    1137             :      * Makes this SDMDataObject unusable.
    1138             :      * After a call to this method any request to this instance will generate an exception.
    1139             :      */
    1140             :     void done();
    1141             : 
    1142             :     /**
    1143             :      * Dimensionality of the binary content
    1144             :      *
    1145             :      * == 0 all data are grouped in one subset
    1146             :      * == 1 data are spread over a sequence of subsets, usually along the time axis  with one integration (i.e. one timestamp) per subset.
    1147             :      */
    1148             :     unsigned int dimensionality() const;
    1149             : 
    1150             :   private:
    1151             : 
    1152             :     static std::vector<std::string> correlationModeRefs;
    1153             :     static std::vector<std::string> axes;
    1154             :     static std::vector<std::string> types;
    1155             :     static std::vector<std::string> apcs;
    1156             : 
    1157             :     const static bool _init;
    1158             :     static bool init();
    1159             : 
    1160             :     // Is the SDMDataObject actually properly filled with valid data.
    1161             :     bool valid_; 
    1162             : 
    1163             :     // Global header variables.
    1164             :     std::string title_;
    1165             : 
    1166             :     const ByteOrder* byteOrder_;
    1167             : 
    1168             :     int schemaVersion_;
    1169             :     
    1170             :     long long startTime_;
    1171             : 
    1172             :     std::string dataOID_;
    1173             : 
    1174             :     unsigned int dimensionality_;
    1175             : 
    1176             :     unsigned int numTime_;
    1177             : 
    1178             :     std::string execBlockUID_;
    1179             : 
    1180             :     unsigned int execBlockNum_;
    1181             : 
    1182             :     unsigned int scanNum_;
    1183             : 
    1184             :     unsigned int subscanNum_;
    1185             : 
    1186             :     unsigned int numAntenna_;
    1187             : 
    1188             :     CorrelationModeMod::CorrelationMode correlationMode_;
    1189             : 
    1190             :     OptionalSpectralResolutionType spectralResolutionType_;
    1191             : 
    1192             :     ProcessorTypeMod::ProcessorType processorType_;
    1193             : 
    1194             :     DataStruct dataStruct_;
    1195             : 
    1196             :     std::map<std::string, unsigned int> str2index_;
    1197             :     
    1198             :     std::vector<SDMDataSubset> dataSubsets_;
    1199             : 
    1200             :     bool aborted_;
    1201             : 
    1202             :     unsigned long long int abortTime_;
    1203             :     std::string   abortReason_;
    1204             : 
    1205             :     void append(const SDMDataSubset& value);
    1206             : 
    1207             : 
    1208             :     /**
    1209             :      * Returns the "dimensionality" of this SDMDataObject.
    1210             :      * A value of 
    1211             :      * <ul>
    1212             :      * <li> 0 corresponds to total power data.</li>
    1213             :      * <li> 1 corresponds to correlator data.</li>
    1214             :      * </ul>
    1215             :      */
    1216             :     void dimensionality( unsigned int value );
    1217             : 
    1218             :     /**
    1219             :      * Returns true is the string passed as an argument is found in the title of this. The search is case insensitive.
    1220             :      * @param what, the string to be looked for in the title of this.
    1221             :      *
    1222             :      * @return true if and only if s is found in the title of this.
    1223             :      */
    1224             :     bool inTitle(const std::string& what) const;
    1225             : 
    1226             :     /**
    1227             :      * Declares itself as the owner of all its parts.
    1228             :      */
    1229             :     void owns();
    1230             : 
    1231             :  
    1232             :     /**
    1233             :      * Returns an XML representation of the global header of this SDMDataObject.
    1234             :      * @return a string.
    1235             :      */
    1236             :     std::string toXML() ;
    1237             :     void toXML(const BinaryPart& binaryPart, const std::string& elementName,  std::ostringstream& oss) const;
    1238             :     void toXML(const AutoDataBinaryPart& autoDataBinaryPart, const std::string& elementName,  std::ostringstream& oss) const;
    1239             :     void toXML(const ZeroLagsBinaryPart& zeroLagsBinaryPart, const std::string& elementName,  std::ostringstream& oss) const;
    1240             :     void spectralWindowsToXML(const std::vector<Baseband>& basebands, unsigned int ibb,  std::ostringstream& oss) const;
    1241             :     void basebandsToXML(std::ostringstream& oss) const; 
    1242             :     void dataStructToXML(std::ostringstream& oss) ;
    1243             : 
    1244             :     void updateIdImageSPW();
    1245             : 
    1246             :     const static std::regex  SPWID;
    1247             : 
    1248             :   };
    1249             :   // SDMDataObject::
    1250             : 
    1251             :   // SDMDataSubset:: declarations
    1252             :   //
    1253             :   /**
    1254             :    * An SDMDataSubset is a class to represent the binary data stored during :
    1255             :    * <ul>
    1256             :    * <li> one integration in the case of Correlator data. </li>
    1257             :    * <li> one subscan in the case of Total Power Data. </li>
    1258             :    * </ul>
    1259             :    */
    1260             :   class SDMDataSubset {
    1261             :     friend class SDMDataObject;
    1262             :     friend class SDMDataObjectReader;
    1263             :     friend class SDMDataObjectStreamReader;
    1264             :     friend class SDMDataObjectWriter;
    1265             :     friend class CorrSubsetHeaderParser;
    1266             :     friend class TPSubsetHeaderParser;
    1267             : 
    1268             :   public:
    1269             :   
    1270             :     /*
    1271             :      * An empty constructor.
    1272             :      */
    1273             :     SDMDataSubset(SDMDataObject* owner= 0);
    1274             : 
    1275             :     SDMDataSubset(SDMDataObject* owner,
    1276             :                   unsigned long long time,
    1277             :                   unsigned long long interval,
    1278             :                   const std::vector<float>& autoData);
    1279             : 
    1280             :     /*
    1281             :      * A copy constructor.
    1282             :      */
    1283             :     SDMDataSubset(const SDMDataSubset & sdmDataSubset);
    1284             : 
    1285             :     /*
    1286             :      * Overloading = 
    1287             :      */
    1288             :     SDMDataSubset& operator= (const SDMDataSubset& sdmDataSubset);
    1289             : 
    1290             :     /*
    1291             :      * The destructor.
    1292             :      */
    1293             :     virtual ~SDMDataSubset();
    1294             : 
    1295             :     const SDMDataObject* owner() const;
    1296             : 
    1297             :     unsigned int integrationNum() const;
    1298             :     
    1299             :     unsigned int subintegrationNum() const;    
    1300             : 
    1301             :     /**
    1302             :      * Returns the project path of this SDMDataSubset.
    1303             :      * the project path is a string of the form :
    1304             :      * <ul>
    1305             :      * <li>/<execblock-number>/<scan-number>/<subscan-number>/<integration-number> in the case of correlator data. </li>
    1306             :      * <li>/<execblock-number>/<scan-number>/<subscan-number> in the case of total power data. </li>
    1307             :      * </ul>
    1308             :      */
    1309             :     std::string projectPath() const;
    1310             :   
    1311             :     /**
    1312             :      * Returns the midpoint of :
    1313             :      * <ul>
    1314             :      * <li> the integration in the case of correlator data. </li>
    1315             :      * <li> the subscan in the case of total power data. </li>
    1316             :      * </ul>
    1317             :      */
    1318             :     unsigned long long time() const;
    1319             :   
    1320             :     /**
    1321             :      * Returns the duration of the subscan in the case of total power data.
    1322             :      * @note not relevant in the case of correlator data.
    1323             :      */
    1324             :     unsigned long long interval() const;
    1325             : 
    1326             : 
    1327             :     /**
    1328             :      * Returns a description of this SDMDataSubset.
    1329             :      *
    1330             :      */
    1331             :     std::string toString(unsigned int N = 10 )const ;
    1332             : 
    1333             :     void binAttachToXML(const std::string& name, std::ostringstream& oss);
    1334             :     void tpBinAttachToXML(std::ostringstream& oss);
    1335             :     void corrBinAttachToXML(std::ostringstream& oss);
    1336             : 
    1337             :     void toXML(std::ostringstream& oss) const;
    1338             : 
    1339             :     /**
    1340             :      * Returns an XML representation of this SDMDataSubset.
    1341             :      *
    1342             :      */
    1343             :     std::string toXML();
    1344             : 
    1345             : 
    1346             :     /**
    1347             :      *
    1348             :      * Set ptr to the adress of the array of ActualDurations and returns the number of actualDurations.
    1349             :      * @param ptr a reference to a pointer on long long.
    1350             :      * @return the number of ActualDurations.
    1351             :      *
    1352             :      */
    1353             :     unsigned long int actualDurations(const ACTUALDURATIONSTYPE* & ptr) const;
    1354             : 
    1355             :     /**
    1356             :      *
    1357             :      * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
    1358             :      * Has no meaning otherwise.
    1359             :      *
    1360             :      */
    1361             :     uint64_t actualDurationsPosition() const;
    1362             : 
    1363             :     /**
    1364             :      *
    1365             :      * Set ptr to the adress of the array of ActualTimes and returns the number of ActualTimes.
    1366             :      * @param ptr a reference to a pointer on long long.
    1367             :      * @return the number of ActualTimes.
    1368             :      *
    1369             :      */
    1370             :     unsigned long int actualTimes(const ACTUALTIMESTYPE* & ptr) const;
    1371             : 
    1372             :     /**
    1373             :      *
    1374             :      * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
    1375             :      * Has no meaning otherwise.
    1376             :      *
    1377             :      */
    1378             :     uint64_t actualTimesPosition() const;
    1379             : 
    1380             :     /**
    1381             :      *
    1382             :      * Set ptr to the adress of the array of AutoData and returns the number of AutoData.
    1383             :      * @param ptr a reference to a pointer on float.
    1384             :      * @return the number of AutoData.
    1385             :      *
    1386             :      */
    1387             :     unsigned long int autoData(const AUTODATATYPE* & ptr) const ;
    1388             : 
    1389             :     /**
    1390             :      *
    1391             :      * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
    1392             :      * Has no meaning otherwise.
    1393             :      *
    1394             :      */
    1395             :     uint64_t autoDataPosition() const;
    1396             : 
    1397             :     /**
    1398             :      *
    1399             :      * Set ptr to the adress of the array of short int CrossData and returns the number of short int CrossData 
    1400             :      * @param ptr a reference to a pointer on short int.
    1401             :      * @return the number of short int CrossData values.
    1402             :      *
    1403             :      */
    1404             :     unsigned long int crossData(const SHORTCROSSDATATYPE* & ptr) const;
    1405             : 
    1406             : 
    1407             :     /**
    1408             :      *
    1409             :      * Set ptr to the adress of the array of int CrossData and Returns the number of long int CrossData.
    1410             :      * @param ptr a reference to a pointer on long int.
    1411             :      * @return the number of long int CrossData values.
    1412             :      *
    1413             :      */
    1414             :     unsigned long int crossData(const INTCROSSDATATYPE* & ptr) const;
    1415             : 
    1416             :     /**
    1417             :      *
    1418             :      * Set ptr to the adress of the array of float CrossData and Returns the number of long int CrossData.
    1419             :      * @param ptr a reference to a pointer on float.
    1420             :      * @return the number of float CrossData values.
    1421             :      *
    1422             :      */
    1423             :     unsigned long int crossData(const FLOATCROSSDATATYPE* & ptr) const;
    1424             : 
    1425             :     /**
    1426             :      *
    1427             :      * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
    1428             :      * Has no meaning otherwise.
    1429             :      *
    1430             :      */
    1431             :     uint64_t crossDataPosition() const;
    1432             : 
    1433             :     /**
    1434             :      * Return the type of cross data values.
    1435             :      * @return a value of the enumeration PrimitiveDataTypeMod::PrimitiveDataType.
    1436             :      *
    1437             :      */
    1438             :     PrimitiveDataTypeMod::PrimitiveDataType crossDataType() const;
    1439             : 
    1440             :     void crossDataType(PrimitiveDataTypeMod::PrimitiveDataType value);
    1441             : 
    1442             :     /**
    1443             :      *
    1444             :      * Set ptr to the adress of the array of flags and returns the number of flags. 
    1445             :      * @param ptr a reference to a pointer on unsigned long int.
    1446             :      * @return the number of flags.
    1447             :      *
    1448             :      */
    1449             :     unsigned long int flags(const FLAGSTYPE* &ptr) const;
    1450             : 
    1451             :     /**
    1452             :      *
    1453             :      * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
    1454             :      * Has no meaning otherwise.
    1455             :      *
    1456             :      */
    1457             :     uint64_t flagsPosition() const;
    1458             : 
    1459             :     /**
    1460             :      *
    1461             :      * Set ptr to the adress of the array of ZeroLags and returns the number of ZeroLags.
    1462             :      * @param ptr a reference to a pointer on float.
    1463             :      * @return the number of autoData.
    1464             :      *
    1465             :      */
    1466             :     unsigned long int zeroLags(const ZEROLAGSTYPE* & ptr) const;
    1467             : 
    1468             :     /**
    1469             :      *
    1470             :      * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
    1471             :      * Has no meaning otherwise.
    1472             :      *
    1473             :      */
    1474             :     uint64_t zeroLagsPosition() const;
    1475             : 
    1476             :     /**
    1477             :      * Returns true if and only if this corresponds to an aborted [sub]integration.
    1478             :      * @return a bool.
    1479             :      */
    1480             :     bool aborted() const ; 
    1481             : 
    1482             :     /**
    1483             :      * Returns the time when the [sub]integration has been declared aborted.
    1484             :      * @return an unsigned long long.
    1485             :      * @note Of course, the returned value is not meaningful if aborted() returns false.
    1486             :      */
    1487             :     unsigned long long abortTime() const; 
    1488             : 
    1489             :     /**
    1490             :      * Returns the reason why the [sub]integration was aborted.
    1491             :      * @return a string.
    1492             :      * @note Of course, the returned value is not meaningful if aborted() returns false.
    1493             :      */
    1494             :     std::string abortReason() const;
    1495             : 
    1496             : 
    1497             : 
    1498             :   private:
    1499             :     SDMDataObject* owner_;
    1500             :     unsigned int integrationNum_;
    1501             :     unsigned int subintegrationNum_;
    1502             :     CorrelationModeMod::CorrelationMode ref_;
    1503             :     unsigned long long time_;
    1504             :     unsigned long long interval_;
    1505             :     std::string dataStruct_;
    1506             :     std::string flagsREF_;
    1507             :     std::string actualTimesREF_;
    1508             :     std::string actualDurationsREF_;
    1509             :     std::string zeroLagsREF_;
    1510             :     std::string crossDataREF_;
    1511             :     PrimitiveDataTypeMod::PrimitiveDataType crossDataType_;
    1512             :     std::string autoDataREF_;
    1513             : 
    1514             :     const ACTUALTIMESTYPE * actualTimes_;
    1515             :     unsigned long int nActualTimes_;
    1516             :     uint64_t actualTimesPosition_;
    1517             :     const ACTUALDURATIONSTYPE * actualDurations_;
    1518             :     unsigned long int nActualDurations_;
    1519             :     uint64_t actualDurationsPosition_;
    1520             :     const ZEROLAGSTYPE* zeroLags_;
    1521             :     unsigned long int nZeroLags_;
    1522             :     uint64_t zeroLagsPosition_;
    1523             :     const FLAGSTYPE* flags_;    
    1524             :     unsigned long int nFlags_;
    1525             :     uint64_t flagsPosition_;
    1526             :     const INTCROSSDATATYPE* longCrossData_;
    1527             :     const SHORTCROSSDATATYPE* shortCrossData_;
    1528             :     const FLOATCROSSDATATYPE* floatCrossData_;
    1529             :     unsigned long int nCrossData_;
    1530             :     uint64_t crossDataPosition_;
    1531             :     const AUTODATATYPE* autoData_;
    1532             :     unsigned long int nAutoData_;
    1533             :     uint64_t autoDataPosition_;
    1534             : 
    1535             :     std::string xsiType() const;
    1536             : 
    1537             :     bool aborted_;
    1538             :     unsigned long long int abortTime_;
    1539             :     std::string   abortReason_;
    1540             : 
    1541             :   };
    1542             :   // SDMDataSubset:: declarations
    1543             : 
    1544             : 
    1545             :   // Utils:: declarations
    1546             :   //
    1547             :   class Utils {
    1548             :   public:
    1549             :     static void invalidCall(const std::string & methodName, const SDMDataObject* sdmDataObject);
    1550             :     static std::string quote(const std::string& s);
    1551             :     static std::string quote(bool b);
    1552             :     static std::string quote(int i);
    1553             :     static std::string quote(unsigned int i);
    1554             :     static std::string quote(long long l);
    1555             :     static std::string quote(float f);
    1556             :     static std::string quote(const std::set<std::string>& s);
    1557             :     static std::string quote(const std::vector<std::string>& s);
    1558         536 :     template<class Enum, class EnumHelper> static std::string quote(Enum l) {
    1559         536 :       std::ostringstream oss;
    1560         536 :       oss << "\"";
    1561         536 :       oss << EnumHelper::name(l);
    1562         536 :       oss << "\"";
    1563        1072 :       return oss.str();
    1564         536 :     }
    1565             : 
    1566        2192 :     template<class Enum, class EnumHelper> static std::string quote(const std::vector<Enum>& v_l) {
    1567        2192 :       std::ostringstream oss;
    1568        2192 :       oss << "\"";
    1569             : 
    1570        2192 :       if (v_l.size() > 0)
    1571        2168 :         oss << EnumHelper::name(v_l.at(0));
    1572             : 
    1573        4714 :       for (unsigned int i = 1; i < v_l.size(); i++)
    1574        2522 :         oss << " " << EnumHelper::name(v_l.at(i));
    1575        2192 :       oss << "\"";
    1576        4384 :       return oss.str();
    1577        2192 :     }
    1578             : 
    1579           0 :     template<class Enum, class EnumHelper> static std::string toString(Enum l) {
    1580           0 :       std::ostringstream oss;
    1581           0 :       oss << EnumHelper::name(l);
    1582           0 :       return oss.str();
    1583           0 :     }
    1584             : 
    1585           0 :     template<class Enum, class EnumHelper> static std::string toString(const std::vector<Enum>& v_l) {
    1586           0 :       std::ostringstream oss;
    1587             : 
    1588           0 :       if (v_l.size() > 0)
    1589           0 :         oss << EnumHelper::name(v_l.at(0));
    1590             : 
    1591           0 :       for (unsigned int i = 1; i < v_l.size(); i++)
    1592           0 :         oss << " " << EnumHelper::name(v_l.at(i));
    1593           0 :       return oss.str();
    1594           0 :     }
    1595             : 
    1596             :     /**
    1597             :      * A generic utility to return a vector of <Enum> out of a string of <Enum> literals separated by space characters.
    1598             :      */
    1599             :     template<class Enum, class EnumHelper> static std::vector<Enum> enumvec(const std::string& strliterals) {
    1600             :       std::vector<Enum> result;
    1601             :       
    1602             :       std::string strliteral;
    1603             :       std::istringstream iss(strliterals);
    1604             :       
    1605             :       while (iss >> strliteral)
    1606             :         result.push_back(EnumHelper::literal(strliteral));
    1607             :       
    1608             :       return result;
    1609             :     }
    1610             : 
    1611             : 
    1612             :     static void toXML(const std::string& elementName, int value, std::ostringstream& oss);
    1613             :     static void toXML(const std::string& elementName, unsigned int value, std::ostringstream& oss);
    1614             :     static void toXML(const std::string& elementName, long long value, std::ostringstream& oss);
    1615             :     static void toXML(const std::string& elementName, unsigned long long value, std::ostringstream& oss);
    1616             :     static void oXML(const std::string& elementName, std::ostringstream& oss);
    1617             :     static void cXML(const std::string& elementName, std::ostringstream& oss);
    1618             :     
    1619             :     /**
    1620             :      * A generic utility to XML'ize a literal as the content of an XML element.
    1621             :      *
    1622             :      * @param elementName the name of the XML element to contain the Enum value.
    1623             :      * @param literal the value of Enum to output.
    1624             :      * @param oss a reference to the output string stream where the XML is written.
    1625             :      *
    1626             :      */
    1627        1608 :     template<class Enum, class EnumHelper> static void toXML(const std::string& elementName, Enum value, std::ostringstream& oss) {
    1628        1608 :       oss << "<" << elementName << ">" << EnumHelper::name(value) << "</" << elementName << ">" << std::endl;      
    1629        1608 :     }
    1630             : 
    1631             : #define QUOTE    Utils::quote
    1632             : #define TOSTRING Utils::toString
    1633             : #define TOXML    Utils::toXML
    1634             : #define OXML     Utils::oXML
    1635             : #define CXML     Utils::cXML
    1636             :   };
    1637             : }
    1638             : #endif // SDMDataObject_CLASS

Generated by: LCOV version 1.16