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

Generated by: LCOV version 1.16