EphemerisTable.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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
00098
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
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
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
00413
00414
00415
00432 EphemerisRow* add(EphemerisRow* x) ;
00433
00434
00435
00436
00437
00438
00439
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;
00539 bool fileAsBin ;
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
00587
00588
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() ;
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
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 }
00701
00702 #endif