casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalAmpliTable.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 CalAmpliTable.h
00032  */
00033  
00034 #ifndef CalAmpliTable_CLASS
00035 #define CalAmpliTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <Tag.h>
00049         
00050 
00051         
00052 #include <Frequency.h>
00053         
00054 
00055 
00056 
00057 
00058         
00059 
00060         
00061 #include "CAtmPhaseCorrection.h"
00062         
00063 
00064         
00065 #include "CReceiverBand.h"
00066         
00067 
00068         
00069 #include "CBasebandName.h"
00070         
00071 
00072         
00073 
00074         
00075 #include "CPolarizationType.h"
00076         
00077 
00078         
00079 
00080         
00081 
00082         
00083 
00084         
00085 
00086         
00087 
00088         
00089 
00090 
00091 
00092 #include <ConversionException.h>
00093 #include <DuplicateKey.h>
00094 #include <UniquenessViolationException.h>
00095 #include <NoSuchRow.h>
00096 #include <DuplicateKey.h>
00097 
00098 
00099 #ifndef WITHOUT_ACS
00100 #include <asdmIDLC.h>
00101 #endif
00102 
00103 #include <Representable.h>
00104 
00105 namespace asdm {
00106 
00107 //class asdm::ASDM;
00108 //class asdm::CalAmpliRow;
00109 
00110 class ASDM;
00111 class CalAmpliRow;
00249 class CalAmpliTable : public Representable {
00250         friend class ASDM;
00251 
00252 public:
00253 
00254 
00260         static std::vector<std::string> getKeyName();
00261 
00262 
00263         virtual ~CalAmpliTable();
00264         
00270         ASDM &getContainer() const;
00271         
00277         unsigned int size() const;
00278         
00286         std::string getName() const;
00287         
00295         static std::string name() ;     
00296         
00301          std::string getVersion() const ;
00302         
00308          static const std::vector<std::string>& getAttributesNames();
00309 
00315          static const std::vector<std::string>& defaultAttributesNamesInBin();
00316          
00320         Entity getEntity() const;
00321 
00326         void setEntity(Entity e);
00327                 
00335         std::string toXML()  ;
00336 
00337 #ifndef WITHOUT_ACS
00338         // Conversion Methods
00344         asdmIDL::CalAmpliTableIDL *toIDL() ;
00345 #endif
00346 
00347 #ifndef WITHOUT_ACS
00348 
00354         void fromIDL(asdmIDL::CalAmpliTableIDL x) ;
00355 #endif
00356         
00357         //
00358         // ====> Row creation.
00359         //
00360         
00365         CalAmpliRow *newRow();
00366         
00367         
00399         CalAmpliRow *newRow(string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, ReceiverBandMod::ReceiverBand receiverBand, BasebandNameMod::BasebandName basebandName, Tag calDataId, Tag calReductionId, int numReceptor, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, ArrayTime startValidTime, ArrayTime endValidTime, vector<Frequency > frequencyRange, vector<float > apertureEfficiency, vector<float > apertureEfficiencyError);
00400         
00401 
00402 
00415          CalAmpliRow *newRow(CalAmpliRow *row); 
00416 
00417         //
00418         // ====> Append a row to its table.
00419         //
00420  
00421         
00434         CalAmpliRow* add(CalAmpliRow* x) ; 
00435 
00436  
00437 
00438 
00439 
00440         //
00441         // ====> Methods returning rows.
00442         //
00443                 
00449         std::vector<CalAmpliRow *> get() ;
00450         
00457          const std::vector<CalAmpliRow *>& get() const ;
00458         
00459 
00460 
00461  
00462         
00482         CalAmpliRow* getRowByKey(string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, ReceiverBandMod::ReceiverBand receiverBand, BasebandNameMod::BasebandName basebandName, Tag calDataId, Tag calReductionId);
00483 
00484                 
00485 
00486 
00487 
00521         CalAmpliRow* lookup(string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, ReceiverBandMod::ReceiverBand receiverBand, BasebandNameMod::BasebandName basebandName, Tag calDataId, Tag calReductionId, int numReceptor, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, ArrayTime startValidTime, ArrayTime endValidTime, vector<Frequency > frequencyRange, vector<float > apertureEfficiency, vector<float > apertureEfficiencyError); 
00522 
00523 
00524         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00525         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00526 
00527 private:
00528 
00537         CalAmpliTable (ASDM & container);
00538 
00539         ASDM & container;
00540         
00541         bool archiveAsBin; // If true archive binary else archive XML
00542         bool fileAsBin ; // If true file binary else file XML   
00543         
00544         std::string version ; 
00545         
00546         Entity entity;
00547         
00548 
00549 
00553         static std::string itsName;
00554         
00558         static std::vector<std::string> attributesNames;
00559         
00563         static std::vector<std::string> attributesNamesInBin;
00564         
00565 
00569         static bool initAttributesNames(), initAttributesNamesDone ;
00570         
00571 
00575         static std::vector<std::string> key;
00576 
00577 
00585         CalAmpliRow* checkAndAdd(CalAmpliRow* x) ;
00586         
00592          void append(CalAmpliRow* x) ;
00593          
00599          void addWithoutCheckingUnique(CalAmpliRow* x) ;
00600          
00601          
00602 
00603 
00604 
00605 // A data structure to store the pointers on the table's rows.
00606 
00607 // In all cases we maintain a private vector of CalAmpliRow s.
00608    std::vector<CalAmpliRow * > privateRows;
00609    
00610 
00611                         
00612         std::vector<CalAmpliRow *> row;
00613 
00614         
00615         void error() ; //throw(ConversionException);
00616 
00617         
00624         void fromXML(std::string& xmlDoc) ;
00625                 
00626         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00627 
00632         void setFromMIMEFile(const std::string& directory);
00633         /*
00634         void openMIMEFile(const std::string& directory);
00635         */
00636         void setFromXMLFile(const std::string& directory);
00637         
00645         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00646   
00647         
00654          void setFromMIME(const std::string & mimeMsg);
00655         
00659         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00660         
00670           void toFile(std::string directory);
00671           
00675           bool loadInProgress;
00676           void checkPresenceInMemory() {
00677                 if (!presentInMemory && !loadInProgress) {
00678                         loadInProgress = true;
00679                         setFromFile(getContainer().getDirectory());
00680                         presentInMemory = true;
00681                         loadInProgress = false;
00682                 }
00683           }
00692          void setFromFile(const std::string& directory);        
00693  
00694 };
00695 
00696 } // End namespace asdm
00697 
00698 #endif /* CalAmpliTable_CLASS */