LCOV - code coverage report
Current view: top level - alma/ASDM - AntennaTable.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 7 7 100.0 %
Date: 2024-12-11 20:54:31 Functions: 1 1 100.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 AntennaTable.h
      32             :  */
      33             :  
      34             : #ifndef AntennaTable_CLASS
      35             : #define AntennaTable_CLASS
      36             : 
      37             : #include <string>
      38             : #include <vector>
      39             : #include <map>
      40             : 
      41             : 
      42             : 
      43             :         
      44             : #include <alma/ASDM/Length.h>
      45             :         
      46             : 
      47             :         
      48             : #include <alma/ASDM/ArrayTime.h>
      49             :         
      50             : 
      51             :         
      52             : #include <alma/ASDM/Tag.h>
      53             :         
      54             : 
      55             : 
      56             : 
      57             : 
      58             :         
      59             : 
      60             :         
      61             : 
      62             :         
      63             : #include <alma/Enumerations/CAntennaMake.h>
      64             :         
      65             : 
      66             :         
      67             : #include <alma/Enumerations/CAntennaType.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::AntennaRow;
      99             : 
     100             : class ASDM;
     101             : class AntennaRow;
     102             : /**
     103             :  * The AntennaTable class is an Alma table.
     104             :  * <BR>
     105             :  * 
     106             :  * \par Role
     107             :  * Antenna characteristics.
     108             :  * <BR>
     109             :  
     110             :  * Generated from model's revision "-1", branch ""
     111             :  *
     112             :  * <TABLE BORDER="1">
     113             :  * <CAPTION> Attributes of Antenna </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> antennaId </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> name </TD> 
     133             :  * <TD> std::string </TD>
     134             :  * <TD>  &nbsp;  </TD> 
     135             :  * <TD> &nbsp;the antenna's name. </TD>
     136             :  * </TR>
     137             :         
     138             :  * <TR>
     139             :  * <TD> antennaMake </TD> 
     140             :  * <TD> AntennaMakeMod::AntennaMake </TD>
     141             :  * <TD>  &nbsp;  </TD> 
     142             :  * <TD> &nbsp;the antenna's make. </TD>
     143             :  * </TR>
     144             :         
     145             :  * <TR>
     146             :  * <TD> antennaType </TD> 
     147             :  * <TD> AntennaTypeMod::AntennaType </TD>
     148             :  * <TD>  &nbsp;  </TD> 
     149             :  * <TD> &nbsp;the antenna's type. </TD>
     150             :  * </TR>
     151             :         
     152             :  * <TR>
     153             :  * <TD> dishDiameter </TD> 
     154             :  * <TD> Length </TD>
     155             :  * <TD>  &nbsp;  </TD> 
     156             :  * <TD> &nbsp;the diameter of the main reflector. </TD>
     157             :  * </TR>
     158             :         
     159             :  * <TR>
     160             :  * <TD> position </TD> 
     161             :  * <TD> std::vector<Length > </TD>
     162             :  * <TD>  3 </TD> 
     163             :  * <TD> &nbsp;the antenna's position. </TD>
     164             :  * </TR>
     165             :         
     166             :  * <TR>
     167             :  * <TD> offset </TD> 
     168             :  * <TD> std::vector<Length > </TD>
     169             :  * <TD>  3 </TD> 
     170             :  * <TD> &nbsp;the position's offset. </TD>
     171             :  * </TR>
     172             :         
     173             :  * <TR>
     174             :  * <TD> time </TD> 
     175             :  * <TD> ArrayTime </TD>
     176             :  * <TD>  &nbsp;  </TD> 
     177             :  * <TD> &nbsp;the time of position's measurement. </TD>
     178             :  * </TR>
     179             :         
     180             :  * <TR>
     181             :  * <TD> stationId </TD> 
     182             :  * <TD> Tag </TD>
     183             :  * <TD>  &nbsp;  </TD> 
     184             :  * <TD> &nbsp;refers to the station where this antenna is located (i.e. one row in the Station table). </TD>
     185             :  * </TR>
     186             :         
     187             : 
     188             : 
     189             :  * <TR> <TH BGCOLOR="#CCCCCC"  colspan="4" valign="center"> Value <br> (Optional) </TH></TR>
     190             :         
     191             :  * <TR>
     192             :  * <TD> assocAntennaId</TD> 
     193             :  * <TD> Tag </TD>
     194             :  * <TD>  &nbsp; </TD>
     195             :  * <TD>&nbsp; refers to an associate antenna (i.e. one row in the Antenna table). </TD>
     196             :  * </TR>
     197             :         
     198             : 
     199             :  * </TABLE>
     200             :  */
     201             : class AntennaTable : 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 ~AntennaTable();
     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 Antenna (AntennaTable.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 AntennaTableIDL CORBA structure.
     293             :          *
     294             :          * @return a pointer to a AntennaTableIDL
     295             :          */
     296             :         asdmIDL::AntennaTableIDL *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::AntennaTableIDL to be populated
     303             :          * with the content of this.
     304             :          */
     305             :          void toIDL(asdmIDL::AntennaTableIDL& x) const;
     306             :          
     307             : #endif
     308             : 
     309             : #ifndef WITHOUT_ACS
     310             :         /**
     311             :          * Populate this table from the content of a AntennaTableIDL 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::AntennaTableIDL 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 AntennaRow
     326             :          */
     327             :         AntennaRow *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 name
     335             :         
     336             :          * @param antennaMake
     337             :         
     338             :          * @param antennaType
     339             :         
     340             :          * @param dishDiameter
     341             :         
     342             :          * @param position
     343             :         
     344             :          * @param offset
     345             :         
     346             :          * @param time
     347             :         
     348             :          * @param stationId
     349             :         
     350             :      */
     351             :         AntennaRow *newRow(std::string name, AntennaMakeMod::AntennaMake antennaMake, AntennaTypeMod::AntennaType antennaType, Length dishDiameter, std::vector<Length > position, std::vector<Length > offset, ArrayTime time, Tag stationId);
     352             :         
     353             : 
     354             : 
     355             :         /**
     356             :          * Create a new row using a copy constructor mechanism.
     357             :          * 
     358             :          * The method creates a new AntennaRow owned by this. Each attribute of the created row 
     359             :          * is a (deep) copy of the corresponding attribute of row. The method does not add 
     360             :          * the created row to this, its simply parents it to this, a call to the add method
     361             :          * has to be done in order to get the row added (very likely after having modified
     362             :          * some of its attributes).
     363             :          * If row is null then the method returns a new AntennaRow with default values for its attributes. 
     364             :          *
     365             :          * @param row the row which is to be copied.
     366             :          */
     367             :          AntennaRow *newRow(AntennaRow *row); 
     368             : 
     369             :         //
     370             :         // ====> Append a row to its table.
     371             :         //
     372             : 
     373             :         
     374             :         
     375             :         
     376             :         /** 
     377             :          * Add a row.
     378             :          * If there table contains a row whose key's fields are equal
     379             :          * to x's ones then return a pointer on this row (i.e. no actual insertion is performed) 
     380             :          * otherwise add x to the table and return x.
     381             :          * @param x . A pointer on the row to be added.
     382             :          * @returns a pointer to a AntennaRow.   
     383             :          */      
     384             :          
     385             :          AntennaRow* add(AntennaRow* x) ;
     386             : 
     387             : 
     388             : 
     389             :         //
     390             :         // ====> Methods returning rows.
     391             :         //
     392             :                 
     393             :         /**
     394             :          * Get a collection of pointers on the rows of the table.
     395             :          * @return Alls rows in a vector of pointers of AntennaRow. The elements of this vector are stored in the order 
     396             :          * in which they have been added to the AntennaTable.
     397             :          */
     398             :         std::vector<AntennaRow *> get() ;
     399             :         
     400             :         /**
     401             :          * Get a const reference on the collection of rows pointers internally hold by the table.
     402             :          * @return A const reference of a vector of pointers of AntennaRow. The elements of this vector are stored in the order 
     403             :          * in which they have been added to the AntennaTable.
     404             :          *
     405             :          */
     406             :          const std::vector<AntennaRow *>& get() const ;
     407             :         
     408             : 
     409             : 
     410             :  
     411             :         
     412             :         /**
     413             :          * Returns a AntennaRow* given a key.
     414             :          * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
     415             :          * no row exists for that key.
     416             :         
     417             :          * @param antennaId
     418             :         
     419             :          *
     420             :          */
     421             :         AntennaRow* getRowByKey(Tag antennaId);
     422             : 
     423             :                 
     424             : 
     425             : 
     426             : 
     427             :         /**
     428             :          * Look up the table for a row whose all attributes  except the autoincrementable one 
     429             :          * are equal to the corresponding parameters of the method.
     430             :          * @return a pointer on this row if any, null otherwise.
     431             :          *
     432             :                         
     433             :          * @param name
     434             :                         
     435             :          * @param antennaMake
     436             :                         
     437             :          * @param antennaType
     438             :                         
     439             :          * @param dishDiameter
     440             :                         
     441             :          * @param position
     442             :                         
     443             :          * @param offset
     444             :                         
     445             :          * @param time
     446             :                         
     447             :          * @param stationId
     448             :                          
     449             :          */
     450             :         AntennaRow* lookup(std::string name, AntennaMakeMod::AntennaMake antennaMake, AntennaTypeMod::AntennaType antennaType, Length dishDiameter, std::vector<Length > position, std::vector<Length > offset, ArrayTime time, Tag stationId); 
     451             : 
     452             : 
     453             :         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
     454             :         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
     455             : 
     456             : private:
     457             : 
     458             :         /**
     459             :          * Create a AntennaTable.
     460             :          * <p>
     461             :          * This constructor is private because only the
     462             :          * container can create tables.  All tables must know the container
     463             :          * to which they belong.
     464             :          * @param container The container to which this table belongs.
     465             :          */ 
     466             :         AntennaTable (ASDM & container);
     467             : 
     468             :         ASDM & container;
     469             :         
     470             :         bool archiveAsBin; // If true archive binary else archive XML
     471             :         bool fileAsBin ; // If true file binary else file XML   
     472             :         
     473             :         std::string version ; 
     474             :         
     475             :         Entity entity;
     476             :         
     477             : 
     478             :         
     479             :         
     480             : 
     481             :         // A map for the autoincrementation algorithm
     482             :         std::map<std::string,int>  noAutoIncIds;
     483             :         void autoIncrement(std::string key, AntennaRow* x);
     484             : 
     485             : 
     486             :         /**
     487             :          * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
     488             :          * Check if *x verifies the key uniqueness rule and throw an exception if not.
     489             :          * Append x to its table.
     490             :          * @throws DuplicateKey
     491             :          
     492             :          * @throws UniquenessViolationException
     493             :          
     494             :          */
     495             :         AntennaRow* checkAndAdd(AntennaRow* x, bool skipCheckUniqueness=false) ;
     496             :         
     497             :         /**
     498             :          * Brutally append an AntennaRow x to the collection of rows already stored in this table. No uniqueness check is done !
     499             :          *
     500             :          * @param AntennaRow* x a pointer onto the AntennaRow to be appended.
     501             :          */
     502             :          void append(AntennaRow* x) ;
     503             :          
     504             :         /**
     505             :          * Brutally append an AntennaRow x to the collection of rows already stored in this table. No uniqueness check is done !
     506             :          *
     507             :          * @param AntennaRow* x a pointer onto the AntennaRow to be appended.
     508             :          */
     509             :          void addWithoutCheckingUnique(AntennaRow* x) ;
     510             :          
     511             :          
     512             : 
     513             : 
     514             : 
     515             : // A data structure to store the pointers on the table's rows.
     516             : 
     517             : // In all cases we maintain a private vector of AntennaRow s.
     518             :    std::vector<AntennaRow * > privateRows;
     519             :    
     520             : 
     521             :                         
     522             :         std::vector<AntennaRow *> row;
     523             : 
     524             :         
     525             :         void error() ; //throw(ConversionException);
     526             : 
     527             :         
     528             :         /**
     529             :          * Populate this table from the content of a XML document that is required to
     530             :          * be conform to the XML schema defined for a Antenna (AntennaTable.xsd).
     531             :          * @throws ConversionException
     532             :          * 
     533             :          */
     534             :         void fromXML(std::string& xmlDoc) ;
     535             :                 
     536             :         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
     537             : 
     538             :         /**
     539             :           * Private methods involved during the build of this table out of the content
     540             :           * of file(s) containing an external representation of a Antenna table.
     541             :           */
     542             :         void setFromMIMEFile(const std::string& directory);
     543             :         /*
     544             :         void openMIMEFile(const std::string& directory);
     545             :         */
     546             :         void setFromXMLFile(const std::string& directory);
     547             :         
     548             :                  /**
     549             :          * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
     550             :          * @returns a string containing the MIME message.
     551             :          *
     552             :          * @param byteOrder a const pointer to a static instance of the class ByteOrder.
     553             :          * 
     554             :          */
     555             :         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
     556             :   
     557             :         
     558             :    /** 
     559             :      * Extracts the binary part of a MIME message and deserialize its content
     560             :          * to fill this with the result of the deserialization. 
     561             :          * @param mimeMsg the string containing the MIME message.
     562             :          * @throws ConversionException
     563             :          */
     564             :          void setFromMIME(const std::string & mimeMsg);
     565             :         
     566             :         /**
     567             :           * Private methods involved during the export of this table into disk file(s).
     568             :           */
     569             :         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
     570             :         
     571             :         /**
     572             :           * Stores a representation (binary or XML) of this table into a file.
     573             :           *
     574             :           * Depending on the boolean value of its private field fileAsBin a binary serialization  of this (fileAsBin==true)  
     575             :           * will be saved in a file "Antenna.bin" or an XML representation (fileAsBin==false) will be saved in a file "Antenna.xml".
     576             :           * The file is always written in a directory whose name is passed as a parameter.
     577             :          * @param directory The name of directory  where the file containing the table's representation will be saved.
     578             :           * 
     579             :           */
     580             :           void toFile(std::string directory);
     581             :           
     582             :           /**
     583             :            * Load the table in memory if necessary.
     584             :            */
     585             :           bool loadInProgress;
     586        3725 :           void checkPresenceInMemory() {
     587        3725 :                 if (!presentInMemory && !loadInProgress) {
     588          82 :                         loadInProgress = true;
     589          82 :                         setFromFile(getContainer().getDirectory());
     590          82 :                         presentInMemory = true;
     591          82 :                         loadInProgress = false;
     592             :                 }
     593        3725 :           }
     594             :         /**
     595             :          * Reads and parses a file containing a representation of a AntennaTable as those produced  by the toFile method.
     596             :          * This table is populated with the result of the parsing.
     597             :          * @param directory The name of the directory containing the file te be read and parsed.
     598             :          * @throws ConversionException If any error occurs while reading the 
     599             :          * files in the directory or parsing them.
     600             :          *
     601             :          */
     602             :          void setFromFile(const std::string& directory);    
     603             :  
     604             : };
     605             : 
     606             : } // End namespace asdm
     607             : 
     608             : #endif /* AntennaTable_CLASS */

Generated by: LCOV version 1.16