SourceTable.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 SourceTable_CLASS
00035 #define SourceTable_CLASS
00036
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040
00041
00042
00043
00044 #include <ArrayTime.h>
00045
00046
00047
00048 #include <AngularRate.h>
00049
00050
00051
00052 #include <Angle.h>
00053
00054
00055
00056 #include <Speed.h>
00057
00058
00059
00060 #include <Flux.h>
00061
00062
00063
00064 #include <Tag.h>
00065
00066
00067
00068 #include <Length.h>
00069
00070
00071
00072 #include <Frequency.h>
00073
00074
00075
00076 #include <ArrayTimeInterval.h>
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 #include "CDirectionReferenceCode.h"
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 #include "CSourceModel.h"
00120
00121
00122
00123 #include "CFrequencyReferenceCode.h"
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 #include "CStokesParameter.h"
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 #include "CRadialVelocityReferenceCode.h"
00152
00153
00154
00155
00156 #include <ConversionException.h>
00157 #include <DuplicateKey.h>
00158 #include <UniquenessViolationException.h>
00159 #include <NoSuchRow.h>
00160 #include <DuplicateKey.h>
00161
00162
00163 #ifndef WITHOUT_ACS
00164 #include <asdmIDLC.h>
00165 #endif
00166
00167 #include <Representable.h>
00168
00169 #include <pthread.h>
00170
00171 namespace asdm {
00172
00173
00174
00175
00176 class ASDM;
00177 class SourceRow;
00435 class SourceTable : public Representable {
00436 friend class ASDM;
00437
00438 public:
00439
00440
00446 static const std::vector<std::string>& getKeyName();
00447
00448
00449 virtual ~SourceTable();
00450
00456 ASDM &getContainer() const;
00457
00463 unsigned int size() const;
00464
00472 std::string getName() const;
00473
00481 static std::string name() ;
00482
00487 std::string getVersion() const ;
00488
00494 static const std::vector<std::string>& getAttributesNames();
00495
00501 static const std::vector<std::string>& defaultAttributesNamesInBin();
00502
00506 Entity getEntity() const;
00507
00512 void setEntity(Entity e);
00513
00521 std::string toXML() ;
00522
00523 #ifndef WITHOUT_ACS
00524
00530 asdmIDL::SourceTableIDL *toIDL() ;
00531
00539 void toIDL(asdmIDL::SourceTableIDL& x) const;
00540
00541 #endif
00542
00543 #ifndef WITHOUT_ACS
00544
00550 void fromIDL(asdmIDL::SourceTableIDL x) ;
00551 #endif
00552
00553
00554
00555
00556
00561 SourceRow *newRow();
00562
00563
00581 SourceRow *newRow(ArrayTimeInterval timeInterval, Tag spectralWindowId, string code, vector<Angle > direction, vector<AngularRate > properMotion, string sourceName);
00582
00583
00584
00597 SourceRow *newRow(SourceRow *row);
00598
00599
00600
00601
00602
00603
00604
00605
00606
00616 SourceRow* add(SourceRow* x) ;
00617
00618
00619
00620
00621
00622
00623
00629 std::vector<SourceRow *> get() ;
00630
00637 const std::vector<SourceRow *>& get() const ;
00638
00639
00640
00641
00642
00656 SourceRow* getRowByKey(int sourceId, ArrayTimeInterval timeInterval, Tag spectralWindowId);
00657
00658
00659
00667 std::vector <SourceRow *> getRowBySourceId(int);
00668
00669
00670
00690 SourceRow* lookup(ArrayTimeInterval timeInterval, Tag spectralWindowId, string code, vector<Angle > direction, vector<AngularRate > properMotion, string sourceName);
00691
00692
00693 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00694 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00695
00696 private:
00697
00706 SourceTable (ASDM & container);
00707
00708 ASDM & container;
00709
00710 bool archiveAsBin;
00711 bool fileAsBin ;
00712
00713 std::string version ;
00714
00715 Entity entity;
00716
00717
00718
00719
00720
00721
00722
00723 std::map<const std::string, int> name2id_m;
00724
00725
00726
00727
00737 SourceRow* checkAndAdd(SourceRow* x, bool skipCheckUniqueness=false) ;
00738
00744 void append(SourceRow* x) ;
00745
00751 void addWithoutCheckingUnique(SourceRow* x) ;
00752
00753
00754
00755
00756
00757
00765 SourceRow * insertByStartTime(SourceRow* x, std::vector<SourceRow* >& row);
00766
00767
00768
00769
00770
00771
00772 std::vector<SourceRow * > privateRows;
00773
00774
00775
00776
00777
00778
00779
00780
00781 typedef std::vector <std::vector <SourceRow* > > ID_TIME_ROWS;
00782 std::map<std::string, ID_TIME_ROWS > context;
00783
00788 std::string Key(Tag spectralWindowId) ;
00789
00790
00791
00792
00798 void getByKeyNoAutoIncNoTime(std::vector <SourceRow*>& vin, std::vector <SourceRow*>& vout, Tag spectralWindowId);
00799
00800
00801
00802 void error() ;
00803
00804
00811 void fromXML(std::string& xmlDoc) ;
00812
00813 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00814
00819 void setFromMIMEFile(const std::string& directory);
00820
00821
00822
00823 void setFromXMLFile(const std::string& directory);
00824
00832 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00833
00834
00841 void setFromMIME(const std::string & mimeMsg);
00842
00846 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00847
00857 void toFile(std::string directory);
00858
00862 bool loadInProgress;
00863 void checkPresenceInMemory() {
00864 if (!presentInMemory && !loadInProgress) {
00865 loadInProgress = true;
00866 setFromFile(getContainer().getDirectory());
00867 presentInMemory = true;
00868 loadInProgress = false;
00869 }
00870 }
00879 void setFromFile(const std::string& directory);
00880
00881 };
00882
00883 }
00884
00885 #endif