LCOV - code coverage report
Current view: top level - alma/ASDM - CalGainTable.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 7 0.0 %
Date: 2024-10-04 18:58:15 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 CalGainTable.h
      32             :  */
      33             :  
      34             : #ifndef CalGainTable_CLASS
      35             : #define CalGainTable_CLASS
      36             : 
      37             : #include <string>
      38             : #include <vector>
      39             : #include <map>
      40             : 
      41             : 
      42             : 
      43             :         
      44             : #include <alma/ASDM/ArrayTime.h>
      45             :         
      46             : 
      47             :         
      48             : #include <alma/ASDM/Tag.h>
      49             :         
      50             : 
      51             : 
      52             : 
      53             : 
      54             :         
      55             : 
      56             :         
      57             : 
      58             :         
      59             : 
      60             :         
      61             : 
      62             :         
      63             : 
      64             :         
      65             : 
      66             :         
      67             : 
      68             :         
      69             : 
      70             :         
      71             : 
      72             : 
      73             : 
      74             : #include <alma/ASDM/ConversionException.h>
      75             : #include <alma/ASDM/DuplicateKey.h>
      76             : #include <alma/ASDM/UniquenessViolationException.h>
      77             : #include <alma/ASDM/NoSuchRow.h>
      78             : #include <alma/ASDM/DuplicateKey.h>
      79             : 
      80             : 
      81             : #ifndef WITHOUT_ACS
      82             : #include <asdmIDLC.h>
      83             : #endif
      84             : 
      85             : #include <alma/ASDM/Representable.h>
      86             : 
      87             : #include <pthread.h>
      88             : 
      89             : namespace asdm {
      90             : 
      91             : //class asdm::ASDM;
      92             : //class asdm::CalGainRow;
      93             : 
      94             : class ASDM;
      95             : class CalGainRow;
      96             : /**
      97             :  * The CalGainTable class is an Alma table.
      98             :  * <BR>
      99             :  * 
     100             :  * \par Role
     101             :  * This Table is a placeholder to be used to wrap up casa gain tables produced  in the Science Pipeline and Offline so that they can be archived in the  ALMA Calibration Data Base.
     102             :  * <BR>
     103             :  
     104             :  * Generated from model's revision "-1", branch ""
     105             :  *
     106             :  * <TABLE BORDER="1">
     107             :  * <CAPTION> Attributes of CalGain </CAPTION>
     108             :  * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape  </TH> <TH> Comment </TH></TR>
     109             :  
     110             :  * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR>
     111             :         
     112             :  * <TR>
     113             :                 
     114             :  * <TD> calDataId </TD>
     115             :                  
     116             :  * <TD> Tag</TD>
     117             :  * <TD> &nbsp; </TD>
     118             :  * <TD> &nbsp;refers to a unique row in CalData Table. </TD>
     119             :  * </TR>
     120             :         
     121             :  * <TR>
     122             :                 
     123             :  * <TD> calReductionId </TD>
     124             :                  
     125             :  * <TD> Tag</TD>
     126             :  * <TD> &nbsp; </TD>
     127             :  * <TD> &nbsp;refers to a unique row  in CalReductionTable. </TD>
     128             :  * </TR>
     129             :         
     130             : 
     131             : 
     132             :  * <TR> <TH BGCOLOR="#CCCCCC"  colspan="4" valign="center"> Value <br> (Mandatory) </TH></TR>
     133             :         
     134             :  * <TR>
     135             :  * <TD> startValidTime </TD> 
     136             :  * <TD> ArrayTime </TD>
     137             :  * <TD>  &nbsp;  </TD> 
     138             :  * <TD> &nbsp; the start time of result validity period. </TD>
     139             :  * </TR>
     140             :         
     141             :  * <TR>
     142             :  * <TD> endValidTime </TD> 
     143             :  * <TD> ArrayTime </TD>
     144             :  * <TD>  &nbsp;  </TD> 
     145             :  * <TD> &nbsp; the end time of result validity period. </TD>
     146             :  * </TR>
     147             :         
     148             :  * <TR>
     149             :  * <TD> gain </TD> 
     150             :  * <TD> float </TD>
     151             :  * <TD>  &nbsp;  </TD> 
     152             :  * <TD> &nbsp;TBD </TD>
     153             :  * </TR>
     154             :         
     155             :  * <TR>
     156             :  * <TD> gainValid </TD> 
     157             :  * <TD> bool </TD>
     158             :  * <TD>  &nbsp;  </TD> 
     159             :  * <TD> &nbsp;TBD </TD>
     160             :  * </TR>
     161             :         
     162             :  * <TR>
     163             :  * <TD> fit </TD> 
     164             :  * <TD> float </TD>
     165             :  * <TD>  &nbsp;  </TD> 
     166             :  * <TD> &nbsp;TBD </TD>
     167             :  * </TR>
     168             :         
     169             :  * <TR>
     170             :  * <TD> fitWeight </TD> 
     171             :  * <TD> float </TD>
     172             :  * <TD>  &nbsp;  </TD> 
     173             :  * <TD> &nbsp;TBD </TD>
     174             :  * </TR>
     175             :         
     176             :  * <TR>
     177             :  * <TD> totalGainValid </TD> 
     178             :  * <TD> bool </TD>
     179             :  * <TD>  &nbsp;  </TD> 
     180             :  * <TD> &nbsp;TBD </TD>
     181             :  * </TR>
     182             :         
     183             :  * <TR>
     184             :  * <TD> totalFit </TD> 
     185             :  * <TD> float </TD>
     186             :  * <TD>  &nbsp;  </TD> 
     187             :  * <TD> &nbsp;TBD </TD>
     188             :  * </TR>
     189             :         
     190             :  * <TR>
     191             :  * <TD> totalFitWeight </TD> 
     192             :  * <TD> float </TD>
     193             :  * <TD>  &nbsp;  </TD> 
     194             :  * <TD> &nbsp;TBD </TD>
     195             :  * </TR>
     196             :         
     197             : 
     198             : 
     199             :  * </TABLE>
     200             :  */
     201             : class CalGainTable : public Representable {
     202             :         friend class ASDM;
     203             : 
     204             : public:
     205             : 
     206             : 
     207             :         /**
     208             :          * Return the list of field names that make up key key
     209             :          * as an array of strings.
     210             :          * @return a vector of string.
     211             :          */     
     212             :         static const std::vector<std::string>& getKeyName();
     213             : 
     214             : 
     215             :         virtual ~CalGainTable();
     216             :         
     217             :         /**
     218             :          * Return the container to which this table belongs.
     219             :          *
     220             :          * @return the ASDM containing this table.
     221             :          */
     222             :         ASDM &getContainer() const;
     223             :         
     224             :         /**
     225             :          * Return the number of rows in the table.
     226             :          *
     227             :          * @return the number of rows in an unsigned int.
     228             :          */
     229             :         unsigned int size() const;
     230             :         
     231             :         /**
     232             :          * Return the name of this table.
     233             :          *
     234             :          * This is a instance method of the class.
     235             :          *
     236             :          * @return the name of this table in a string.
     237             :          */
     238             :         std::string getName() const;
     239             :         
     240             :         /**
     241             :          * Return the name of this table.
     242             :          *
     243             :          * This is a static method of the class.
     244             :          *
     245             :          * @return the name of this table in a string.
     246             :          */
     247             :         static std::string name() ;     
     248             :         
     249             :         /**
     250             :          * Return the version information about this table.
     251             :          *
     252             :          */
     253             :          std::string getVersion() const ;
     254             :         
     255             :         /**
     256             :          * Return the names of the attributes of this table.
     257             :          *
     258             :          * @return a vector of string
     259             :          */
     260             :          static const std::vector<std::string>& getAttributesNames();
     261             : 
     262             :         /**
     263             :          * Return the default sorted list of attributes names in the binary representation of the table.
     264             :          *
     265             :          * @return a const reference to a vector of string
     266             :          */
     267             :          static const std::vector<std::string>& defaultAttributesNamesInBin();
     268             :          
     269             :         /**
     270             :          * Return this table's Entity.
     271             :          */
     272             :         Entity getEntity() const;
     273             : 
     274             :         /**
     275             :          * Set this table's Entity.
     276             :          * @param e An entity. 
     277             :          */
     278             :         void setEntity(Entity e);
     279             :                 
     280             :         /**
     281             :          * Produces an XML representation conform
     282             :          * to the schema defined for CalGain (CalGainTable.xsd).
     283             :          *
     284             :          * @returns a string containing the XML representation.
     285             :          * @throws ConversionException
     286             :          */
     287             :         std::string toXML()  ;
     288             : 
     289             : #ifndef WITHOUT_ACS
     290             :         // Conversion Methods
     291             :         /**
     292             :          * Convert this table into a CalGainTableIDL CORBA structure.
     293             :          *
     294             :          * @return a pointer to a CalGainTableIDL
     295             :          */
     296             :         asdmIDL::CalGainTableIDL *toIDL() ;
     297             :         
     298             :         /**
     299             :          * Fills the CORBA data structure passed in parameter
     300             :          * with the content of this table.
     301             :          *
     302             :          * @param x a reference to the asdmIDL::CalGainTableIDL to be populated
     303             :          * with the content of this.
     304             :          */
     305             :          void toIDL(asdmIDL::CalGainTableIDL& x) const;
     306             :          
     307             : #endif
     308             : 
     309             : #ifndef WITHOUT_ACS
     310             :         /**
     311             :          * Populate this table from the content of a CalGainTableIDL Corba structure.
     312             :          *
     313             :          * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table.
     314             :          * @throws ConversionException
     315             :          */     
     316             :         void fromIDL(asdmIDL::CalGainTableIDL x) ;
     317             : #endif
     318             :         
     319             :         //
     320             :         // ====> Row creation.
     321             :         //
     322             :         
     323             :         /**
     324             :          * Create a new row with default values.
     325             :          * @return a pointer on a CalGainRow
     326             :          */
     327             :         CalGainRow *newRow();
     328             :         
     329             :         
     330             :         /**
     331             :          * Create a new row initialized to the specified values.
     332             :          * @return a pointer on the created and initialized row.
     333             :         
     334             :          * @param calDataId
     335             :         
     336             :          * @param calReductionId
     337             :         
     338             :          * @param startValidTime
     339             :         
     340             :          * @param endValidTime
     341             :         
     342             :          * @param gain
     343             :         
     344             :          * @param gainValid
     345             :         
     346             :          * @param fit
     347             :         
     348             :          * @param fitWeight
     349             :         
     350             :          * @param totalGainValid
     351             :         
     352             :          * @param totalFit
     353             :         
     354             :          * @param totalFitWeight
     355             :         
     356             :      */
     357             :         CalGainRow *newRow(Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, float gain, bool gainValid, float fit, float fitWeight, bool totalGainValid, float totalFit, float totalFitWeight);
     358             :         
     359             : 
     360             : 
     361             :         /**
     362             :          * Create a new row using a copy constructor mechanism.
     363             :          * 
     364             :          * The method creates a new CalGainRow owned by this. Each attribute of the created row 
     365             :          * is a (deep) copy of the corresponding attribute of row. The method does not add 
     366             :          * the created row to this, its simply parents it to this, a call to the add method
     367             :          * has to be done in order to get the row added (very likely after having modified
     368             :          * some of its attributes).
     369             :          * If row is null then the method returns a new CalGainRow with default values for its attributes. 
     370             :          *
     371             :          * @param row the row which is to be copied.
     372             :          */
     373             :          CalGainRow *newRow(CalGainRow *row); 
     374             : 
     375             :         //
     376             :         // ====> Append a row to its table.
     377             :         //
     378             :  
     379             :         
     380             :         /**
     381             :          * Add a row.
     382             :          * @param x a pointer to the CalGainRow to be added.
     383             :          *
     384             :          * @return a pointer to a CalGainRow. If the table contains a CalGainRow whose attributes (key and mandatory values) are equal to x ones
     385             :          * then returns a pointer on that CalGainRow, otherwise returns x.
     386             :          *
     387             :          * @throw DuplicateKey { thrown when the table contains a CalGainRow with a key equal to the x one but having
     388             :          * and a value section different from x one }
     389             :          *
     390             :         
     391             :          */
     392             :         CalGainRow* add(CalGainRow* x) ; 
     393             : 
     394             :  
     395             : 
     396             : 
     397             : 
     398             :         //
     399             :         // ====> Methods returning rows.
     400             :         //
     401             :                 
     402             :         /**
     403             :          * Get a collection of pointers on the rows of the table.
     404             :          * @return Alls rows in a vector of pointers of CalGainRow. The elements of this vector are stored in the order 
     405             :          * in which they have been added to the CalGainTable.
     406             :          */
     407             :         std::vector<CalGainRow *> get() ;
     408             :         
     409             :         /**
     410             :          * Get a const reference on the collection of rows pointers internally hold by the table.
     411             :          * @return A const reference of a vector of pointers of CalGainRow. The elements of this vector are stored in the order 
     412             :          * in which they have been added to the CalGainTable.
     413             :          *
     414             :          */
     415             :          const std::vector<CalGainRow *>& get() const ;
     416             :         
     417             : 
     418             : 
     419             :  
     420             :         
     421             :         /**
     422             :          * Returns a CalGainRow* given a key.
     423             :          * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
     424             :          * no row exists for that key.
     425             :         
     426             :          * @param calDataId
     427             :         
     428             :          * @param calReductionId
     429             :         
     430             :          *
     431             :          */
     432             :         CalGainRow* getRowByKey(Tag calDataId, Tag calReductionId);
     433             : 
     434             :                 
     435             : 
     436             : 
     437             : 
     438             :         /**
     439             :          * Look up the table for a row whose all attributes 
     440             :          * are equal to the corresponding parameters of the method.
     441             :          * @return a pointer on this row if any, null otherwise.
     442             :          *
     443             :                         
     444             :          * @param calDataId
     445             :                         
     446             :          * @param calReductionId
     447             :                         
     448             :          * @param startValidTime
     449             :                         
     450             :          * @param endValidTime
     451             :                         
     452             :          * @param gain
     453             :                         
     454             :          * @param gainValid
     455             :                         
     456             :          * @param fit
     457             :                         
     458             :          * @param fitWeight
     459             :                         
     460             :          * @param totalGainValid
     461             :                         
     462             :          * @param totalFit
     463             :                         
     464             :          * @param totalFitWeight
     465             :                          
     466             :          */
     467             :         CalGainRow* lookup(Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, float gain, bool gainValid, float fit, float fitWeight, bool totalGainValid, float totalFit, float totalFitWeight); 
     468             : 
     469             : 
     470             :         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
     471             :         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
     472             : 
     473             : private:
     474             : 
     475             :         /**
     476             :          * Create a CalGainTable.
     477             :          * <p>
     478             :          * This constructor is private because only the
     479             :          * container can create tables.  All tables must know the container
     480             :          * to which they belong.
     481             :          * @param container The container to which this table belongs.
     482             :          */ 
     483             :         CalGainTable (ASDM & container);
     484             : 
     485             :         ASDM & container;
     486             :         
     487             :         bool archiveAsBin; // If true archive binary else archive XML
     488             :         bool fileAsBin ; // If true file binary else file XML   
     489             :         
     490             :         std::string version ; 
     491             :         
     492             :         Entity entity;
     493             :         
     494             : 
     495             :         
     496             :         
     497             : 
     498             : 
     499             :         /**
     500             :          * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
     501             :          * Check if *x verifies the key uniqueness rule and throw an exception if not.
     502             :          * Append x to its table.
     503             :          * @throws DuplicateKey
     504             :          
     505             :          */
     506             :         CalGainRow* checkAndAdd(CalGainRow* x, bool skipCheckUniqueness=false) ;
     507             :         
     508             :         /**
     509             :          * Brutally append an CalGainRow x to the collection of rows already stored in this table. No uniqueness check is done !
     510             :          *
     511             :          * @param CalGainRow* x a pointer onto the CalGainRow to be appended.
     512             :          */
     513             :          void append(CalGainRow* x) ;
     514             :          
     515             :         /**
     516             :          * Brutally append an CalGainRow x to the collection of rows already stored in this table. No uniqueness check is done !
     517             :          *
     518             :          * @param CalGainRow* x a pointer onto the CalGainRow to be appended.
     519             :          */
     520             :          void addWithoutCheckingUnique(CalGainRow* x) ;
     521             :          
     522             :          
     523             : 
     524             : 
     525             : 
     526             : // A data structure to store the pointers on the table's rows.
     527             : 
     528             : // In all cases we maintain a private vector of CalGainRow s.
     529             :    std::vector<CalGainRow * > privateRows;
     530             :    
     531             : 
     532             :                         
     533             :         std::vector<CalGainRow *> row;
     534             : 
     535             :         
     536             :         void error() ; //throw(ConversionException);
     537             : 
     538             :         
     539             :         /**
     540             :          * Populate this table from the content of a XML document that is required to
     541             :          * be conform to the XML schema defined for a CalGain (CalGainTable.xsd).
     542             :          * @throws ConversionException
     543             :          * 
     544             :          */
     545             :         void fromXML(std::string& xmlDoc) ;
     546             :                 
     547             :         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
     548             : 
     549             :         /**
     550             :           * Private methods involved during the build of this table out of the content
     551             :           * of file(s) containing an external representation of a CalGain table.
     552             :           */
     553             :         void setFromMIMEFile(const std::string& directory);
     554             :         /*
     555             :         void openMIMEFile(const std::string& directory);
     556             :         */
     557             :         void setFromXMLFile(const std::string& directory);
     558             :         
     559             :                  /**
     560             :          * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
     561             :          * @returns a string containing the MIME message.
     562             :          *
     563             :          * @param byteOrder a const pointer to a static instance of the class ByteOrder.
     564             :          * 
     565             :          */
     566             :         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
     567             :   
     568             :         
     569             :    /** 
     570             :      * Extracts the binary part of a MIME message and deserialize its content
     571             :          * to fill this with the result of the deserialization. 
     572             :          * @param mimeMsg the string containing the MIME message.
     573             :          * @throws ConversionException
     574             :          */
     575             :          void setFromMIME(const std::string & mimeMsg);
     576             :         
     577             :         /**
     578             :           * Private methods involved during the export of this table into disk file(s).
     579             :           */
     580             :         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
     581             :         
     582             :         /**
     583             :           * Stores a representation (binary or XML) of this table into a file.
     584             :           *
     585             :           * Depending on the boolean value of its private field fileAsBin a binary serialization  of this (fileAsBin==true)  
     586             :           * will be saved in a file "CalGain.bin" or an XML representation (fileAsBin==false) will be saved in a file "CalGain.xml".
     587             :           * The file is always written in a directory whose name is passed as a parameter.
     588             :          * @param directory The name of directory  where the file containing the table's representation will be saved.
     589             :           * 
     590             :           */
     591             :           void toFile(std::string directory);
     592             :           
     593             :           /**
     594             :            * Load the table in memory if necessary.
     595             :            */
     596             :           bool loadInProgress;
     597           0 :           void checkPresenceInMemory() {
     598           0 :                 if (!presentInMemory && !loadInProgress) {
     599           0 :                         loadInProgress = true;
     600           0 :                         setFromFile(getContainer().getDirectory());
     601           0 :                         presentInMemory = true;
     602           0 :                         loadInProgress = false;
     603             :                 }
     604           0 :           }
     605             :         /**
     606             :          * Reads and parses a file containing a representation of a CalGainTable as those produced  by the toFile method.
     607             :          * This table is populated with the result of the parsing.
     608             :          * @param directory The name of the directory containing the file te be read and parsed.
     609             :          * @throws ConversionException If any error occurs while reading the 
     610             :          * files in the directory or parsing them.
     611             :          *
     612             :          */
     613             :          void setFromFile(const std::string& directory);    
     614             :  
     615             : };
     616             : 
     617             : } // End namespace asdm
     618             : 
     619             : #endif /* CalGainTable_CLASS */

Generated by: LCOV version 1.16