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

Generated by: LCOV version 1.16