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

Generated by: LCOV version 1.16