SeeingTable.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 SeeingTable_CLASS
00035 #define SeeingTable_CLASS
00036
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040
00041
00042
00043
00044 #include <Angle.h>
00045
00046
00047
00048 #include <Length.h>
00049
00050
00051
00052 #include <ArrayTimeInterval.h>
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #include <ConversionException.h>
00073 #include <DuplicateKey.h>
00074 #include <UniquenessViolationException.h>
00075 #include <NoSuchRow.h>
00076 #include <DuplicateKey.h>
00077
00078
00079 #ifndef WITHOUT_ACS
00080 #include <asdmIDLC.h>
00081 #endif
00082
00083 #include <Representable.h>
00084
00085 #include <pthread.h>
00086
00087 namespace asdm {
00088
00089
00090
00091
00092 class ASDM;
00093 class SeeingRow;
00162 class SeeingTable : public Representable {
00163 friend class ASDM;
00164
00165 public:
00166
00167
00173 static const std::vector<std::string>& getKeyName();
00174
00175
00176 virtual ~SeeingTable();
00177
00183 ASDM &getContainer() const;
00184
00190 unsigned int size() const;
00191
00199 std::string getName() const;
00200
00208 static std::string name() ;
00209
00214 std::string getVersion() const ;
00215
00221 static const std::vector<std::string>& getAttributesNames();
00222
00228 static const std::vector<std::string>& defaultAttributesNamesInBin();
00229
00233 Entity getEntity() const;
00234
00239 void setEntity(Entity e);
00240
00248 std::string toXML() ;
00249
00250 #ifndef WITHOUT_ACS
00251
00257 asdmIDL::SeeingTableIDL *toIDL() ;
00258
00266 void toIDL(asdmIDL::SeeingTableIDL& x) const;
00267
00268 #endif
00269
00270 #ifndef WITHOUT_ACS
00271
00277 void fromIDL(asdmIDL::SeeingTableIDL x) ;
00278 #endif
00279
00280
00281
00282
00283
00288 SeeingRow *newRow();
00289
00290
00308 SeeingRow *newRow(ArrayTimeInterval timeInterval, int numBaseLength, vector<Length > baseLength, vector<Angle > phaseRms, float seeing, float exponent);
00309
00310
00311
00324 SeeingRow *newRow(SeeingRow *row);
00325
00326
00327
00328
00329
00330
00347 SeeingRow* add(SeeingRow* x) ;
00348
00349
00350
00351
00352
00353
00354
00355
00356
00362 std::vector<SeeingRow *> get() ;
00363
00370 const std::vector<SeeingRow *>& get() const ;
00371
00372
00383 std::vector <SeeingRow*> *getByContext();
00384
00385
00386
00387
00388
00398 SeeingRow* getRowByKey(ArrayTimeInterval timeInterval);
00399
00400
00401
00402
00403
00423 SeeingRow* lookup(ArrayTimeInterval timeInterval, int numBaseLength, vector<Length > baseLength, vector<Angle > phaseRms, float seeing, float exponent);
00424
00425
00426 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00427 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00428
00429 private:
00430
00439 SeeingTable (ASDM & container);
00440
00441 ASDM & container;
00442
00443 bool archiveAsBin;
00444 bool fileAsBin ;
00445
00446 std::string version ;
00447
00448 Entity entity;
00449
00450
00451
00459 SeeingRow* checkAndAdd(SeeingRow* x, bool skipCheckUniqueness=false) ;
00460
00466 void append(SeeingRow* x) ;
00467
00473 void addWithoutCheckingUnique(SeeingRow* x) ;
00474
00475
00476
00477
00478
00479
00487 SeeingRow * insertByStartTime(SeeingRow* x, std::vector<SeeingRow* >& row);
00488
00489
00490
00491
00492
00493
00494 std::vector<SeeingRow * > privateRows;
00495
00496
00497
00498
00499
00500
00501
00502
00503 std::vector <SeeingRow *> row;
00504
00505
00506
00507
00508
00509
00510 void error() ;
00511
00512
00519 void fromXML(std::string& xmlDoc) ;
00520
00521 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00522
00527 void setFromMIMEFile(const std::string& directory);
00528
00529
00530
00531 void setFromXMLFile(const std::string& directory);
00532
00540 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00541
00542
00549 void setFromMIME(const std::string & mimeMsg);
00550
00554 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00555
00565 void toFile(std::string directory);
00566
00570 bool loadInProgress;
00571 void checkPresenceInMemory() {
00572 if (!presentInMemory && !loadInProgress) {
00573 loadInProgress = true;
00574 setFromFile(getContainer().getDirectory());
00575 presentInMemory = true;
00576 loadInProgress = false;
00577 }
00578 }
00587 void setFromFile(const std::string& directory);
00588
00589 };
00590
00591 }
00592
00593 #endif