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 SeeingTable.h 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 //class asdm::ASDM; 00090 //class asdm::SeeingRow; 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 // Conversion Methods 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 // ====> Row creation. 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 // ====> Append a row to its table. 00328 // 00329 00330 00347 SeeingRow* add(SeeingRow* x) ; 00348 00349 00350 00351 00352 00353 // 00354 // ====> Methods returning rows. 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; // If true archive binary else archive XML 00444 bool fileAsBin ; // If true file binary else file XML 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 // A data structure to store the pointers on the table's rows. 00492 00493 // In all cases we maintain a private vector of SeeingRow s. 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() ; //throw(ConversionException); 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 void openMIMEFile(const std::string& directory); 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 } // End namespace asdm 00592 00593 #endif /* SeeingTable_CLASS */