LCOV - code coverage report
Current view: top level - alma/ASDM - FreqOffsetTable.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 7 0.0 %
Date: 2024-10-28 15:53:10 Functions: 0 1 0.0 %

          Line data    Source code
       1             : 
       2             : /*
       3             :  * ALMA - Atacama Large Millimeter Array
       4             :  * (c) European Southern Observatory, 2002
       5             :  * (c) Associated Universities Inc., 2002
       6             :  * Copyright by ESO (in the framework of the ALMA collaboration),
       7             :  * Copyright by AUI (in the framework of the ALMA collaboration),
       8             :  * All rights reserved.
       9             :  * 
      10             :  * This library is free software; you can redistribute it and/or
      11             :  * modify it under the terms of the GNU Lesser General Public
      12             :  * License as published by the Free software Foundation; either
      13             :  * version 2.1 of the License, or (at your option) any later version.
      14             :  * 
      15             :  * This library is distributed in the hope that it will be useful,
      16             :  * but WITHOUT ANY WARRANTY, without even the implied warranty of
      17             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      18             :  * Lesser General Public License for more details.
      19             :  * 
      20             :  * You should have received a copy of the GNU Lesser General Public
      21             :  * License along with this library; if not, write to the Free Software
      22             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      23             :  * MA 02111-1307  USA
      24             :  *
      25             :  * Warning!
      26             :  *  -------------------------------------------------------------------- 
      27             :  * | This is generated code!  Do not modify this file.                  |
      28             :  * | If you do, all changes will be lost when the file is re-generated. |
      29             :  *  --------------------------------------------------------------------
      30             :  *
      31             :  * File FreqOffsetTable.h
      32             :  */
      33             :  
      34             : #ifndef FreqOffsetTable_CLASS
      35             : #define FreqOffsetTable_CLASS
      36             : 
      37             : #include <string>
      38             : #include <vector>
      39             : #include <map>
      40             : 
      41             : 
      42             : 
      43             :         
      44             : #include <alma/ASDM/ArrayTimeInterval.h>
      45             :         
      46             : 
      47             :         
      48             : #include <alma/ASDM/Frequency.h>
      49             :         
      50             : 
      51             :         
      52             : #include <alma/ASDM/Tag.h>
      53             :         
      54             : 
      55             : 
      56             : 
      57             : 
      58             :         
      59             : 
      60             :         
      61             : 
      62             : 
      63             : 
      64             : #include <alma/ASDM/ConversionException.h>
      65             : #include <alma/ASDM/DuplicateKey.h>
      66             : #include <alma/ASDM/UniquenessViolationException.h>
      67             : #include <alma/ASDM/NoSuchRow.h>
      68             : #include <alma/ASDM/DuplicateKey.h>
      69             : 
      70             : 
      71             : #ifndef WITHOUT_ACS
      72             : #include <asdmIDLC.h>
      73             : #endif
      74             : 
      75             : #include <alma/ASDM/Representable.h>
      76             : 
      77             : #include <pthread.h>
      78             : 
      79             : namespace asdm {
      80             : 
      81             : //class asdm::ASDM;
      82             : //class asdm::FreqOffsetRow;
      83             : 
      84             : class ASDM;
      85             : class FreqOffsetRow;
      86             : /**
      87             :  * The FreqOffsetTable class is an Alma table.
      88             :  * <BR>
      89             :  * 
      90             :  * \par Role
      91             :  * Frequency offset information. Contains an additional antenna-based frequency  offset relative to the frequencies in the Spectral Windows. Useful for such  thing as Doppler tracking.
      92             :  * <BR>
      93             :  
      94             :  * Generated from model's revision "-1", branch ""
      95             :  *
      96             :  * <TABLE BORDER="1">
      97             :  * <CAPTION> Attributes of FreqOffset </CAPTION>
      98             :  * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape  </TH> <TH> Comment </TH></TR>
      99             :  
     100             :  * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR>
     101             :         
     102             :  * <TR>
     103             :                 
     104             :  * <TD> antennaId </TD>
     105             :                  
     106             :  * <TD> Tag</TD>
     107             :  * <TD> &nbsp; </TD>
     108             :  * <TD> &nbsp;refers to a unique row in AntennaTable. </TD>
     109             :  * </TR>
     110             :         
     111             :  * <TR>
     112             :                 
     113             :  * <TD> spectralWindowId </TD>
     114             :                  
     115             :  * <TD> Tag</TD>
     116             :  * <TD> &nbsp; </TD>
     117             :  * <TD> &nbsp;refers to a unique row in SpectralWindowTable. </TD>
     118             :  * </TR>
     119             :         
     120             :  * <TR>
     121             :                 
     122             :  * <TD> timeInterval </TD>
     123             :                  
     124             :  * <TD> ArrayTimeInterval</TD>
     125             :  * <TD> &nbsp; </TD>
     126             :  * <TD> &nbsp;the time interval of validity of the row's content. </TD>
     127             :  * </TR>
     128             :         
     129             :  * <TR>
     130             :                 
     131             :  * <TD> feedId </TD>
     132             :                  
     133             :  * <TD> int</TD>
     134             :  * <TD> &nbsp; </TD>
     135             :  * <TD> &nbsp;refers to a collection of rows in FeedTable. </TD>
     136             :  * </TR>
     137             :         
     138             : 
     139             : 
     140             :  * <TR> <TH BGCOLOR="#CCCCCC"  colspan="4" valign="center"> Value <br> (Mandatory) </TH></TR>
     141             :         
     142             :  * <TR>
     143             :  * <TD> offset </TD> 
     144             :  * <TD> Frequency </TD>
     145             :  * <TD>  &nbsp;  </TD> 
     146             :  * <TD> &nbsp;frequency offset. </TD>
     147             :  * </TR>
     148             :         
     149             : 
     150             : 
     151             :  * </TABLE>
     152             :  */
     153             : class FreqOffsetTable : public Representable {
     154             :         friend class ASDM;
     155             : 
     156             : public:
     157             : 
     158             : 
     159             :         /**
     160             :          * Return the list of field names that make up key key
     161             :          * as an array of strings.
     162             :          * @return a vector of string.
     163             :          */     
     164             :         static const std::vector<std::string>& getKeyName();
     165             : 
     166             : 
     167             :         virtual ~FreqOffsetTable();
     168             :         
     169             :         /**
     170             :          * Return the container to which this table belongs.
     171             :          *
     172             :          * @return the ASDM containing this table.
     173             :          */
     174             :         ASDM &getContainer() const;
     175             :         
     176             :         /**
     177             :          * Return the number of rows in the table.
     178             :          *
     179             :          * @return the number of rows in an unsigned int.
     180             :          */
     181             :         unsigned int size() const;
     182             :         
     183             :         /**
     184             :          * Return the name of this table.
     185             :          *
     186             :          * This is a instance method of the class.
     187             :          *
     188             :          * @return the name of this table in a string.
     189             :          */
     190             :         std::string getName() const;
     191             :         
     192             :         /**
     193             :          * Return the name of this table.
     194             :          *
     195             :          * This is a static method of the class.
     196             :          *
     197             :          * @return the name of this table in a string.
     198             :          */
     199             :         static std::string name() ;     
     200             :         
     201             :         /**
     202             :          * Return the version information about this table.
     203             :          *
     204             :          */
     205             :          std::string getVersion() const ;
     206             :         
     207             :         /**
     208             :          * Return the names of the attributes of this table.
     209             :          *
     210             :          * @return a vector of string
     211             :          */
     212             :          static const std::vector<std::string>& getAttributesNames();
     213             : 
     214             :         /**
     215             :          * Return the default sorted list of attributes names in the binary representation of the table.
     216             :          *
     217             :          * @return a const reference to a vector of string
     218             :          */
     219             :          static const std::vector<std::string>& defaultAttributesNamesInBin();
     220             :          
     221             :         /**
     222             :          * Return this table's Entity.
     223             :          */
     224             :         Entity getEntity() const;
     225             : 
     226             :         /**
     227             :          * Set this table's Entity.
     228             :          * @param e An entity. 
     229             :          */
     230             :         void setEntity(Entity e);
     231             :                 
     232             :         /**
     233             :          * Produces an XML representation conform
     234             :          * to the schema defined for FreqOffset (FreqOffsetTable.xsd).
     235             :          *
     236             :          * @returns a string containing the XML representation.
     237             :          * @throws ConversionException
     238             :          */
     239             :         std::string toXML()  ;
     240             : 
     241             : #ifndef WITHOUT_ACS
     242             :         // Conversion Methods
     243             :         /**
     244             :          * Convert this table into a FreqOffsetTableIDL CORBA structure.
     245             :          *
     246             :          * @return a pointer to a FreqOffsetTableIDL
     247             :          */
     248             :         asdmIDL::FreqOffsetTableIDL *toIDL() ;
     249             :         
     250             :         /**
     251             :          * Fills the CORBA data structure passed in parameter
     252             :          * with the content of this table.
     253             :          *
     254             :          * @param x a reference to the asdmIDL::FreqOffsetTableIDL to be populated
     255             :          * with the content of this.
     256             :          */
     257             :          void toIDL(asdmIDL::FreqOffsetTableIDL& x) const;
     258             :          
     259             : #endif
     260             : 
     261             : #ifndef WITHOUT_ACS
     262             :         /**
     263             :          * Populate this table from the content of a FreqOffsetTableIDL Corba structure.
     264             :          *
     265             :          * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table.
     266             :          * @throws ConversionException
     267             :          */     
     268             :         void fromIDL(asdmIDL::FreqOffsetTableIDL x) ;
     269             : #endif
     270             :         
     271             :         //
     272             :         // ====> Row creation.
     273             :         //
     274             :         
     275             :         /**
     276             :          * Create a new row with default values.
     277             :          * @return a pointer on a FreqOffsetRow
     278             :          */
     279             :         FreqOffsetRow *newRow();
     280             :         
     281             :         
     282             :         /**
     283             :          * Create a new row initialized to the specified values.
     284             :          * @return a pointer on the created and initialized row.
     285             :         
     286             :          * @param antennaId
     287             :         
     288             :          * @param spectralWindowId
     289             :         
     290             :          * @param timeInterval
     291             :         
     292             :          * @param feedId
     293             :         
     294             :          * @param offset
     295             :         
     296             :      */
     297             :         FreqOffsetRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, Frequency offset);
     298             :         
     299             : 
     300             : 
     301             :         /**
     302             :          * Create a new row using a copy constructor mechanism.
     303             :          * 
     304             :          * The method creates a new FreqOffsetRow owned by this. Each attribute of the created row 
     305             :          * is a (deep) copy of the corresponding attribute of row. The method does not add 
     306             :          * the created row to this, its simply parents it to this, a call to the add method
     307             :          * has to be done in order to get the row added (very likely after having modified
     308             :          * some of its attributes).
     309             :          * If row is null then the method returns a new FreqOffsetRow with default values for its attributes. 
     310             :          *
     311             :          * @param row the row which is to be copied.
     312             :          */
     313             :          FreqOffsetRow *newRow(FreqOffsetRow *row); 
     314             : 
     315             :         //
     316             :         // ====> Append a row to its table.
     317             :         //
     318             :  
     319             :         
     320             :         /**
     321             :          * Add a row.
     322             :          * @param x a pointer to the FreqOffsetRow to be added.
     323             :          *
     324             :          * @return a pointer to a FreqOffsetRow. If the table contains a FreqOffsetRow whose attributes (key and mandatory values) are equal to x ones
     325             :          * then returns a pointer on that FreqOffsetRow, otherwise returns x.
     326             :          *
     327             :          * @throw DuplicateKey { thrown when the table contains a FreqOffsetRow with a key equal to the x one but having
     328             :          * and a value section different from x one }
     329             :          *
     330             :         
     331             :          * @note The row is inserted in the table in such a way that all the rows having the same value of
     332             :          * ( antennaId, spectralWindowId, feedId ) are stored by ascending time.
     333             :          * @see method getByContext.
     334             :         
     335             :          */
     336             :         FreqOffsetRow* add(FreqOffsetRow* x) ; 
     337             : 
     338             :  
     339             : 
     340             : 
     341             : 
     342             :         //
     343             :         // ====> Methods returning rows.
     344             :         //
     345             :                 
     346             :         /**
     347             :          * Get a collection of pointers on the rows of the table.
     348             :          * @return Alls rows in a vector of pointers of FreqOffsetRow. The elements of this vector are stored in the order 
     349             :          * in which they have been added to the FreqOffsetTable.
     350             :          */
     351             :         std::vector<FreqOffsetRow *> get() ;
     352             :         
     353             :         /**
     354             :          * Get a const reference on the collection of rows pointers internally hold by the table.
     355             :          * @return A const reference of a vector of pointers of FreqOffsetRow. The elements of this vector are stored in the order 
     356             :          * in which they have been added to the FreqOffsetTable.
     357             :          *
     358             :          */
     359             :          const std::vector<FreqOffsetRow *>& get() const ;
     360             :         
     361             : 
     362             :         /**
     363             :          * Returns all the rows sorted by ascending startTime for a given context. 
     364             :          * The context is defined by a value of ( antennaId, spectralWindowId, feedId ).
     365             :          *
     366             :          * @return a pointer on a vector<FreqOffsetRow *>. A null returned value means that the table contains
     367             :          * no FreqOffsetRow for the given ( antennaId, spectralWindowId, feedId ).
     368             :          *
     369             :          * @throws IllegalAccessException when a call is done to this method when it's called while the dataset has been imported with the 
     370             :          * option checkRowUniqueness set to false.
     371             :          */
     372             :          std::vector <FreqOffsetRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
     373             :          
     374             : 
     375             : 
     376             :  
     377             :         
     378             :         /**
     379             :          * Returns a FreqOffsetRow* given a key.
     380             :          * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
     381             :          * no row exists for that key.
     382             :         
     383             :          * @param antennaId
     384             :         
     385             :          * @param spectralWindowId
     386             :         
     387             :          * @param timeInterval
     388             :         
     389             :          * @param feedId
     390             :         
     391             :          *
     392             :          */
     393             :         FreqOffsetRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
     394             : 
     395             :                 
     396             : 
     397             : 
     398             : 
     399             :         /**
     400             :          * Look up the table for a row whose all attributes 
     401             :          * are equal to the corresponding parameters of the method.
     402             :          * @return a pointer on this row if any, null otherwise.
     403             :          *
     404             :                         
     405             :          * @param antennaId
     406             :                         
     407             :          * @param spectralWindowId
     408             :                         
     409             :          * @param timeInterval
     410             :                         
     411             :          * @param feedId
     412             :                         
     413             :          * @param offset
     414             :                          
     415             :          */
     416             :         FreqOffsetRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, Frequency offset); 
     417             : 
     418             : 
     419             :         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
     420             :         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
     421             : 
     422             : private:
     423             : 
     424             :         /**
     425             :          * Create a FreqOffsetTable.
     426             :          * <p>
     427             :          * This constructor is private because only the
     428             :          * container can create tables.  All tables must know the container
     429             :          * to which they belong.
     430             :          * @param container The container to which this table belongs.
     431             :          */ 
     432             :         FreqOffsetTable (ASDM & container);
     433             : 
     434             :         ASDM & container;
     435             :         
     436             :         bool archiveAsBin; // If true archive binary else archive XML
     437             :         bool fileAsBin ; // If true file binary else file XML   
     438             :         
     439             :         std::string version ; 
     440             :         
     441             :         Entity entity;
     442             :         
     443             : 
     444             :         
     445             :         
     446             : 
     447             : 
     448             :         /**
     449             :          * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
     450             :          * Check if *x verifies the key uniqueness rule and throw an exception if not.
     451             :          * Append x to its table.
     452             :          * @throws DuplicateKey
     453             :          
     454             :          */
     455             :         FreqOffsetRow* checkAndAdd(FreqOffsetRow* x, bool skipCheckUniqueness=false) ;
     456             :         
     457             :         /**
     458             :          * Brutally append an FreqOffsetRow x to the collection of rows already stored in this table. No uniqueness check is done !
     459             :          *
     460             :          * @param FreqOffsetRow* x a pointer onto the FreqOffsetRow to be appended.
     461             :          */
     462             :          void append(FreqOffsetRow* x) ;
     463             :          
     464             :         /**
     465             :          * Brutally append an FreqOffsetRow x to the collection of rows already stored in this table. No uniqueness check is done !
     466             :          *
     467             :          * @param FreqOffsetRow* x a pointer onto the FreqOffsetRow to be appended.
     468             :          */
     469             :          void addWithoutCheckingUnique(FreqOffsetRow* x) ;
     470             :          
     471             :          
     472             : 
     473             : 
     474             :         
     475             :         
     476             :         /**
     477             :          * Insert a FreqOffsetRow* in a vector of FreqOffsetRow* so that it's ordered by ascending time.
     478             :          *
     479             :          * @param FreqOffsetRow* x . The pointer to be inserted.
     480             :          * @param vector <FreqOffsetRow*>& row . A reference to the vector where to insert x.
     481             :          *
     482             :          */
     483             :          FreqOffsetRow * insertByStartTime(FreqOffsetRow* x, std::vector<FreqOffsetRow* >& row);
     484             :           
     485             : 
     486             : 
     487             : // A data structure to store the pointers on the table's rows.
     488             : 
     489             : // In all cases we maintain a private vector of FreqOffsetRow s.
     490             :    std::vector<FreqOffsetRow * > privateRows;
     491             :    
     492             : 
     493             :         
     494             : 
     495             :         
     496             :         
     497             :                 
     498             :                                 
     499             :         typedef std::vector <FreqOffsetRow* > TIME_ROWS;
     500             :         std::map<std::string, TIME_ROWS > context;
     501             :                 
     502             :         /** 
     503             :          * Returns a string built by concatenating the ascii representation of the
     504             :          * parameters values suffixed with a "_" character.
     505             :          */
     506             :          std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
     507             :                  
     508             :                 
     509             :         
     510             :         
     511             :         /**
     512             :          * Fills the vector vout (passed by reference) with pointers on elements of vin 
     513             :          * whose attributes are equal to the corresponding parameters of the method.
     514             :          *
     515             :          */
     516             :         void getByKeyNoAutoIncNoTime(std::vector <FreqOffsetRow*>& vin, std::vector <FreqOffsetRow*>& vout,  Tag antennaId, Tag spectralWindowId, int feedId);
     517             :         
     518             : 
     519             :         
     520             :         void error() ; //throw(ConversionException);
     521             : 
     522             :         
     523             :         /**
     524             :          * Populate this table from the content of a XML document that is required to
     525             :          * be conform to the XML schema defined for a FreqOffset (FreqOffsetTable.xsd).
     526             :          * @throws ConversionException
     527             :          * 
     528             :          */
     529             :         void fromXML(std::string& xmlDoc) ;
     530             :                 
     531             :         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
     532             : 
     533             :         /**
     534             :           * Private methods involved during the build of this table out of the content
     535             :           * of file(s) containing an external representation of a FreqOffset table.
     536             :           */
     537             :         void setFromMIMEFile(const std::string& directory);
     538             :         /*
     539             :         void openMIMEFile(const std::string& directory);
     540             :         */
     541             :         void setFromXMLFile(const std::string& directory);
     542             :         
     543             :                  /**
     544             :          * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
     545             :          * @returns a string containing the MIME message.
     546             :          *
     547             :          * @param byteOrder a const pointer to a static instance of the class ByteOrder.
     548             :          * 
     549             :          */
     550             :         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
     551             :   
     552             :         
     553             :    /** 
     554             :      * Extracts the binary part of a MIME message and deserialize its content
     555             :          * to fill this with the result of the deserialization. 
     556             :          * @param mimeMsg the string containing the MIME message.
     557             :          * @throws ConversionException
     558             :          */
     559             :          void setFromMIME(const std::string & mimeMsg);
     560             :         
     561             :         /**
     562             :           * Private methods involved during the export of this table into disk file(s).
     563             :           */
     564             :         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
     565             :         
     566             :         /**
     567             :           * Stores a representation (binary or XML) of this table into a file.
     568             :           *
     569             :           * Depending on the boolean value of its private field fileAsBin a binary serialization  of this (fileAsBin==true)  
     570             :           * will be saved in a file "FreqOffset.bin" or an XML representation (fileAsBin==false) will be saved in a file "FreqOffset.xml".
     571             :           * The file is always written in a directory whose name is passed as a parameter.
     572             :          * @param directory The name of directory  where the file containing the table's representation will be saved.
     573             :           * 
     574             :           */
     575             :           void toFile(std::string directory);
     576             :           
     577             :           /**
     578             :            * Load the table in memory if necessary.
     579             :            */
     580             :           bool loadInProgress;
     581           0 :           void checkPresenceInMemory() {
     582           0 :                 if (!presentInMemory && !loadInProgress) {
     583           0 :                         loadInProgress = true;
     584           0 :                         setFromFile(getContainer().getDirectory());
     585           0 :                         presentInMemory = true;
     586           0 :                         loadInProgress = false;
     587             :                 }
     588           0 :           }
     589             :         /**
     590             :          * Reads and parses a file containing a representation of a FreqOffsetTable as those produced  by the toFile method.
     591             :          * This table is populated with the result of the parsing.
     592             :          * @param directory The name of the directory containing the file te be read and parsed.
     593             :          * @throws ConversionException If any error occurs while reading the 
     594             :          * files in the directory or parsing them.
     595             :          *
     596             :          */
     597             :          void setFromFile(const std::string& directory);    
     598             :  
     599             : };
     600             : 
     601             : } // End namespace asdm
     602             : 
     603             : #endif /* FreqOffsetTable_CLASS */

Generated by: LCOV version 1.16