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 #include <pthread.h>
00106 
00107 namespace asdm {
00108 
00109 //class asdm::ASDM;
00110 //class asdm::CalAmpliRow;
00111 
00112 class ASDM;
00113 class CalAmpliRow;
00251 class CalAmpliTable : public Representable {
00252         friend class ASDM;
00253 
00254 public:
00255 
00256 
00262         static const std::vector<std::string>& getKeyName();
00263 
00264 
00265         virtual ~CalAmpliTable();
00266         
00272         ASDM &getContainer() const;
00273         
00279         unsigned int size() const;
00280         
00288         std::string getName() const;
00289         
00297         static std::string name() ;     
00298         
00303          std::string getVersion() const ;
00304         
00310          static const std::vector<std::string>& getAttributesNames();
00311 
00317          static const std::vector<std::string>& defaultAttributesNamesInBin();
00318          
00322         Entity getEntity() const;
00323 
00328         void setEntity(Entity e);
00329                 
00337         std::string toXML()  ;
00338 
00339 #ifndef WITHOUT_ACS
00340         // Conversion Methods
00346         asdmIDL::CalAmpliTableIDL *toIDL() ;
00347         
00355          void toIDL(asdmIDL::CalAmpliTableIDL& x) const;
00356          
00357 #endif
00358 
00359 #ifndef WITHOUT_ACS
00360 
00366         void fromIDL(asdmIDL::CalAmpliTableIDL x) ;
00367 #endif
00368         
00369         //
00370         // ====> Row creation.
00371         //
00372         
00377         CalAmpliRow *newRow();
00378         
00379         
00411         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);
00412         
00413 
00414 
00427          CalAmpliRow *newRow(CalAmpliRow *row); 
00428 
00429         //
00430         // ====> Append a row to its table.
00431         //
00432  
00433         
00446         CalAmpliRow* add(CalAmpliRow* x) ; 
00447 
00448  
00449 
00450 
00451 
00452         //
00453         // ====> Methods returning rows.
00454         //
00455                 
00461         std::vector<CalAmpliRow *> get() ;
00462         
00469          const std::vector<CalAmpliRow *>& get() const ;
00470         
00471 
00472 
00473  
00474         
00494         CalAmpliRow* getRowByKey(string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, ReceiverBandMod::ReceiverBand receiverBand, BasebandNameMod::BasebandName basebandName, Tag calDataId, Tag calReductionId);
00495 
00496                 
00497 
00498 
00499 
00533         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); 
00534 
00535 
00536         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00537         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00538 
00539 private:
00540 
00549         CalAmpliTable (ASDM & container);
00550 
00551         ASDM & container;
00552         
00553         bool archiveAsBin; // If true archive binary else archive XML
00554         bool fileAsBin ; // If true file binary else file XML   
00555         
00556         std::string version ; 
00557         
00558         Entity entity;
00559         
00560 
00561 
00569         CalAmpliRow* checkAndAdd(CalAmpliRow* x, bool skipCheckUniqueness=false) ;
00570         
00576          void append(CalAmpliRow* x) ;
00577          
00583          void addWithoutCheckingUnique(CalAmpliRow* x) ;
00584          
00585          
00586 
00587 
00588 
00589 // A data structure to store the pointers on the table's rows.
00590 
00591 // In all cases we maintain a private vector of CalAmpliRow s.
00592    std::vector<CalAmpliRow * > privateRows;
00593    
00594 
00595                         
00596         std::vector<CalAmpliRow *> row;
00597 
00598         
00599         void error() ; //throw(ConversionException);
00600 
00601         
00608         void fromXML(std::string& xmlDoc) ;
00609                 
00610         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00611 
00616         void setFromMIMEFile(const std::string& directory);
00617         /*
00618         void openMIMEFile(const std::string& directory);
00619         */
00620         void setFromXMLFile(const std::string& directory);
00621         
00629         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00630   
00631         
00638          void setFromMIME(const std::string & mimeMsg);
00639         
00643         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00644         
00654           void toFile(std::string directory);
00655           
00659           bool loadInProgress;
00660           void checkPresenceInMemory() {
00661                 if (!presentInMemory && !loadInProgress) {
00662                         loadInProgress = true;
00663                         setFromFile(getContainer().getDirectory());
00664                         presentInMemory = true;
00665                         loadInProgress = false;
00666                 }
00667           }
00676          void setFromFile(const std::string& directory);        
00677  
00678 };
00679 
00680 } // End namespace asdm
00681 
00682 #endif /* CalAmpliTable_CLASS */