EphemerisTable.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 EphemerisTable.h
00032  */
00033  
00034 #ifndef EphemerisTable_CLASS
00035 #define EphemerisTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <ArrayTimeInterval.h>
00049         
00050 
00051 
00052 
00053 
00054         
00055 
00056         
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 
00078 
00079 
00080 #include <ConversionException.h>
00081 #include <DuplicateKey.h>
00082 #include <UniquenessViolationException.h>
00083 #include <NoSuchRow.h>
00084 #include <DuplicateKey.h>
00085 
00086 
00087 #ifndef WITHOUT_ACS
00088 #include <asdmIDLC.h>
00089 #endif
00090 
00091 #include <Representable.h>
00092 
00093 #include <pthread.h>
00094 
00095 namespace asdm {
00096 
00097 //class asdm::ASDM;
00098 //class asdm::EphemerisRow;
00099 
00100 class ASDM;
00101 class EphemerisRow;
00239 class EphemerisTable : public Representable {
00240         friend class ASDM;
00241 
00242 public:
00243 
00244 
00250         static const std::vector<std::string>& getKeyName();
00251 
00252 
00253         virtual ~EphemerisTable();
00254         
00260         ASDM &getContainer() const;
00261         
00267         unsigned int size() const;
00268         
00276         std::string getName() const;
00277         
00285         static std::string name() ;     
00286         
00291          std::string getVersion() const ;
00292         
00298          static const std::vector<std::string>& getAttributesNames();
00299 
00305          static const std::vector<std::string>& defaultAttributesNamesInBin();
00306          
00310         Entity getEntity() const;
00311 
00316         void setEntity(Entity e);
00317                 
00325         std::string toXML()  ;
00326 
00327 #ifndef WITHOUT_ACS
00328         // Conversion Methods
00334         asdmIDL::EphemerisTableIDL *toIDL() ;
00335         
00343          void toIDL(asdmIDL::EphemerisTableIDL& x) const;
00344          
00345 #endif
00346 
00347 #ifndef WITHOUT_ACS
00348 
00354         void fromIDL(asdmIDL::EphemerisTableIDL x) ;
00355 #endif
00356         
00357         //
00358         // ====> Row creation.
00359         //
00360         
00365         EphemerisRow *newRow();
00366         
00367         
00393         EphemerisRow *newRow(ArrayTimeInterval timeInterval, int ephemerisId, vector<double > observerLocation, double equinoxEquator, int numPolyDir, vector<vector<double > > dir, int numPolyDist, vector<double > distance, ArrayTime timeOrigin, string origin);
00394         
00395 
00396 
00409          EphemerisRow *newRow(EphemerisRow *row); 
00410 
00411         //
00412         // ====> Append a row to its table.
00413         //
00414  
00415         
00432         EphemerisRow* add(EphemerisRow* x) ; 
00433 
00434  
00435 
00436 
00437 
00438         //
00439         // ====> Methods returning rows.
00440         //
00441                 
00447         std::vector<EphemerisRow *> get() ;
00448         
00455          const std::vector<EphemerisRow *>& get() const ;
00456         
00457 
00468          std::vector <EphemerisRow*> *getByContext(int ephemerisId);
00469          
00470 
00471 
00472  
00473         
00485         EphemerisRow* getRowByKey(ArrayTimeInterval timeInterval, int ephemerisId);
00486 
00487                 
00488 
00489 
00490 
00518         EphemerisRow* lookup(ArrayTimeInterval timeInterval, int ephemerisId, vector<double > observerLocation, double equinoxEquator, int numPolyDir, vector<vector<double > > dir, int numPolyDist, vector<double > distance, ArrayTime timeOrigin, string origin); 
00519 
00520 
00521         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00522         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00523 
00524 private:
00525 
00534         EphemerisTable (ASDM & container);
00535 
00536         ASDM & container;
00537         
00538         bool archiveAsBin; // If true archive binary else archive XML
00539         bool fileAsBin ; // If true file binary else file XML   
00540         
00541         std::string version ; 
00542         
00543         Entity entity;
00544         
00545 
00546 
00554         EphemerisRow* checkAndAdd(EphemerisRow* x, bool skipCheckUniqueness=false) ;
00555         
00561          void append(EphemerisRow* x) ;
00562          
00568          void addWithoutCheckingUnique(EphemerisRow* x) ;
00569          
00570          
00571 
00572 
00573         
00574         
00582          EphemerisRow * insertByStartTime(EphemerisRow* x, std::vector<EphemerisRow* >& row);
00583           
00584 
00585 
00586 // A data structure to store the pointers on the table's rows.
00587 
00588 // In all cases we maintain a private vector of EphemerisRow s.
00589    std::vector<EphemerisRow * > privateRows;
00590    
00591 
00592         
00593 
00594         
00595         
00596                 
00597                                 
00598         typedef std::vector <EphemerisRow* > TIME_ROWS;
00599         std::map<std::string, TIME_ROWS > context;
00600                 
00605          std::string Key(int ephemerisId) ;
00606                  
00607                 
00608         
00609         
00615         void getByKeyNoAutoIncNoTime(std::vector <EphemerisRow*>& vin, std::vector <EphemerisRow*>& vout,  int ephemerisId);
00616         
00617 
00618         
00619         void error() ; //throw(ConversionException);
00620 
00621         
00628         void fromXML(std::string& xmlDoc) ;
00629                 
00630         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00631 
00636         void setFromMIMEFile(const std::string& directory);
00637         /*
00638         void openMIMEFile(const std::string& directory);
00639         */
00640         void setFromXMLFile(const std::string& directory);
00641         
00649         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00650   
00651         
00658          void setFromMIME(const std::string & mimeMsg);
00659         
00663         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00664         
00674           void toFile(std::string directory);
00675           
00679           bool loadInProgress;
00680           void checkPresenceInMemory() {
00681                 if (!presentInMemory && !loadInProgress) {
00682                         loadInProgress = true;
00683                         setFromFile(getContainer().getDirectory());
00684                         presentInMemory = true;
00685                         loadInProgress = false;
00686                 }
00687           }
00696          void setFromFile(const std::string& directory);        
00697  
00698 };
00699 
00700 } // End namespace asdm
00701 
00702 #endif /* EphemerisTable_CLASS */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1