casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GainTrackingTable.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 GainTrackingTable.h
00032  */
00033  
00034 #ifndef GainTrackingTable_CLASS
00035 #define GainTrackingTable_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 #include <ComplexWrapper.h>
00053         
00054 
00055 
00056 
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 #include "CPolarizationType.h"
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076 
00077 
00078 #include <ConversionException.h>
00079 #include <DuplicateKey.h>
00080 #include <UniquenessViolationException.h>
00081 #include <NoSuchRow.h>
00082 #include <DuplicateKey.h>
00083 
00084 
00085 #ifndef WITHOUT_ACS
00086 #include <asdmIDLC.h>
00087 #endif
00088 
00089 #include <Representable.h>
00090 
00091 #include <pthread.h>
00092 
00093 namespace asdm {
00094 
00095 //class asdm::ASDM;
00096 //class asdm::GainTrackingRow;
00097 
00098 class ASDM;
00099 class GainTrackingRow;
00212 class GainTrackingTable : public Representable {
00213         friend class ASDM;
00214 
00215 public:
00216 
00217 
00223         static const std::vector<std::string>& getKeyName();
00224 
00225 
00226         virtual ~GainTrackingTable();
00227         
00233         ASDM &getContainer() const;
00234         
00240         unsigned int size() const;
00241         
00249         std::string getName() const;
00250         
00258         static std::string name() ;     
00259         
00264          std::string getVersion() const ;
00265         
00271          static const std::vector<std::string>& getAttributesNames();
00272 
00278          static const std::vector<std::string>& defaultAttributesNamesInBin();
00279          
00283         Entity getEntity() const;
00284 
00289         void setEntity(Entity e);
00290                 
00298         std::string toXML()  ;
00299 
00300 #ifndef WITHOUT_ACS
00301         // Conversion Methods
00307         asdmIDL::GainTrackingTableIDL *toIDL() ;
00308         
00316          void toIDL(asdmIDL::GainTrackingTableIDL& x) const;
00317          
00318 #endif
00319 
00320 #ifndef WITHOUT_ACS
00321 
00327         void fromIDL(asdmIDL::GainTrackingTableIDL x) ;
00328 #endif
00329         
00330         //
00331         // ====> Row creation.
00332         //
00333         
00338         GainTrackingRow *newRow();
00339         
00340         
00360         GainTrackingRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, vector<float > attenuator, vector<PolarizationTypeMod::PolarizationType > polarizationType);
00361         
00362 
00363 
00376          GainTrackingRow *newRow(GainTrackingRow *row); 
00377 
00378         //
00379         // ====> Append a row to its table.
00380         //
00381  
00382         
00399         GainTrackingRow* add(GainTrackingRow* x) ; 
00400 
00401  
00402 
00403 
00404 
00405         //
00406         // ====> Methods returning rows.
00407         //
00408                 
00414         std::vector<GainTrackingRow *> get() ;
00415         
00422          const std::vector<GainTrackingRow *>& get() const ;
00423         
00424 
00435          std::vector <GainTrackingRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
00436          
00437 
00438 
00439  
00440         
00456         GainTrackingRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
00457 
00458                 
00459 
00460 
00461 
00483         GainTrackingRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, vector<float > attenuator, vector<PolarizationTypeMod::PolarizationType > polarizationType); 
00484 
00485 
00486         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00487         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00488 
00489 private:
00490 
00499         GainTrackingTable (ASDM & container);
00500 
00501         ASDM & container;
00502         
00503         bool archiveAsBin; // If true archive binary else archive XML
00504         bool fileAsBin ; // If true file binary else file XML   
00505         
00506         std::string version ; 
00507         
00508         Entity entity;
00509         
00510 
00511 
00519         GainTrackingRow* checkAndAdd(GainTrackingRow* x, bool skipCheckUniqueness=false) ;
00520         
00526          void append(GainTrackingRow* x) ;
00527          
00533          void addWithoutCheckingUnique(GainTrackingRow* x) ;
00534          
00535          
00536 
00537 
00538         
00539         
00547          GainTrackingRow * insertByStartTime(GainTrackingRow* x, std::vector<GainTrackingRow* >& row);
00548           
00549 
00550 
00551 // A data structure to store the pointers on the table's rows.
00552 
00553 // In all cases we maintain a private vector of GainTrackingRow s.
00554    std::vector<GainTrackingRow * > privateRows;
00555    
00556 
00557         
00558 
00559         
00560         
00561                 
00562                                 
00563         typedef std::vector <GainTrackingRow* > TIME_ROWS;
00564         std::map<std::string, TIME_ROWS > context;
00565                 
00570          std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
00571                  
00572                 
00573         
00574         
00580         void getByKeyNoAutoIncNoTime(std::vector <GainTrackingRow*>& vin, std::vector <GainTrackingRow*>& vout,  Tag antennaId, Tag spectralWindowId, int feedId);
00581         
00582 
00583         
00584         void error() ; //throw(ConversionException);
00585 
00586         
00593         void fromXML(std::string& xmlDoc) ;
00594                 
00595         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00596 
00601         void setFromMIMEFile(const std::string& directory);
00602         /*
00603         void openMIMEFile(const std::string& directory);
00604         */
00605         void setFromXMLFile(const std::string& directory);
00606         
00614         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00615   
00616         
00623          void setFromMIME(const std::string & mimeMsg);
00624         
00628         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00629         
00639           void toFile(std::string directory);
00640           
00644           bool loadInProgress;
00645           void checkPresenceInMemory() {
00646                 if (!presentInMemory && !loadInProgress) {
00647                         loadInProgress = true;
00648                         setFromFile(getContainer().getDirectory());
00649                         presentInMemory = true;
00650                         loadInProgress = false;
00651                 }
00652           }
00661          void setFromFile(const std::string& directory);        
00662  
00663 };
00664 
00665 } // End namespace asdm
00666 
00667 #endif /* GainTrackingTable_CLASS */