casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalPhaseTable.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 CalPhaseTable.h
00032  */
00033  
00034 #ifndef CalPhaseTable_CLASS
00035 #define CalPhaseTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <Interval.h>
00049         
00050 
00051         
00052 #include <Angle.h>
00053         
00054 
00055         
00056 #include <Tag.h>
00057         
00058 
00059         
00060 #include <Length.h>
00061         
00062 
00063         
00064 #include <Frequency.h>
00065         
00066 
00067 
00068 
00069 
00070         
00071 #include "CBasebandName.h"
00072         
00073 
00074         
00075 #include "CReceiverBand.h"
00076         
00077 
00078         
00079 #include "CAtmPhaseCorrection.h"
00080         
00081 
00082         
00083 
00084         
00085 
00086         
00087 
00088         
00089 
00090         
00091 
00092         
00093 
00094         
00095 
00096         
00097 
00098         
00099 
00100         
00101 
00102         
00103 
00104         
00105 
00106         
00107 #include "CPolarizationType.h"
00108         
00109 
00110         
00111 
00112         
00113 
00114         
00115 
00116 
00117 
00118 #include <ConversionException.h>
00119 #include <DuplicateKey.h>
00120 #include <UniquenessViolationException.h>
00121 #include <NoSuchRow.h>
00122 #include <DuplicateKey.h>
00123 
00124 
00125 #ifndef WITHOUT_ACS
00126 #include <asdmIDLC.h>
00127 #endif
00128 
00129 #include <Representable.h>
00130 
00131 #include <pthread.h>
00132 
00133 namespace asdm {
00134 
00135 //class asdm::ASDM;
00136 //class asdm::CalPhaseRow;
00137 
00138 class ASDM;
00139 class CalPhaseRow;
00324 class CalPhaseTable : public Representable {
00325         friend class ASDM;
00326 
00327 public:
00328 
00329 
00335         static const std::vector<std::string>& getKeyName();
00336 
00337 
00338         virtual ~CalPhaseTable();
00339         
00345         ASDM &getContainer() const;
00346         
00352         unsigned int size() const;
00353         
00361         std::string getName() const;
00362         
00370         static std::string name() ;     
00371         
00376          std::string getVersion() const ;
00377         
00383          static const std::vector<std::string>& getAttributesNames();
00384 
00390          static const std::vector<std::string>& defaultAttributesNamesInBin();
00391          
00395         Entity getEntity() const;
00396 
00401         void setEntity(Entity e);
00402                 
00410         std::string toXML()  ;
00411 
00412 #ifndef WITHOUT_ACS
00413         // Conversion Methods
00419         asdmIDL::CalPhaseTableIDL *toIDL() ;
00420         
00428          void toIDL(asdmIDL::CalPhaseTableIDL& x) const;
00429          
00430 #endif
00431 
00432 #ifndef WITHOUT_ACS
00433 
00439         void fromIDL(asdmIDL::CalPhaseTableIDL x) ;
00440 #endif
00441         
00442         //
00443         // ====> Row creation.
00444         //
00445         
00450         CalPhaseRow *newRow();
00451         
00452         
00498         CalPhaseRow *newRow(BasebandNameMod::BasebandName basebandName, ReceiverBandMod::ReceiverBand receiverBand, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, int numBaseline, int numReceptor, vector<vector<float > > ampli, vector<vector<string > > antennaNames, vector<Length > baselineLengths, vector<vector<float > > decorrelationFactor, vector<Angle > direction, vector<Frequency > frequencyRange, Interval integrationTime, vector<vector<float > > phase, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, vector<vector<float > > phaseRMS, vector<vector<float > > statPhaseRMS);
00499         
00500 
00501 
00514          CalPhaseRow *newRow(CalPhaseRow *row); 
00515 
00516         //
00517         // ====> Append a row to its table.
00518         //
00519  
00520         
00533         CalPhaseRow* add(CalPhaseRow* x) ; 
00534 
00535  
00536 
00537 
00538 
00539         //
00540         // ====> Methods returning rows.
00541         //
00542                 
00548         std::vector<CalPhaseRow *> get() ;
00549         
00556          const std::vector<CalPhaseRow *>& get() const ;
00557         
00558 
00559 
00560  
00561         
00579         CalPhaseRow* getRowByKey(BasebandNameMod::BasebandName basebandName, ReceiverBandMod::ReceiverBand receiverBand, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId);
00580 
00581                 
00582 
00583 
00584 
00632         CalPhaseRow* lookup(BasebandNameMod::BasebandName basebandName, ReceiverBandMod::ReceiverBand receiverBand, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, int numBaseline, int numReceptor, vector<vector<float > > ampli, vector<vector<string > > antennaNames, vector<Length > baselineLengths, vector<vector<float > > decorrelationFactor, vector<Angle > direction, vector<Frequency > frequencyRange, Interval integrationTime, vector<vector<float > > phase, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, vector<vector<float > > phaseRMS, vector<vector<float > > statPhaseRMS); 
00633 
00634 
00635         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00636         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00637 
00638 private:
00639 
00648         CalPhaseTable (ASDM & container);
00649 
00650         ASDM & container;
00651         
00652         bool archiveAsBin; // If true archive binary else archive XML
00653         bool fileAsBin ; // If true file binary else file XML   
00654         
00655         std::string version ; 
00656         
00657         Entity entity;
00658         
00659 
00660 
00668         CalPhaseRow* checkAndAdd(CalPhaseRow* x, bool skipCheckUniqueness=false) ;
00669         
00675          void append(CalPhaseRow* x) ;
00676          
00682          void addWithoutCheckingUnique(CalPhaseRow* x) ;
00683          
00684          
00685 
00686 
00687 
00688 // A data structure to store the pointers on the table's rows.
00689 
00690 // In all cases we maintain a private vector of CalPhaseRow s.
00691    std::vector<CalPhaseRow * > privateRows;
00692    
00693 
00694                         
00695         std::vector<CalPhaseRow *> row;
00696 
00697         
00698         void error() ; //throw(ConversionException);
00699 
00700         
00707         void fromXML(std::string& xmlDoc) ;
00708                 
00709         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00710 
00715         void setFromMIMEFile(const std::string& directory);
00716         /*
00717         void openMIMEFile(const std::string& directory);
00718         */
00719         void setFromXMLFile(const std::string& directory);
00720         
00728         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00729   
00730         
00737          void setFromMIME(const std::string & mimeMsg);
00738         
00742         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00743         
00753           void toFile(std::string directory);
00754           
00758           bool loadInProgress;
00759           void checkPresenceInMemory() {
00760                 if (!presentInMemory && !loadInProgress) {
00761                         loadInProgress = true;
00762                         setFromFile(getContainer().getDirectory());
00763                         presentInMemory = true;
00764                         loadInProgress = false;
00765                 }
00766           }
00775          void setFromFile(const std::string& directory);        
00776  
00777 };
00778 
00779 } // End namespace asdm
00780 
00781 #endif /* CalPhaseTable_CLASS */