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

Generated by: LCOV version 1.16