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 namespace asdm {
00126 
00127 //class asdm::ASDM;
00128 //class asdm::CalPrimaryBeamRow;
00129 
00130 class ASDM;
00131 class CalPrimaryBeamRow;
00304 class CalPrimaryBeamTable : public Representable {
00305         friend class ASDM;
00306 
00307 public:
00308 
00309 
00315         static std::vector<std::string> getKeyName();
00316 
00317 
00318         virtual ~CalPrimaryBeamTable();
00319         
00325         ASDM &getContainer() const;
00326         
00332         unsigned int size() const;
00333         
00341         std::string getName() const;
00342         
00350         static std::string name() ;     
00351         
00356          std::string getVersion() const ;
00357         
00363          static const std::vector<std::string>& getAttributesNames();
00364 
00370          static const std::vector<std::string>& defaultAttributesNamesInBin();
00371          
00375         Entity getEntity() const;
00376 
00381         void setEntity(Entity e);
00382                 
00390         std::string toXML()  ;
00391 
00392 #ifndef WITHOUT_ACS
00393         // Conversion Methods
00399         asdmIDL::CalPrimaryBeamTableIDL *toIDL() ;
00400 #endif
00401 
00402 #ifndef WITHOUT_ACS
00403 
00409         void fromIDL(asdmIDL::CalPrimaryBeamTableIDL x) ;
00410 #endif
00411         
00412         //
00413         // ====> Row creation.
00414         //
00415         
00420         CalPrimaryBeamRow *newRow();
00421         
00422         
00468         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);
00469         
00470 
00471 
00484          CalPrimaryBeamRow *newRow(CalPrimaryBeamRow *row); 
00485 
00486         //
00487         // ====> Append a row to its table.
00488         //
00489  
00490         
00503         CalPrimaryBeamRow* add(CalPrimaryBeamRow* x) ; 
00504 
00505  
00506 
00507 
00508 
00509         //
00510         // ====> Methods returning rows.
00511         //
00512                 
00518         std::vector<CalPrimaryBeamRow *> get() ;
00519         
00526          const std::vector<CalPrimaryBeamRow *>& get() const ;
00527         
00528 
00529 
00530  
00531         
00547         CalPrimaryBeamRow* getRowByKey(string antennaName, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId);
00548 
00549                 
00550 
00551 
00552 
00600         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); 
00601 
00602 
00603         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00604         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00605 
00606 private:
00607 
00616         CalPrimaryBeamTable (ASDM & container);
00617 
00618         ASDM & container;
00619         
00620         bool archiveAsBin; // If true archive binary else archive XML
00621         bool fileAsBin ; // If true file binary else file XML   
00622         
00623         std::string version ; 
00624         
00625         Entity entity;
00626         
00627 
00628 
00632         static std::string itsName;
00633         
00637         static std::vector<std::string> attributesNames;
00638         
00642         static std::vector<std::string> attributesNamesInBin;
00643         
00644 
00648         static bool initAttributesNames(), initAttributesNamesDone ;
00649         
00650 
00654         static std::vector<std::string> key;
00655 
00656 
00664         CalPrimaryBeamRow* checkAndAdd(CalPrimaryBeamRow* x) ;
00665         
00671          void append(CalPrimaryBeamRow* x) ;
00672          
00678          void addWithoutCheckingUnique(CalPrimaryBeamRow* x) ;
00679          
00680          
00681 
00682 
00683 
00684 // A data structure to store the pointers on the table's rows.
00685 
00686 // In all cases we maintain a private vector of CalPrimaryBeamRow s.
00687    std::vector<CalPrimaryBeamRow * > privateRows;
00688    
00689 
00690                         
00691         std::vector<CalPrimaryBeamRow *> row;
00692 
00693         
00694         void error() ; //throw(ConversionException);
00695 
00696         
00703         void fromXML(std::string& xmlDoc) ;
00704                 
00705         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00706 
00711         void setFromMIMEFile(const std::string& directory);
00712         /*
00713         void openMIMEFile(const std::string& directory);
00714         */
00715         void setFromXMLFile(const std::string& directory);
00716         
00724         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00725   
00726         
00733          void setFromMIME(const std::string & mimeMsg);
00734         
00738         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00739         
00749           void toFile(std::string directory);
00750           
00754           bool loadInProgress;
00755           void checkPresenceInMemory() {
00756                 if (!presentInMemory && !loadInProgress) {
00757                         loadInProgress = true;
00758                         setFromFile(getContainer().getDirectory());
00759                         presentInMemory = true;
00760                         loadInProgress = false;
00761                 }
00762           }
00771          void setFromFile(const std::string& directory);        
00772  
00773 };
00774 
00775 } // End namespace asdm
00776 
00777 #endif /* CalPrimaryBeamTable_CLASS */