WeatherTable.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 WeatherTable_CLASS
00035 #define WeatherTable_CLASS
00036
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040
00041
00042
00043
00044 #include <Angle.h>
00045
00046
00047
00048 #include <Speed.h>
00049
00050
00051
00052 #include <Tag.h>
00053
00054
00055
00056 #include <Length.h>
00057
00058
00059
00060 #include <Temperature.h>
00061
00062
00063
00064 #include <Humidity.h>
00065
00066
00067
00068 #include <ArrayTimeInterval.h>
00069
00070
00071
00072 #include <Pressure.h>
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 #include <ConversionException.h>
00111 #include <DuplicateKey.h>
00112 #include <UniquenessViolationException.h>
00113 #include <NoSuchRow.h>
00114 #include <DuplicateKey.h>
00115
00116
00117 #ifndef WITHOUT_ACS
00118 #include <asdmIDLC.h>
00119 #endif
00120
00121 #include <Representable.h>
00122
00123 #include <pthread.h>
00124
00125 namespace asdm {
00126
00127
00128
00129
00130 class ASDM;
00131 class WeatherRow;
00272 class WeatherTable : public Representable {
00273 friend class ASDM;
00274
00275 public:
00276
00277
00283 static const std::vector<std::string>& getKeyName();
00284
00285
00286 virtual ~WeatherTable();
00287
00293 ASDM &getContainer() const;
00294
00300 unsigned int size() const;
00301
00309 std::string getName() const;
00310
00318 static std::string name() ;
00319
00324 std::string getVersion() const ;
00325
00331 static const std::vector<std::string>& getAttributesNames();
00332
00338 static const std::vector<std::string>& defaultAttributesNamesInBin();
00339
00343 Entity getEntity() const;
00344
00349 void setEntity(Entity e);
00350
00358 std::string toXML() ;
00359
00360 #ifndef WITHOUT_ACS
00361
00367 asdmIDL::WeatherTableIDL *toIDL() ;
00368
00376 void toIDL(asdmIDL::WeatherTableIDL& x) const;
00377
00378 #endif
00379
00380 #ifndef WITHOUT_ACS
00381
00387 void fromIDL(asdmIDL::WeatherTableIDL x) ;
00388 #endif
00389
00390
00391
00392
00393
00398 WeatherRow *newRow();
00399
00400
00410 WeatherRow *newRow(Tag stationId, ArrayTimeInterval timeInterval);
00411
00412
00413
00426 WeatherRow *newRow(WeatherRow *row);
00427
00428
00429
00430
00431
00432
00449 WeatherRow* add(WeatherRow* x) ;
00450
00451
00452
00453
00454
00455
00456
00457
00458
00464 std::vector<WeatherRow *> get() ;
00465
00472 const std::vector<WeatherRow *>& get() const ;
00473
00474
00485 std::vector <WeatherRow*> *getByContext(Tag stationId);
00486
00487
00488
00489
00490
00502 WeatherRow* getRowByKey(Tag stationId, ArrayTimeInterval timeInterval);
00503
00504
00505
00506
00507
00519 WeatherRow* lookup(Tag stationId, ArrayTimeInterval timeInterval);
00520
00521
00522 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00523 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00524
00525 private:
00526
00535 WeatherTable (ASDM & container);
00536
00537 ASDM & container;
00538
00539 bool archiveAsBin;
00540 bool fileAsBin ;
00541
00542 std::string version ;
00543
00544 Entity entity;
00545
00546
00547
00555 WeatherRow* checkAndAdd(WeatherRow* x, bool skipCheckUniqueness=false) ;
00556
00562 void append(WeatherRow* x) ;
00563
00569 void addWithoutCheckingUnique(WeatherRow* x) ;
00570
00571
00572
00573
00574
00575
00583 WeatherRow * insertByStartTime(WeatherRow* x, std::vector<WeatherRow* >& row);
00584
00585
00586
00587
00588
00589
00590 std::vector<WeatherRow * > privateRows;
00591
00592
00593
00594
00595
00596
00597
00598
00599 typedef std::vector <WeatherRow* > TIME_ROWS;
00600 std::map<std::string, TIME_ROWS > context;
00601
00606 std::string Key(Tag stationId) ;
00607
00608
00609
00610
00616 void getByKeyNoAutoIncNoTime(std::vector <WeatherRow*>& vin, std::vector <WeatherRow*>& vout, Tag stationId);
00617
00618
00619
00620 void error() ;
00621
00622
00629 void fromXML(std::string& xmlDoc) ;
00630
00631 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00632
00637 void setFromMIMEFile(const std::string& directory);
00638
00639
00640
00641 void setFromXMLFile(const std::string& directory);
00642
00650 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00651
00652
00659 void setFromMIME(const std::string & mimeMsg);
00660
00664 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00665
00675 void toFile(std::string directory);
00676
00680 bool loadInProgress;
00681 void checkPresenceInMemory() {
00682 if (!presentInMemory && !loadInProgress) {
00683 loadInProgress = true;
00684 setFromFile(getContainer().getDirectory());
00685 presentInMemory = true;
00686 loadInProgress = false;
00687 }
00688 }
00697 void setFromFile(const std::string& directory);
00698
00699 };
00700
00701 }
00702
00703 #endif