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

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

Generated by: LCOV version 1.16