casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalPositionTable.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 CalPositionTable.h
00032  */
00033  
00034 #ifndef CalPositionTable_CLASS
00035 #define CalPositionTable_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 <Length.h>
00057         
00058 
00059 
00060 
00061 
00062         
00063 
00064         
00065 #include "CAtmPhaseCorrection.h"
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 
00078         
00079 #include "CPositionMethod.h"
00080         
00081 
00082         
00083 #include "CReceiverBand.h"
00084         
00085 
00086         
00087 
00088         
00089 
00090         
00091 
00092         
00093 
00094         
00095 
00096         
00097 
00098         
00099 
00100         
00101 
00102         
00103 
00104         
00105 
00106 
00107 
00108 #include <ConversionException.h>
00109 #include <DuplicateKey.h>
00110 #include <UniquenessViolationException.h>
00111 #include <NoSuchRow.h>
00112 #include <DuplicateKey.h>
00113 
00114 
00115 #ifndef WITHOUT_ACS
00116 #include <asdmIDLC.h>
00117 #endif
00118 
00119 #include <Representable.h>
00120 
00121 #include <pthread.h>
00122 
00123 namespace asdm {
00124 
00125 //class asdm::ASDM;
00126 //class asdm::CalPositionRow;
00127 
00128 class ASDM;
00129 class CalPositionRow;
00312 class CalPositionTable : public Representable {
00313         friend class ASDM;
00314 
00315 public:
00316 
00317 
00323         static const std::vector<std::string>& getKeyName();
00324 
00325 
00326         virtual ~CalPositionTable();
00327         
00333         ASDM &getContainer() const;
00334         
00340         unsigned int size() const;
00341         
00349         std::string getName() const;
00350         
00358         static std::string name() ;     
00359         
00364          std::string getVersion() const ;
00365         
00371          static const std::vector<std::string>& getAttributesNames();
00372 
00378          static const std::vector<std::string>& defaultAttributesNamesInBin();
00379          
00383         Entity getEntity() const;
00384 
00389         void setEntity(Entity e);
00390                 
00398         std::string toXML()  ;
00399 
00400 #ifndef WITHOUT_ACS
00401         // Conversion Methods
00407         asdmIDL::CalPositionTableIDL *toIDL() ;
00408         
00416          void toIDL(asdmIDL::CalPositionTableIDL& x) const;
00417          
00418 #endif
00419 
00420 #ifndef WITHOUT_ACS
00421 
00427         void fromIDL(asdmIDL::CalPositionTableIDL x) ;
00428 #endif
00429         
00430         //
00431         // ====> Row creation.
00432         //
00433         
00438         CalPositionRow *newRow();
00439         
00440         
00484         CalPositionRow *newRow(string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, vector<Length > antennaPosition, string stationName, vector<Length > stationPosition, PositionMethodMod::PositionMethod positionMethod, ReceiverBandMod::ReceiverBand receiverBand, int numAntenna, vector<string > refAntennaNames, Length axesOffset, Length axesOffsetErr, bool axesOffsetFixed, vector<Length > positionOffset, vector<Length > positionErr, double reducedChiSquared);
00485         
00486 
00487 
00500          CalPositionRow *newRow(CalPositionRow *row); 
00501 
00502         //
00503         // ====> Append a row to its table.
00504         //
00505  
00506         
00519         CalPositionRow* add(CalPositionRow* x) ; 
00520 
00521  
00522 
00523 
00524 
00525         //
00526         // ====> Methods returning rows.
00527         //
00528                 
00534         std::vector<CalPositionRow *> get() ;
00535         
00542          const std::vector<CalPositionRow *>& get() const ;
00543         
00544 
00545 
00546  
00547         
00563         CalPositionRow* getRowByKey(string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId);
00564 
00565                 
00566 
00567 
00568 
00614         CalPositionRow* lookup(string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, vector<Length > antennaPosition, string stationName, vector<Length > stationPosition, PositionMethodMod::PositionMethod positionMethod, ReceiverBandMod::ReceiverBand receiverBand, int numAntenna, vector<string > refAntennaNames, Length axesOffset, Length axesOffsetErr, bool axesOffsetFixed, vector<Length > positionOffset, vector<Length > positionErr, double reducedChiSquared); 
00615 
00616 
00617         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00618         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00619 
00620 private:
00621 
00630         CalPositionTable (ASDM & container);
00631 
00632         ASDM & container;
00633         
00634         bool archiveAsBin; // If true archive binary else archive XML
00635         bool fileAsBin ; // If true file binary else file XML   
00636         
00637         std::string version ; 
00638         
00639         Entity entity;
00640         
00641 
00642 
00650         CalPositionRow* checkAndAdd(CalPositionRow* x, bool skipCheckUniqueness=false) ;
00651         
00657          void append(CalPositionRow* x) ;
00658          
00664          void addWithoutCheckingUnique(CalPositionRow* x) ;
00665          
00666          
00667 
00668 
00669 
00670 // A data structure to store the pointers on the table's rows.
00671 
00672 // In all cases we maintain a private vector of CalPositionRow s.
00673    std::vector<CalPositionRow * > privateRows;
00674    
00675 
00676                         
00677         std::vector<CalPositionRow *> row;
00678 
00679         
00680         void error() ; //throw(ConversionException);
00681 
00682         
00689         void fromXML(std::string& xmlDoc) ;
00690                 
00691         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00692 
00697         void setFromMIMEFile(const std::string& directory);
00698         /*
00699         void openMIMEFile(const std::string& directory);
00700         */
00701         void setFromXMLFile(const std::string& directory);
00702         
00710         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00711   
00712         
00719          void setFromMIME(const std::string & mimeMsg);
00720         
00724         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00725         
00735           void toFile(std::string directory);
00736           
00740           bool loadInProgress;
00741           void checkPresenceInMemory() {
00742                 if (!presentInMemory && !loadInProgress) {
00743                         loadInProgress = true;
00744                         setFromFile(getContainer().getDirectory());
00745                         presentInMemory = true;
00746                         loadInProgress = false;
00747                 }
00748           }
00757          void setFromFile(const std::string& directory);        
00758  
00759 };
00760 
00761 } // End namespace asdm
00762 
00763 #endif /* CalPositionTable_CLASS */