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

Generated by: LCOV version 1.16