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 FocusTable.h 00032 */ 00033 00034 #ifndef FocusTable_CLASS 00035 #define FocusTable_CLASS 00036 00037 #include <string> 00038 #include <vector> 00039 #include <map> 00040 00041 00042 00043 00044 #include <Angle.h> 00045 00046 00047 00048 #include <Tag.h> 00049 00050 00051 00052 #include <Length.h> 00053 00054 00055 00056 #include <ArrayTimeInterval.h> 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 #include <ConversionException.h> 00077 #include <DuplicateKey.h> 00078 #include <UniquenessViolationException.h> 00079 #include <NoSuchRow.h> 00080 #include <DuplicateKey.h> 00081 00082 00083 #ifndef WITHOUT_ACS 00084 #include <asdmIDLC.h> 00085 #endif 00086 00087 #include <Representable.h> 00088 00089 #include <pthread.h> 00090 00091 namespace asdm { 00092 00093 //class asdm::ASDM; 00094 //class asdm::FocusRow; 00095 00096 class ASDM; 00097 class FocusRow; 00185 class FocusTable : public Representable { 00186 friend class ASDM; 00187 00188 public: 00189 00190 00196 static const std::vector<std::string>& getKeyName(); 00197 00198 00199 virtual ~FocusTable(); 00200 00206 ASDM &getContainer() const; 00207 00213 unsigned int size() const; 00214 00222 std::string getName() const; 00223 00231 static std::string name() ; 00232 00237 std::string getVersion() const ; 00238 00244 static const std::vector<std::string>& getAttributesNames(); 00245 00251 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00252 00256 Entity getEntity() const; 00257 00262 void setEntity(Entity e); 00263 00271 std::string toXML() ; 00272 00273 #ifndef WITHOUT_ACS 00274 // Conversion Methods 00280 asdmIDL::FocusTableIDL *toIDL() ; 00281 00289 void toIDL(asdmIDL::FocusTableIDL& x) const; 00290 00291 #endif 00292 00293 #ifndef WITHOUT_ACS 00294 00300 void fromIDL(asdmIDL::FocusTableIDL x) ; 00301 #endif 00302 00303 // 00304 // ====> Row creation. 00305 // 00306 00311 FocusRow *newRow(); 00312 00313 00331 FocusRow *newRow(Tag antennaId, ArrayTimeInterval timeInterval, bool focusTracking, vector<Length > focusOffset, vector<Angle > focusRotationOffset, int focusModelId); 00332 00333 00334 00347 FocusRow *newRow(FocusRow *row); 00348 00349 // 00350 // ====> Append a row to its table. 00351 // 00352 00353 00370 FocusRow* add(FocusRow* x) ; 00371 00372 00373 00374 00375 00376 // 00377 // ====> Methods returning rows. 00378 // 00379 00385 std::vector<FocusRow *> get() ; 00386 00393 const std::vector<FocusRow *>& get() const ; 00394 00395 00406 std::vector <FocusRow*> *getByContext(Tag antennaId); 00407 00408 00409 00410 00411 00423 FocusRow* getRowByKey(Tag antennaId, ArrayTimeInterval timeInterval); 00424 00425 00426 00427 00428 00448 FocusRow* lookup(Tag antennaId, ArrayTimeInterval timeInterval, bool focusTracking, vector<Length > focusOffset, vector<Angle > focusRotationOffset, int focusModelId); 00449 00450 00451 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00452 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00453 00454 private: 00455 00464 FocusTable (ASDM & container); 00465 00466 ASDM & container; 00467 00468 bool archiveAsBin; // If true archive binary else archive XML 00469 bool fileAsBin ; // If true file binary else file XML 00470 00471 std::string version ; 00472 00473 Entity entity; 00474 00475 00476 00484 FocusRow* checkAndAdd(FocusRow* x, bool skipCheckUniqueness=false) ; 00485 00491 void append(FocusRow* x) ; 00492 00498 void addWithoutCheckingUnique(FocusRow* x) ; 00499 00500 00501 00502 00503 00504 00512 FocusRow * insertByStartTime(FocusRow* x, std::vector<FocusRow* >& row); 00513 00514 00515 00516 // A data structure to store the pointers on the table's rows. 00517 00518 // In all cases we maintain a private vector of FocusRow s. 00519 std::vector<FocusRow * > privateRows; 00520 00521 00522 00523 00524 00525 00526 00527 00528 typedef std::vector <FocusRow* > TIME_ROWS; 00529 std::map<std::string, TIME_ROWS > context; 00530 00535 std::string Key(Tag antennaId) ; 00536 00537 00538 00539 00545 void getByKeyNoAutoIncNoTime(std::vector <FocusRow*>& vin, std::vector <FocusRow*>& vout, Tag antennaId); 00546 00547 00548 00549 void error() ; //throw(ConversionException); 00550 00551 00558 void fromXML(std::string& xmlDoc) ; 00559 00560 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00561 00566 void setFromMIMEFile(const std::string& directory); 00567 /* 00568 void openMIMEFile(const std::string& directory); 00569 */ 00570 void setFromXMLFile(const std::string& directory); 00571 00579 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00580 00581 00588 void setFromMIME(const std::string & mimeMsg); 00589 00593 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00594 00604 void toFile(std::string directory); 00605 00609 bool loadInProgress; 00610 void checkPresenceInMemory() { 00611 if (!presentInMemory && !loadInProgress) { 00612 loadInProgress = true; 00613 setFromFile(getContainer().getDirectory()); 00614 presentInMemory = true; 00615 loadInProgress = false; 00616 } 00617 } 00626 void setFromFile(const std::string& directory); 00627 00628 }; 00629 00630 } // End namespace asdm 00631 00632 #endif /* FocusTable_CLASS */