LCOV - code coverage report
Current view: top level - alma/ASDM - AlmaRadiometerTable.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 7 0.0 %
Date: 2024-10-12 00:35:29 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 AlmaRadiometerTable.h
      32             :  */
      33             :  
      34             : #ifndef AlmaRadiometerTable_CLASS
      35             : #define AlmaRadiometerTable_CLASS
      36             : 
      37             : #include <string>
      38             : #include <vector>
      39             : #include <map>
      40             : 
      41             : 
      42             : 
      43             :         
      44             : #include <alma/ASDM/Tag.h>
      45             :         
      46             : 
      47             : 
      48             : 
      49             : 
      50             :         
      51             : 
      52             :         
      53             : 
      54             : 
      55             : 
      56             : #include <alma/ASDM/ConversionException.h>
      57             : #include <alma/ASDM/DuplicateKey.h>
      58             : #include <alma/ASDM/UniquenessViolationException.h>
      59             : #include <alma/ASDM/NoSuchRow.h>
      60             : #include <alma/ASDM/DuplicateKey.h>
      61             : 
      62             : 
      63             : #ifndef WITHOUT_ACS
      64             : #include <asdmIDLC.h>
      65             : #endif
      66             : 
      67             : #include <alma/ASDM/Representable.h>
      68             : 
      69             : #include <pthread.h>
      70             : 
      71             : namespace asdm {
      72             : 
      73             : //class asdm::ASDM;
      74             : //class asdm::AlmaRadiometerRow;
      75             : 
      76             : class ASDM;
      77             : class AlmaRadiometerRow;
      78             : /**
      79             :  * The AlmaRadiometerTable class is an Alma table.
      80             :  * <BR>
      81             :  * 
      82             :  * \par Role
      83             :  * Properties of the Radiometer receiver/backend (used to monitor water vapour  content and correct phases). Note that standard properties (like  spectral coverage) are in the generic tables (like SpectralWindow).
      84             :  * <BR>
      85             :  
      86             :  * Generated from model's revision "-1", branch ""
      87             :  *
      88             :  * <TABLE BORDER="1">
      89             :  * <CAPTION> Attributes of AlmaRadiometer </CAPTION>
      90             :  * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape  </TH> <TH> Comment </TH></TR>
      91             :  
      92             :  * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR>
      93             :         
      94             :  * <TR>
      95             :                 
      96             :  * <TD><I> almaRadiometerId </I></TD>
      97             :                  
      98             :  * <TD> Tag</TD>
      99             :  * <TD> &nbsp; </TD>
     100             :  * <TD> &nbsp;identifies a unique row in the table. </TD>
     101             :  * </TR>
     102             :         
     103             : 
     104             : 
     105             : 
     106             :  * <TR> <TH BGCOLOR="#CCCCCC"  colspan="4" valign="center"> Value <br> (Optional) </TH></TR>
     107             :         
     108             :  * <TR>
     109             :  * <TD> numAntenna(numAntenna)</TD> 
     110             :  * <TD> int </TD>
     111             :  * <TD>  &nbsp; </TD>
     112             :  * <TD>&nbsp; the number of antennas. </TD>
     113             :  * </TR>
     114             :         
     115             :  * <TR>
     116             :  * <TD> spectralWindowId</TD> 
     117             :  * <TD> std::vector<Tag>  </TD>
     118             :  * <TD>  numAntenna  </TD>
     119             :  * <TD>&nbsp; the references to the actual spectral windows (one spectral window per antenna). </TD>
     120             :  * </TR>
     121             :         
     122             : 
     123             :  * </TABLE>
     124             :  */
     125             : class AlmaRadiometerTable : public Representable {
     126             :         friend class ASDM;
     127             : 
     128             : public:
     129             : 
     130             : 
     131             :         /**
     132             :          * Return the list of field names that make up key key
     133             :          * as an array of strings.
     134             :          * @return a vector of string.
     135             :          */     
     136             :         static const std::vector<std::string>& getKeyName();
     137             : 
     138             : 
     139             :         virtual ~AlmaRadiometerTable();
     140             :         
     141             :         /**
     142             :          * Return the container to which this table belongs.
     143             :          *
     144             :          * @return the ASDM containing this table.
     145             :          */
     146             :         ASDM &getContainer() const;
     147             :         
     148             :         /**
     149             :          * Return the number of rows in the table.
     150             :          *
     151             :          * @return the number of rows in an unsigned int.
     152             :          */
     153             :         unsigned int size() const;
     154             :         
     155             :         /**
     156             :          * Return the name of this table.
     157             :          *
     158             :          * This is a instance method of the class.
     159             :          *
     160             :          * @return the name of this table in a string.
     161             :          */
     162             :         std::string getName() const;
     163             :         
     164             :         /**
     165             :          * Return the name of this table.
     166             :          *
     167             :          * This is a static method of the class.
     168             :          *
     169             :          * @return the name of this table in a string.
     170             :          */
     171             :         static std::string name() ;     
     172             :         
     173             :         /**
     174             :          * Return the version information about this table.
     175             :          *
     176             :          */
     177             :          std::string getVersion() const ;
     178             :         
     179             :         /**
     180             :          * Return the names of the attributes of this table.
     181             :          *
     182             :          * @return a vector of string
     183             :          */
     184             :          static const std::vector<std::string>& getAttributesNames();
     185             : 
     186             :         /**
     187             :          * Return the default sorted list of attributes names in the binary representation of the table.
     188             :          *
     189             :          * @return a const reference to a vector of string
     190             :          */
     191             :          static const std::vector<std::string>& defaultAttributesNamesInBin();
     192             :          
     193             :         /**
     194             :          * Return this table's Entity.
     195             :          */
     196             :         Entity getEntity() const;
     197             : 
     198             :         /**
     199             :          * Set this table's Entity.
     200             :          * @param e An entity. 
     201             :          */
     202             :         void setEntity(Entity e);
     203             :                 
     204             :         /**
     205             :          * Produces an XML representation conform
     206             :          * to the schema defined for AlmaRadiometer (AlmaRadiometerTable.xsd).
     207             :          *
     208             :          * @returns a string containing the XML representation.
     209             :          * @throws ConversionException
     210             :          */
     211             :         std::string toXML()  ;
     212             : 
     213             : #ifndef WITHOUT_ACS
     214             :         // Conversion Methods
     215             :         /**
     216             :          * Convert this table into a AlmaRadiometerTableIDL CORBA structure.
     217             :          *
     218             :          * @return a pointer to a AlmaRadiometerTableIDL
     219             :          */
     220             :         asdmIDL::AlmaRadiometerTableIDL *toIDL() ;
     221             :         
     222             :         /**
     223             :          * Fills the CORBA data structure passed in parameter
     224             :          * with the content of this table.
     225             :          *
     226             :          * @param x a reference to the asdmIDL::AlmaRadiometerTableIDL to be populated
     227             :          * with the content of this.
     228             :          */
     229             :          void toIDL(asdmIDL::AlmaRadiometerTableIDL& x) const;
     230             :          
     231             : #endif
     232             : 
     233             : #ifndef WITHOUT_ACS
     234             :         /**
     235             :          * Populate this table from the content of a AlmaRadiometerTableIDL Corba structure.
     236             :          *
     237             :          * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table.
     238             :          * @throws ConversionException
     239             :          */     
     240             :         void fromIDL(asdmIDL::AlmaRadiometerTableIDL x) ;
     241             : #endif
     242             :         
     243             :         //
     244             :         // ====> Row creation.
     245             :         //
     246             :         
     247             :         /**
     248             :          * Create a new row with default values.
     249             :          * @return a pointer on a AlmaRadiometerRow
     250             :          */
     251             :         AlmaRadiometerRow *newRow();
     252             :         
     253             : 
     254             : 
     255             :         /**
     256             :          * Create a new row using a copy constructor mechanism.
     257             :          * 
     258             :          * The method creates a new AlmaRadiometerRow owned by this. Each attribute of the created row 
     259             :          * is a (deep) copy of the corresponding attribute of row. The method does not add 
     260             :          * the created row to this, its simply parents it to this, a call to the add method
     261             :          * has to be done in order to get the row added (very likely after having modified
     262             :          * some of its attributes).
     263             :          * If row is null then the method returns a new AlmaRadiometerRow with default values for its attributes. 
     264             :          *
     265             :          * @param row the row which is to be copied.
     266             :          */
     267             :          AlmaRadiometerRow *newRow(AlmaRadiometerRow *row); 
     268             : 
     269             :         //
     270             :         // ====> Append a row to its table.
     271             :         //
     272             : 
     273             :         
     274             :         
     275             :         
     276             :         /** 
     277             :          * Add a row.
     278             :          * If there table contains a row whose key's fields are equal
     279             :          * to x's ones then return a pointer on this row (i.e. no actual insertion is performed) 
     280             :          * otherwise add x to the table and return x.
     281             :          * @param x . A pointer on the row to be added.
     282             :          * @returns a pointer to a AlmaRadiometerRow.    
     283             :          */      
     284             :          
     285             :          AlmaRadiometerRow* add(AlmaRadiometerRow* x) ;
     286             : 
     287             : 
     288             : 
     289             :         //
     290             :         // ====> Methods returning rows.
     291             :         //
     292             :                 
     293             :         /**
     294             :          * Get a collection of pointers on the rows of the table.
     295             :          * @return Alls rows in a vector of pointers of AlmaRadiometerRow. The elements of this vector are stored in the order 
     296             :          * in which they have been added to the AlmaRadiometerTable.
     297             :          */
     298             :         std::vector<AlmaRadiometerRow *> get() ;
     299             :         
     300             :         /**
     301             :          * Get a const reference on the collection of rows pointers internally hold by the table.
     302             :          * @return A const reference of a vector of pointers of AlmaRadiometerRow. The elements of this vector are stored in the order 
     303             :          * in which they have been added to the AlmaRadiometerTable.
     304             :          *
     305             :          */
     306             :          const std::vector<AlmaRadiometerRow *>& get() const ;
     307             :         
     308             : 
     309             : 
     310             :  
     311             :         
     312             :         /**
     313             :          * Returns a AlmaRadiometerRow* given a key.
     314             :          * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
     315             :          * no row exists for that key.
     316             :         
     317             :          * @param almaRadiometerId
     318             :         
     319             :          *
     320             :          */
     321             :         AlmaRadiometerRow* getRowByKey(Tag almaRadiometerId);
     322             : 
     323             :                 
     324             : 
     325             : 
     326             : 
     327             : 
     328             :         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
     329             :         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
     330             : 
     331             : private:
     332             : 
     333             :         /**
     334             :          * Create a AlmaRadiometerTable.
     335             :          * <p>
     336             :          * This constructor is private because only the
     337             :          * container can create tables.  All tables must know the container
     338             :          * to which they belong.
     339             :          * @param container The container to which this table belongs.
     340             :          */ 
     341             :         AlmaRadiometerTable (ASDM & container);
     342             : 
     343             :         ASDM & container;
     344             :         
     345             :         bool archiveAsBin; // If true archive binary else archive XML
     346             :         bool fileAsBin ; // If true file binary else file XML   
     347             :         
     348             :         std::string version ; 
     349             :         
     350             :         Entity entity;
     351             :         
     352             : 
     353             :         
     354             :         
     355             : 
     356             :         // A map for the autoincrementation algorithm
     357             :         std::map<std::string,int>  noAutoIncIds;
     358             :         void autoIncrement(std::string key, AlmaRadiometerRow* x);
     359             : 
     360             : 
     361             :         /**
     362             :          * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
     363             :          * Check if *x verifies the key uniqueness rule and throw an exception if not.
     364             :          * Append x to its table.
     365             :          * @throws DuplicateKey
     366             :          
     367             :          * @throws UniquenessViolationException
     368             :          
     369             :          */
     370             :         AlmaRadiometerRow* checkAndAdd(AlmaRadiometerRow* x, bool skipCheckUniqueness=false) ;
     371             :         
     372             :         /**
     373             :          * Brutally append an AlmaRadiometerRow x to the collection of rows already stored in this table. No uniqueness check is done !
     374             :          *
     375             :          * @param AlmaRadiometerRow* x a pointer onto the AlmaRadiometerRow to be appended.
     376             :          */
     377             :          void append(AlmaRadiometerRow* x) ;
     378             :          
     379             :         /**
     380             :          * Brutally append an AlmaRadiometerRow x to the collection of rows already stored in this table. No uniqueness check is done !
     381             :          *
     382             :          * @param AlmaRadiometerRow* x a pointer onto the AlmaRadiometerRow to be appended.
     383             :          */
     384             :          void addWithoutCheckingUnique(AlmaRadiometerRow* x) ;
     385             :          
     386             :          
     387             : 
     388             : 
     389             : 
     390             : // A data structure to store the pointers on the table's rows.
     391             : 
     392             : // In all cases we maintain a private vector of AlmaRadiometerRow s.
     393             :    std::vector<AlmaRadiometerRow * > privateRows;
     394             :    
     395             : 
     396             :                         
     397             :         std::vector<AlmaRadiometerRow *> row;
     398             : 
     399             :         
     400             :         void error() ; //throw(ConversionException);
     401             : 
     402             :         
     403             :         /**
     404             :          * Populate this table from the content of a XML document that is required to
     405             :          * be conform to the XML schema defined for a AlmaRadiometer (AlmaRadiometerTable.xsd).
     406             :          * @throws ConversionException
     407             :          * 
     408             :          */
     409             :         void fromXML(std::string& xmlDoc) ;
     410             :                 
     411             :         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
     412             : 
     413             :         /**
     414             :           * Private methods involved during the build of this table out of the content
     415             :           * of file(s) containing an external representation of a AlmaRadiometer table.
     416             :           */
     417             :         void setFromMIMEFile(const std::string& directory);
     418             :         /*
     419             :         void openMIMEFile(const std::string& directory);
     420             :         */
     421             :         void setFromXMLFile(const std::string& directory);
     422             :         
     423             :                  /**
     424             :          * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
     425             :          * @returns a string containing the MIME message.
     426             :          *
     427             :          * @param byteOrder a const pointer to a static instance of the class ByteOrder.
     428             :          * 
     429             :          */
     430             :         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
     431             :   
     432             :         
     433             :    /** 
     434             :      * Extracts the binary part of a MIME message and deserialize its content
     435             :          * to fill this with the result of the deserialization. 
     436             :          * @param mimeMsg the string containing the MIME message.
     437             :          * @throws ConversionException
     438             :          */
     439             :          void setFromMIME(const std::string & mimeMsg);
     440             :         
     441             :         /**
     442             :           * Private methods involved during the export of this table into disk file(s).
     443             :           */
     444             :         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
     445             :         
     446             :         /**
     447             :           * Stores a representation (binary or XML) of this table into a file.
     448             :           *
     449             :           * Depending on the boolean value of its private field fileAsBin a binary serialization  of this (fileAsBin==true)  
     450             :           * will be saved in a file "AlmaRadiometer.bin" or an XML representation (fileAsBin==false) will be saved in a file "AlmaRadiometer.xml".
     451             :           * The file is always written in a directory whose name is passed as a parameter.
     452             :          * @param directory The name of directory  where the file containing the table's representation will be saved.
     453             :           * 
     454             :           */
     455             :           void toFile(std::string directory);
     456             :           
     457             :           /**
     458             :            * Load the table in memory if necessary.
     459             :            */
     460             :           bool loadInProgress;
     461           0 :           void checkPresenceInMemory() {
     462           0 :                 if (!presentInMemory && !loadInProgress) {
     463           0 :                         loadInProgress = true;
     464           0 :                         setFromFile(getContainer().getDirectory());
     465           0 :                         presentInMemory = true;
     466           0 :                         loadInProgress = false;
     467             :                 }
     468           0 :           }
     469             :         /**
     470             :          * Reads and parses a file containing a representation of a AlmaRadiometerTable as those produced  by the toFile method.
     471             :          * This table is populated with the result of the parsing.
     472             :          * @param directory The name of the directory containing the file te be read and parsed.
     473             :          * @throws ConversionException If any error occurs while reading the 
     474             :          * files in the directory or parsing them.
     475             :          *
     476             :          */
     477             :          void setFromFile(const std::string& directory);    
     478             :  
     479             : };
     480             : 
     481             : } // End namespace asdm
     482             : 
     483             : #endif /* AlmaRadiometerTable_CLASS */

Generated by: LCOV version 1.16