casa
$Rev:20696$
|
00001 00002 /* 00003 * ALMA - Atacama Large Millimeter Array 00004 * (c) European Southern Observatory, 2002 00005 * (c) Associated Universities Inc., 2002 00006 * Copyright by ESO (in the framework of the ALMA collaboration), 00007 * Copyright by AUI (in the framework of the ALMA collaboration), 00008 * All rights reserved. 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY, without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00023 * MA 02111-1307 USA 00024 * 00025 * Warning! 00026 * -------------------------------------------------------------------- 00027 * | This is generated code! Do not modify this file. | 00028 * | If you do, all changes will be lost when the file is re-generated. | 00029 * -------------------------------------------------------------------- 00030 * 00031 * File WeatherTable.h 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 namespace asdm { 00124 00125 //class asdm::ASDM; 00126 //class asdm::WeatherRow; 00127 00128 class ASDM; 00129 class WeatherRow; 00270 class WeatherTable : public Representable { 00271 friend class ASDM; 00272 00273 public: 00274 00275 00281 static std::vector<std::string> getKeyName(); 00282 00283 00284 virtual ~WeatherTable(); 00285 00291 ASDM &getContainer() const; 00292 00298 unsigned int size() const; 00299 00307 std::string getName() const; 00308 00316 static std::string name() ; 00317 00322 std::string getVersion() const ; 00323 00329 static const std::vector<std::string>& getAttributesNames(); 00330 00336 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00337 00341 Entity getEntity() const; 00342 00347 void setEntity(Entity e); 00348 00356 std::string toXML() ; 00357 00358 #ifndef WITHOUT_ACS 00359 // Conversion Methods 00365 asdmIDL::WeatherTableIDL *toIDL() ; 00366 #endif 00367 00368 #ifndef WITHOUT_ACS 00369 00375 void fromIDL(asdmIDL::WeatherTableIDL x) ; 00376 #endif 00377 00378 // 00379 // ====> Row creation. 00380 // 00381 00386 WeatherRow *newRow(); 00387 00388 00398 WeatherRow *newRow(Tag stationId, ArrayTimeInterval timeInterval); 00399 00400 00401 00414 WeatherRow *newRow(WeatherRow *row); 00415 00416 // 00417 // ====> Append a row to its table. 00418 // 00419 00420 00437 WeatherRow* add(WeatherRow* x) ; 00438 00439 00440 00441 00442 00443 // 00444 // ====> Methods returning rows. 00445 // 00446 00452 std::vector<WeatherRow *> get() ; 00453 00460 const std::vector<WeatherRow *>& get() const ; 00461 00462 00473 std::vector <WeatherRow*> *getByContext(Tag stationId); 00474 00475 00476 00477 00478 00490 WeatherRow* getRowByKey(Tag stationId, ArrayTimeInterval timeInterval); 00491 00492 00493 00494 00495 00507 WeatherRow* lookup(Tag stationId, ArrayTimeInterval timeInterval); 00508 00509 00510 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00511 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00512 00513 private: 00514 00523 WeatherTable (ASDM & container); 00524 00525 ASDM & container; 00526 00527 bool archiveAsBin; // If true archive binary else archive XML 00528 bool fileAsBin ; // If true file binary else file XML 00529 00530 std::string version ; 00531 00532 Entity entity; 00533 00534 00535 00539 static std::string itsName; 00540 00544 static std::vector<std::string> attributesNames; 00545 00549 static std::vector<std::string> attributesNamesInBin; 00550 00551 00555 static bool initAttributesNames(), initAttributesNamesDone ; 00556 00557 00561 static std::vector<std::string> key; 00562 00563 00571 WeatherRow* checkAndAdd(WeatherRow* x) ; 00572 00578 void append(WeatherRow* x) ; 00579 00585 void addWithoutCheckingUnique(WeatherRow* x) ; 00586 00587 00588 00589 00590 00591 00599 WeatherRow * insertByStartTime(WeatherRow* x, std::vector<WeatherRow* >& row); 00600 00601 00602 00603 // A data structure to store the pointers on the table's rows. 00604 00605 // In all cases we maintain a private vector of WeatherRow s. 00606 std::vector<WeatherRow * > privateRows; 00607 00608 00609 00610 00611 00612 00613 00614 00615 typedef std::vector <WeatherRow* > TIME_ROWS; 00616 std::map<std::string, TIME_ROWS > context; 00617 00622 std::string Key(Tag stationId) ; 00623 00624 00625 00626 00632 void getByKeyNoAutoIncNoTime(std::vector <WeatherRow*>& vin, std::vector <WeatherRow*>& vout, Tag stationId); 00633 00634 00635 00636 void error() ; //throw(ConversionException); 00637 00638 00645 void fromXML(std::string& xmlDoc) ; 00646 00647 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00648 00653 void setFromMIMEFile(const std::string& directory); 00654 /* 00655 void openMIMEFile(const std::string& directory); 00656 */ 00657 void setFromXMLFile(const std::string& directory); 00658 00666 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00667 00668 00675 void setFromMIME(const std::string & mimeMsg); 00676 00680 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00681 00691 void toFile(std::string directory); 00692 00696 bool loadInProgress; 00697 void checkPresenceInMemory() { 00698 if (!presentInMemory && !loadInProgress) { 00699 loadInProgress = true; 00700 setFromFile(getContainer().getDirectory()); 00701 presentInMemory = true; 00702 loadInProgress = false; 00703 } 00704 } 00713 void setFromFile(const std::string& directory); 00714 00715 }; 00716 00717 } // End namespace asdm 00718 00719 #endif /* WeatherTable_CLASS */