casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SysPowerTable.h
Go to the documentation of this file.
00001 
00002 /*
00003  * ALMA - Atacama Large Millimeter Array
00004  * (c) European Southern Observatory, 2002
00005  * (c) Associated Universities Inc., 2002
00006  * Copyright by ESO (in the framework of the ALMA collaboration),
00007  * Copyright by AUI (in the framework of the ALMA collaboration),
00008  * All rights reserved.
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free software Foundation; either
00013  * version 2.1 of the License, or (at your option) any later version.
00014  * 
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY, without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023  * MA 02111-1307  USA
00024  *
00025  * Warning!
00026  *  -------------------------------------------------------------------- 
00027  * | This is generated code!  Do not modify this file.                  |
00028  * | If you do, all changes will be lost when the file is re-generated. |
00029  *  --------------------------------------------------------------------
00030  *
00031  * File SysPowerTable.h
00032  */
00033  
00034 #ifndef SysPowerTable_CLASS
00035 #define SysPowerTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047         
00048 #include <ArrayTimeInterval.h>
00049         
00050 
00051 
00052 
00053 
00054         
00055 
00056         
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064 
00065 
00066 #include <ConversionException.h>
00067 #include <DuplicateKey.h>
00068 #include <UniquenessViolationException.h>
00069 #include <NoSuchRow.h>
00070 #include <DuplicateKey.h>
00071 
00072 
00073 #ifndef WITHOUT_ACS
00074 #include <asdmIDLC.h>
00075 #endif
00076 
00077 #include <Representable.h>
00078 
00079 #include <pthread.h>
00080 
00081 namespace asdm {
00082 
00083 //class asdm::ASDM;
00084 //class asdm::SysPowerRow;
00085 
00086 class ASDM;
00087 class SysPowerRow;
00184 class SysPowerTable : public Representable {
00185         friend class ASDM;
00186 
00187 public:
00188 
00189 
00195         static const std::vector<std::string>& getKeyName();
00196 
00197 
00198         virtual ~SysPowerTable();
00199         
00205         ASDM &getContainer() const;
00206         
00212         unsigned int size() const;
00213         
00221         std::string getName() const;
00222         
00230         static std::string name() ;     
00231         
00236          std::string getVersion() const ;
00237         
00243          static const std::vector<std::string>& getAttributesNames();
00244 
00250          static const std::vector<std::string>& defaultAttributesNamesInBin();
00251          
00255         Entity getEntity() const;
00256 
00261         void setEntity(Entity e);
00262                 
00270         std::string toXML()  ;
00271 
00272 #ifndef WITHOUT_ACS
00273         // Conversion Methods
00279         asdmIDL::SysPowerTableIDL *toIDL() ;
00280         
00288          void toIDL(asdmIDL::SysPowerTableIDL& x) const;
00289          
00290 #endif
00291 
00292 #ifndef WITHOUT_ACS
00293 
00299         void fromIDL(asdmIDL::SysPowerTableIDL x) ;
00300 #endif
00301         
00302         //
00303         // ====> Row creation.
00304         //
00305         
00310         SysPowerRow *newRow();
00311         
00312         
00328         SysPowerRow *newRow(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval, int numReceptor);
00329         
00330 
00331 
00344          SysPowerRow *newRow(SysPowerRow *row); 
00345 
00346         //
00347         // ====> Append a row to its table.
00348         //
00349  
00350         
00367         SysPowerRow* add(SysPowerRow* x) ; 
00368 
00369  
00370 
00371 
00372 
00373         //
00374         // ====> Methods returning rows.
00375         //
00376                 
00382         std::vector<SysPowerRow *> get() ;
00383         
00390          const std::vector<SysPowerRow *>& get() const ;
00391         
00392 
00403          std::vector <SysPowerRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
00404          
00405 
00406 
00407  
00408         
00424         SysPowerRow* getRowByKey(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval);
00425 
00426                 
00427 
00428 
00429 
00447         SysPowerRow* lookup(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval, int numReceptor); 
00448 
00449 
00450         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00451         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00452 
00453 private:
00454 
00463         SysPowerTable (ASDM & container);
00464 
00465         ASDM & container;
00466         
00467         bool archiveAsBin; // If true archive binary else archive XML
00468         bool fileAsBin ; // If true file binary else file XML   
00469         
00470         std::string version ; 
00471         
00472         Entity entity;
00473         
00474 
00475 
00483         SysPowerRow* checkAndAdd(SysPowerRow* x, bool skipCheckUniqueness=false) ;
00484         
00490          void append(SysPowerRow* x) ;
00491          
00497          void addWithoutCheckingUnique(SysPowerRow* x) ;
00498          
00499          
00500 
00501 
00502         
00503         
00511          SysPowerRow * insertByStartTime(SysPowerRow* x, std::vector<SysPowerRow* >& row);
00512           
00513 
00514 
00515 // A data structure to store the pointers on the table's rows.
00516 
00517 // In all cases we maintain a private vector of SysPowerRow s.
00518    std::vector<SysPowerRow * > privateRows;
00519    
00520 
00521         
00522 
00523         
00524         
00525                 
00526                                 
00527         typedef std::vector <SysPowerRow* > TIME_ROWS;
00528         std::map<std::string, TIME_ROWS > context;
00529                 
00534          std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
00535                  
00536                 
00537         
00538         
00544         void getByKeyNoAutoIncNoTime(std::vector <SysPowerRow*>& vin, std::vector <SysPowerRow*>& vout,  Tag antennaId, Tag spectralWindowId, int feedId);
00545         
00546 
00547         
00548         void error() ; //throw(ConversionException);
00549 
00550         
00557         void fromXML(std::string& xmlDoc) ;
00558                 
00559         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00560 
00565         void setFromMIMEFile(const std::string& directory);
00566         /*
00567         void openMIMEFile(const std::string& directory);
00568         */
00569         void setFromXMLFile(const std::string& directory);
00570         
00578         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00579   
00580         
00587          void setFromMIME(const std::string & mimeMsg);
00588         
00592         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00593         
00603           void toFile(std::string directory);
00604           
00608           bool loadInProgress;
00609           void checkPresenceInMemory() {
00610                 if (!presentInMemory && !loadInProgress) {
00611                         loadInProgress = true;
00612                         setFromFile(getContainer().getDirectory());
00613                         presentInMemory = true;
00614                         loadInProgress = false;
00615                 }
00616           }
00625          void setFromFile(const std::string& directory);        
00626  
00627 };
00628 
00629 } // End namespace asdm
00630 
00631 #endif /* SysPowerTable_CLASS */