MainTable.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 MainTable_CLASS
00035 #define MainTable_CLASS
00036
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040
00041
00042
00043
00044 #include <ArrayTime.h>
00045
00046
00047
00048 #include <Interval.h>
00049
00050
00051
00052 #include <Tag.h>
00053
00054
00055
00056 #include <EntityRef.h>
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 #include "CTimeSampling.h"
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 #include <ConversionException.h>
00085 #include <DuplicateKey.h>
00086 #include <UniquenessViolationException.h>
00087 #include <NoSuchRow.h>
00088 #include <DuplicateKey.h>
00089
00090
00091 #ifndef WITHOUT_ACS
00092 #include <asdmIDLC.h>
00093 #endif
00094
00095 #include <Representable.h>
00096
00097 #include <pthread.h>
00098
00099 namespace asdm {
00100
00101
00102
00103
00104 class ASDM;
00105 class MainRow;
00228 class MainTable : public Representable {
00229 friend class ASDM;
00230
00231 public:
00232
00233
00239 static const std::vector<std::string>& getKeyName();
00240
00241
00242 virtual ~MainTable();
00243
00249 ASDM &getContainer() const;
00250
00256 unsigned int size() const;
00257
00265 std::string getName() const;
00266
00274 static std::string name() ;
00275
00280 std::string getVersion() const ;
00281
00287 static const std::vector<std::string>& getAttributesNames();
00288
00294 static const std::vector<std::string>& defaultAttributesNamesInBin();
00295
00299 Entity getEntity() const;
00300
00305 void setEntity(Entity e);
00306
00314 std::string toXML() ;
00315
00316 #ifndef WITHOUT_ACS
00317
00323 asdmIDL::MainTableIDL *toIDL() ;
00324
00332 void toIDL(asdmIDL::MainTableIDL& x) const;
00333
00334 #endif
00335
00336 #ifndef WITHOUT_ACS
00337
00343 void fromIDL(asdmIDL::MainTableIDL x) ;
00344 #endif
00345
00346
00347
00348
00349
00354 MainRow *newRow();
00355
00356
00388 MainRow *newRow(ArrayTime time, Tag configDescriptionId, Tag fieldId, int numAntenna, TimeSamplingMod::TimeSampling timeSampling, Interval interval, int numIntegration, int scanNumber, int subscanNumber, int64_t dataSize, EntityRef dataUID, vector<Tag> stateId, Tag execBlockId);
00389
00390
00391
00404 MainRow *newRow(MainRow *row);
00405
00406
00407
00408
00409
00410
00427 MainRow* add(MainRow* x) ;
00428
00429
00430
00431
00432
00433
00434
00435
00436
00442 std::vector<MainRow *> get() ;
00443
00450 const std::vector<MainRow *>& get() const ;
00451
00452
00463 std::vector <MainRow*> *getByContext(Tag configDescriptionId, Tag fieldId);
00464
00465
00466
00467
00468
00482 MainRow* getRowByKey(ArrayTime time, Tag configDescriptionId, Tag fieldId);
00483
00484
00485
00486
00487
00521 MainRow* lookup(ArrayTime time, Tag configDescriptionId, Tag fieldId, int numAntenna, TimeSamplingMod::TimeSampling timeSampling, Interval interval, int numIntegration, int scanNumber, int subscanNumber, int64_t dataSize, EntityRef dataUID, vector<Tag> stateId, Tag execBlockId);
00522
00523
00524 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00525 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00526
00527 private:
00528
00537 MainTable (ASDM & container);
00538
00539 ASDM & container;
00540
00541 bool archiveAsBin;
00542 bool fileAsBin ;
00543
00544 std::string version ;
00545
00546 Entity entity;
00547
00548
00549
00557 MainRow* checkAndAdd(MainRow* x, bool skipCheckUniqueness=false) ;
00558
00564 void append(MainRow* x) ;
00565
00571 void addWithoutCheckingUnique(MainRow* x) ;
00572
00573
00574
00575
00576
00577
00585 MainRow * insertByTime(MainRow* x, std::vector<MainRow *>&row );
00586
00587
00588
00589
00590
00591
00592 std::vector<MainRow * > privateRows;
00593
00594
00595
00596
00597
00598
00599
00600
00601 typedef std::vector <MainRow* > TIME_ROWS;
00602 std::map<std::string, TIME_ROWS > context;
00603
00608 std::string Key(Tag configDescriptionId, Tag fieldId) ;
00609
00610
00611
00612
00618 void getByKeyNoAutoIncNoTime(std::vector <MainRow*>& vin, std::vector <MainRow*>& vout, Tag configDescriptionId, Tag fieldId);
00619
00620
00621
00622 void error() ;
00623
00624
00631 void fromXML(std::string& xmlDoc) ;
00632
00633 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00634
00639 void setFromMIMEFile(const std::string& directory);
00640
00641
00642
00643 void setFromXMLFile(const std::string& directory);
00644
00652 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00653
00654
00661 void setFromMIME(const std::string & mimeMsg);
00662
00666 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00667
00677 void toFile(std::string directory);
00678
00682 bool loadInProgress;
00683 void checkPresenceInMemory() {
00684 if (!presentInMemory && !loadInProgress) {
00685 loadInProgress = true;
00686 setFromFile(getContainer().getDirectory());
00687 presentInMemory = true;
00688 loadInProgress = false;
00689 }
00690 }
00699 void setFromFile(const std::string& directory);
00700
00701 };
00702
00703 }
00704
00705 #endif