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

Generated by: LCOV version 1.16