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

Generated by: LCOV version 1.16