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 namespace asdm {
00122 
00123 //class asdm::ASDM;
00124 //class asdm::CalPositionRow;
00125 
00126 class ASDM;
00127 class CalPositionRow;
00310 class CalPositionTable : public Representable {
00311         friend class ASDM;
00312 
00313 public:
00314 
00315 
00321         static std::vector<std::string> getKeyName();
00322 
00323 
00324         virtual ~CalPositionTable();
00325         
00331         ASDM &getContainer() const;
00332         
00338         unsigned int size() const;
00339         
00347         std::string getName() const;
00348         
00356         static std::string name() ;     
00357         
00362          std::string getVersion() const ;
00363         
00369          static const std::vector<std::string>& getAttributesNames();
00370 
00376          static const std::vector<std::string>& defaultAttributesNamesInBin();
00377          
00381         Entity getEntity() const;
00382 
00387         void setEntity(Entity e);
00388                 
00396         std::string toXML()  ;
00397 
00398 #ifndef WITHOUT_ACS
00399         // Conversion Methods
00405         asdmIDL::CalPositionTableIDL *toIDL() ;
00406 #endif
00407 
00408 #ifndef WITHOUT_ACS
00409 
00415         void fromIDL(asdmIDL::CalPositionTableIDL x) ;
00416 #endif
00417         
00418         //
00419         // ====> Row creation.
00420         //
00421         
00426         CalPositionRow *newRow();
00427         
00428         
00472         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);
00473         
00474 
00475 
00488          CalPositionRow *newRow(CalPositionRow *row); 
00489 
00490         //
00491         // ====> Append a row to its table.
00492         //
00493  
00494         
00507         CalPositionRow* add(CalPositionRow* x) ; 
00508 
00509  
00510 
00511 
00512 
00513         //
00514         // ====> Methods returning rows.
00515         //
00516                 
00522         std::vector<CalPositionRow *> get() ;
00523         
00530          const std::vector<CalPositionRow *>& get() const ;
00531         
00532 
00533 
00534  
00535         
00551         CalPositionRow* getRowByKey(string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId);
00552 
00553                 
00554 
00555 
00556 
00602         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); 
00603 
00604 
00605         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00606         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00607 
00608 private:
00609 
00618         CalPositionTable (ASDM & container);
00619 
00620         ASDM & container;
00621         
00622         bool archiveAsBin; // If true archive binary else archive XML
00623         bool fileAsBin ; // If true file binary else file XML   
00624         
00625         std::string version ; 
00626         
00627         Entity entity;
00628         
00629 
00630 
00634         static std::string itsName;
00635         
00639         static std::vector<std::string> attributesNames;
00640         
00644         static std::vector<std::string> attributesNamesInBin;
00645         
00646 
00650         static bool initAttributesNames(), initAttributesNamesDone ;
00651         
00652 
00656         static std::vector<std::string> key;
00657 
00658 
00666         CalPositionRow* checkAndAdd(CalPositionRow* x) ;
00667         
00673          void append(CalPositionRow* x) ;
00674          
00680          void addWithoutCheckingUnique(CalPositionRow* x) ;
00681          
00682          
00683 
00684 
00685 
00686 // A data structure to store the pointers on the table's rows.
00687 
00688 // In all cases we maintain a private vector of CalPositionRow s.
00689    std::vector<CalPositionRow * > privateRows;
00690    
00691 
00692                         
00693         std::vector<CalPositionRow *> row;
00694 
00695         
00696         void error() ; //throw(ConversionException);
00697 
00698         
00705         void fromXML(std::string& xmlDoc) ;
00706                 
00707         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00708 
00713         void setFromMIMEFile(const std::string& directory);
00714         /*
00715         void openMIMEFile(const std::string& directory);
00716         */
00717         void setFromXMLFile(const std::string& directory);
00718         
00726         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00727   
00728         
00735          void setFromMIME(const std::string & mimeMsg);
00736         
00740         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00741         
00751           void toFile(std::string directory);
00752           
00756           bool loadInProgress;
00757           void checkPresenceInMemory() {
00758                 if (!presentInMemory && !loadInProgress) {
00759                         loadInProgress = true;
00760                         setFromFile(getContainer().getDirectory());
00761                         presentInMemory = true;
00762                         loadInProgress = false;
00763                 }
00764           }
00773          void setFromFile(const std::string& directory);        
00774  
00775 };
00776 
00777 } // End namespace asdm
00778 
00779 #endif /* CalPositionTable_CLASS */