CalDeviceTable.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 CalDeviceTable_CLASS
00035 #define CalDeviceTable_CLASS
00036
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040
00041
00042
00043
00044 #include <Tag.h>
00045
00046
00047
00048 #include <Temperature.h>
00049
00050
00051
00052 #include <ArrayTimeInterval.h>
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #include "CCalibrationDevice.h"
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 #include <ConversionException.h>
00079 #include <DuplicateKey.h>
00080 #include <UniquenessViolationException.h>
00081 #include <NoSuchRow.h>
00082 #include <DuplicateKey.h>
00083
00084
00085 #ifndef WITHOUT_ACS
00086 #include <asdmIDLC.h>
00087 #endif
00088
00089 #include <Representable.h>
00090
00091 #include <pthread.h>
00092
00093 namespace asdm {
00094
00095
00096
00097
00098 class ASDM;
00099 class CalDeviceRow;
00212 class CalDeviceTable : public Representable {
00213 friend class ASDM;
00214
00215 public:
00216
00217
00223 static const std::vector<std::string>& getKeyName();
00224
00225
00226 virtual ~CalDeviceTable();
00227
00233 ASDM &getContainer() const;
00234
00240 unsigned int size() const;
00241
00249 std::string getName() const;
00250
00258 static std::string name() ;
00259
00264 std::string getVersion() const ;
00265
00271 static const std::vector<std::string>& getAttributesNames();
00272
00278 static const std::vector<std::string>& defaultAttributesNamesInBin();
00279
00283 Entity getEntity() const;
00284
00289 void setEntity(Entity e);
00290
00298 std::string toXML() ;
00299
00300 #ifndef WITHOUT_ACS
00301
00307 asdmIDL::CalDeviceTableIDL *toIDL() ;
00308
00316 void toIDL(asdmIDL::CalDeviceTableIDL& x) const;
00317
00318 #endif
00319
00320 #ifndef WITHOUT_ACS
00321
00327 void fromIDL(asdmIDL::CalDeviceTableIDL x) ;
00328 #endif
00329
00330
00331
00332
00333
00338 CalDeviceRow *newRow();
00339
00340
00358 CalDeviceRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numCalload, vector<CalibrationDeviceMod::CalibrationDevice > calLoadNames);
00359
00360
00361
00374 CalDeviceRow *newRow(CalDeviceRow *row);
00375
00376
00377
00378
00379
00380
00397 CalDeviceRow* add(CalDeviceRow* x) ;
00398
00399
00400
00401
00402
00403
00404
00405
00406
00412 std::vector<CalDeviceRow *> get() ;
00413
00420 const std::vector<CalDeviceRow *>& get() const ;
00421
00422
00433 std::vector <CalDeviceRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
00434
00435
00436
00437
00438
00454 CalDeviceRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
00455
00456
00457
00458
00459
00479 CalDeviceRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numCalload, vector<CalibrationDeviceMod::CalibrationDevice > calLoadNames);
00480
00481
00482 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00483 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00484
00485 private:
00486
00495 CalDeviceTable (ASDM & container);
00496
00497 ASDM & container;
00498
00499 bool archiveAsBin;
00500 bool fileAsBin ;
00501
00502 std::string version ;
00503
00504 Entity entity;
00505
00506
00507
00515 CalDeviceRow* checkAndAdd(CalDeviceRow* x, bool skipCheckUniqueness=false) ;
00516
00522 void append(CalDeviceRow* x) ;
00523
00529 void addWithoutCheckingUnique(CalDeviceRow* x) ;
00530
00531
00532
00533
00534
00535
00543 CalDeviceRow * insertByStartTime(CalDeviceRow* x, std::vector<CalDeviceRow* >& row);
00544
00545
00546
00547
00548
00549
00550 std::vector<CalDeviceRow * > privateRows;
00551
00552
00553
00554
00555
00556
00557
00558
00559 typedef std::vector <CalDeviceRow* > TIME_ROWS;
00560 std::map<std::string, TIME_ROWS > context;
00561
00566 std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
00567
00568
00569
00570
00576 void getByKeyNoAutoIncNoTime(std::vector <CalDeviceRow*>& vin, std::vector <CalDeviceRow*>& vout, Tag antennaId, Tag spectralWindowId, int feedId);
00577
00578
00579
00580 void error() ;
00581
00582
00589 void fromXML(std::string& xmlDoc) ;
00590
00591 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00592
00597 void setFromMIMEFile(const std::string& directory);
00598
00599
00600
00601 void setFromXMLFile(const std::string& directory);
00602
00610 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00611
00612
00619 void setFromMIME(const std::string & mimeMsg);
00620
00624 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00625
00635 void toFile(std::string directory);
00636
00640 bool loadInProgress;
00641 void checkPresenceInMemory() {
00642 if (!presentInMemory && !loadInProgress) {
00643 loadInProgress = true;
00644 setFromFile(getContainer().getDirectory());
00645 presentInMemory = true;
00646 loadInProgress = false;
00647 }
00648 }
00657 void setFromFile(const std::string& directory);
00658
00659 };
00660
00661 }
00662
00663 #endif