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

Generated by: LCOV version 1.16