casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalSeeingTable.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 CalSeeingTable.h
00032  */
00033  
00034 #ifndef CalSeeingTable_CLASS
00035 #define CalSeeingTable_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 <Interval.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 "CAtmPhaseCorrection.h"
00072         
00073 
00074         
00075 
00076         
00077 
00078         
00079 
00080         
00081 
00082         
00083 
00084         
00085 
00086         
00087 
00088         
00089 
00090         
00091 
00092         
00093 
00094         
00095 
00096         
00097 
00098 
00099 
00100 #include <ConversionException.h>
00101 #include <DuplicateKey.h>
00102 #include <UniquenessViolationException.h>
00103 #include <NoSuchRow.h>
00104 #include <DuplicateKey.h>
00105 
00106 
00107 #ifndef WITHOUT_ACS
00108 #include <asdmIDLC.h>
00109 #endif
00110 
00111 #include <Representable.h>
00112 
00113 #include <pthread.h>
00114 
00115 namespace asdm {
00116 
00117 //class asdm::ASDM;
00118 //class asdm::CalSeeingRow;
00119 
00120 class ASDM;
00121 class CalSeeingRow;
00260 class CalSeeingTable : public Representable {
00261         friend class ASDM;
00262 
00263 public:
00264 
00265 
00271         static const std::vector<std::string>& getKeyName();
00272 
00273 
00274         virtual ~CalSeeingTable();
00275         
00281         ASDM &getContainer() const;
00282         
00288         unsigned int size() const;
00289         
00297         std::string getName() const;
00298         
00306         static std::string name() ;     
00307         
00312          std::string getVersion() const ;
00313         
00319          static const std::vector<std::string>& getAttributesNames();
00320 
00326          static const std::vector<std::string>& defaultAttributesNamesInBin();
00327          
00331         Entity getEntity() const;
00332 
00337         void setEntity(Entity e);
00338                 
00346         std::string toXML()  ;
00347 
00348 #ifndef WITHOUT_ACS
00349         // Conversion Methods
00355         asdmIDL::CalSeeingTableIDL *toIDL() ;
00356         
00364          void toIDL(asdmIDL::CalSeeingTableIDL& x) const;
00365          
00366 #endif
00367 
00368 #ifndef WITHOUT_ACS
00369 
00375         void fromIDL(asdmIDL::CalSeeingTableIDL x) ;
00376 #endif
00377         
00378         //
00379         // ====> Row creation.
00380         //
00381         
00386         CalSeeingRow *newRow();
00387         
00388         
00418         CalSeeingRow *newRow(AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, vector<Frequency > frequencyRange, Interval integrationTime, int numBaseLengths, vector<Length > baselineLengths, vector<Angle > phaseRMS, Angle seeing, Angle seeingError);
00419         
00420 
00421 
00434          CalSeeingRow *newRow(CalSeeingRow *row); 
00435 
00436         //
00437         // ====> Append a row to its table.
00438         //
00439  
00440         
00453         CalSeeingRow* add(CalSeeingRow* x) ; 
00454 
00455  
00456 
00457 
00458 
00459         //
00460         // ====> Methods returning rows.
00461         //
00462                 
00468         std::vector<CalSeeingRow *> get() ;
00469         
00476          const std::vector<CalSeeingRow *>& get() const ;
00477         
00478 
00479 
00480  
00481         
00495         CalSeeingRow* getRowByKey(AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId);
00496 
00497                 
00498 
00499 
00500 
00532         CalSeeingRow* lookup(AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, vector<Frequency > frequencyRange, Interval integrationTime, int numBaseLengths, vector<Length > baselineLengths, vector<Angle > phaseRMS, Angle seeing, Angle seeingError); 
00533 
00534 
00535         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00536         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00537 
00538 private:
00539 
00548         CalSeeingTable (ASDM & container);
00549 
00550         ASDM & container;
00551         
00552         bool archiveAsBin; // If true archive binary else archive XML
00553         bool fileAsBin ; // If true file binary else file XML   
00554         
00555         std::string version ; 
00556         
00557         Entity entity;
00558         
00559 
00560 
00568         CalSeeingRow* checkAndAdd(CalSeeingRow* x, bool skipCheckUniqueness=false) ;
00569         
00575          void append(CalSeeingRow* x) ;
00576          
00582          void addWithoutCheckingUnique(CalSeeingRow* x) ;
00583          
00584          
00585 
00586 
00587 
00588 // A data structure to store the pointers on the table's rows.
00589 
00590 // In all cases we maintain a private vector of CalSeeingRow s.
00591    std::vector<CalSeeingRow * > privateRows;
00592    
00593 
00594                         
00595         std::vector<CalSeeingRow *> row;
00596 
00597         
00598         void error() ; //throw(ConversionException);
00599 
00600         
00607         void fromXML(std::string& xmlDoc) ;
00608                 
00609         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00610 
00615         void setFromMIMEFile(const std::string& directory);
00616         /*
00617         void openMIMEFile(const std::string& directory);
00618         */
00619         void setFromXMLFile(const std::string& directory);
00620         
00628         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00629   
00630         
00637          void setFromMIME(const std::string & mimeMsg);
00638         
00642         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00643         
00653           void toFile(std::string directory);
00654           
00658           bool loadInProgress;
00659           void checkPresenceInMemory() {
00660                 if (!presentInMemory && !loadInProgress) {
00661                         loadInProgress = true;
00662                         setFromFile(getContainer().getDirectory());
00663                         presentInMemory = true;
00664                         loadInProgress = false;
00665                 }
00666           }
00675          void setFromFile(const std::string& directory);        
00676  
00677 };
00678 
00679 } // End namespace asdm
00680 
00681 #endif /* CalSeeingTable_CLASS */