casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalPrimaryBeamTable.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 CalPrimaryBeamTable.h
00032  */
00033  
00034 #ifndef CalPrimaryBeamTable_CLASS
00035 #define CalPrimaryBeamTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <Angle.h>
00049         
00050 
00051         
00052 #include <Tag.h>
00053         
00054 
00055         
00056 #include <Frequency.h>
00057         
00058 
00059         
00060 #include <EntityRef.h>
00061         
00062 
00063 
00064 
00065 
00066         
00067 
00068         
00069 #include "CReceiverBand.h"
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 #include "CAntennaMake.h"
00078         
00079 
00080         
00081 
00082         
00083 
00084         
00085 
00086         
00087 #include "CPolarizationType.h"
00088         
00089 
00090         
00091 
00092         
00093 
00094         
00095 
00096         
00097 
00098         
00099 
00100         
00101 
00102         
00103 #include "CPrimaryBeamDescription.h"
00104         
00105 
00106         
00107 
00108         
00109 
00110 
00111 
00112 #include <ConversionException.h>
00113 #include <DuplicateKey.h>
00114 #include <UniquenessViolationException.h>
00115 #include <NoSuchRow.h>
00116 #include <DuplicateKey.h>
00117 
00118 
00119 #ifndef WITHOUT_ACS
00120 #include <asdmIDLC.h>
00121 #endif
00122 
00123 #include <Representable.h>
00124 
00125 #include <pthread.h>
00126 
00127 namespace asdm {
00128 
00129 //class asdm::ASDM;
00130 //class asdm::CalPrimaryBeamRow;
00131 
00132 class ASDM;
00133 class CalPrimaryBeamRow;
00306 class CalPrimaryBeamTable : public Representable {
00307         friend class ASDM;
00308 
00309 public:
00310 
00311 
00317         static const std::vector<std::string>& getKeyName();
00318 
00319 
00320         virtual ~CalPrimaryBeamTable();
00321         
00327         ASDM &getContainer() const;
00328         
00334         unsigned int size() const;
00335         
00343         std::string getName() const;
00344         
00352         static std::string name() ;     
00353         
00358          std::string getVersion() const ;
00359         
00365          static const std::vector<std::string>& getAttributesNames();
00366 
00372          static const std::vector<std::string>& defaultAttributesNamesInBin();
00373          
00377         Entity getEntity() const;
00378 
00383         void setEntity(Entity e);
00384                 
00392         std::string toXML()  ;
00393 
00394 #ifndef WITHOUT_ACS
00395         // Conversion Methods
00401         asdmIDL::CalPrimaryBeamTableIDL *toIDL() ;
00402         
00410          void toIDL(asdmIDL::CalPrimaryBeamTableIDL& x) const;
00411          
00412 #endif
00413 
00414 #ifndef WITHOUT_ACS
00415 
00421         void fromIDL(asdmIDL::CalPrimaryBeamTableIDL x) ;
00422 #endif
00423         
00424         //
00425         // ====> Row creation.
00426         //
00427         
00432         CalPrimaryBeamRow *newRow();
00433         
00434         
00480         CalPrimaryBeamRow *newRow(string antennaName, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, AntennaMakeMod::AntennaMake antennaMake, int numSubband, vector<vector<Frequency > > frequencyRange, int numReceptor, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, vector<double > mainBeamEfficiency, EntityRef beamDescriptionUID, float relativeAmplitudeRms, vector<Angle > direction, vector<Angle > minValidDirection, vector<Angle > maxValidDirection, PrimaryBeamDescriptionMod::PrimaryBeamDescription descriptionType, vector<int > imageChannelNumber, vector<Frequency > imageNominalFrequency);
00481         
00482 
00483 
00496          CalPrimaryBeamRow *newRow(CalPrimaryBeamRow *row); 
00497 
00498         //
00499         // ====> Append a row to its table.
00500         //
00501  
00502         
00515         CalPrimaryBeamRow* add(CalPrimaryBeamRow* x) ; 
00516 
00517  
00518 
00519 
00520 
00521         //
00522         // ====> Methods returning rows.
00523         //
00524                 
00530         std::vector<CalPrimaryBeamRow *> get() ;
00531         
00538          const std::vector<CalPrimaryBeamRow *>& get() const ;
00539         
00540 
00541 
00542  
00543         
00559         CalPrimaryBeamRow* getRowByKey(string antennaName, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId);
00560 
00561                 
00562 
00563 
00564 
00612         CalPrimaryBeamRow* lookup(string antennaName, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, AntennaMakeMod::AntennaMake antennaMake, int numSubband, vector<vector<Frequency > > frequencyRange, int numReceptor, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, vector<double > mainBeamEfficiency, EntityRef beamDescriptionUID, float relativeAmplitudeRms, vector<Angle > direction, vector<Angle > minValidDirection, vector<Angle > maxValidDirection, PrimaryBeamDescriptionMod::PrimaryBeamDescription descriptionType, vector<int > imageChannelNumber, vector<Frequency > imageNominalFrequency); 
00613 
00614 
00615         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00616         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00617 
00618 private:
00619 
00628         CalPrimaryBeamTable (ASDM & container);
00629 
00630         ASDM & container;
00631         
00632         bool archiveAsBin; // If true archive binary else archive XML
00633         bool fileAsBin ; // If true file binary else file XML   
00634         
00635         std::string version ; 
00636         
00637         Entity entity;
00638         
00639 
00640 
00648         CalPrimaryBeamRow* checkAndAdd(CalPrimaryBeamRow* x, bool skipCheckUniqueness=false) ;
00649         
00655          void append(CalPrimaryBeamRow* x) ;
00656          
00662          void addWithoutCheckingUnique(CalPrimaryBeamRow* x) ;
00663          
00664          
00665 
00666 
00667 
00668 // A data structure to store the pointers on the table's rows.
00669 
00670 // In all cases we maintain a private vector of CalPrimaryBeamRow s.
00671    std::vector<CalPrimaryBeamRow * > privateRows;
00672    
00673 
00674                         
00675         std::vector<CalPrimaryBeamRow *> row;
00676 
00677         
00678         void error() ; //throw(ConversionException);
00679 
00680         
00687         void fromXML(std::string& xmlDoc) ;
00688                 
00689         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00690 
00695         void setFromMIMEFile(const std::string& directory);
00696         /*
00697         void openMIMEFile(const std::string& directory);
00698         */
00699         void setFromXMLFile(const std::string& directory);
00700         
00708         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00709   
00710         
00717          void setFromMIME(const std::string & mimeMsg);
00718         
00722         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00723         
00733           void toFile(std::string directory);
00734           
00738           bool loadInProgress;
00739           void checkPresenceInMemory() {
00740                 if (!presentInMemory && !loadInProgress) {
00741                         loadInProgress = true;
00742                         setFromFile(getContainer().getDirectory());
00743                         presentInMemory = true;
00744                         loadInProgress = false;
00745                 }
00746           }
00755          void setFromFile(const std::string& directory);        
00756  
00757 };
00758 
00759 } // End namespace asdm
00760 
00761 #endif /* CalPrimaryBeamTable_CLASS */