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 AnnotationTable.h 00032 */ 00033 00034 #ifndef AnnotationTable_CLASS 00035 #define AnnotationTable_CLASS 00036 00037 #include <string> 00038 #include <vector> 00039 #include <map> 00040 00041 00042 00043 00044 #include <ArrayTime.h> 00045 00046 00047 00048 #include <Interval.h> 00049 00050 00051 00052 #include <Tag.h> 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 #include "CBasebandName.h" 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 #include <ConversionException.h> 00091 #include <DuplicateKey.h> 00092 #include <UniquenessViolationException.h> 00093 #include <NoSuchRow.h> 00094 #include <DuplicateKey.h> 00095 00096 00097 #ifndef WITHOUT_ACS 00098 #include <asdmIDLC.h> 00099 #endif 00100 00101 #include <Representable.h> 00102 00103 namespace asdm { 00104 00105 //class asdm::ASDM; 00106 //class asdm::AnnotationRow; 00107 00108 class ASDM; 00109 class AnnotationRow; 00244 class AnnotationTable : public Representable { 00245 friend class ASDM; 00246 00247 public: 00248 00249 00255 static std::vector<std::string> getKeyName(); 00256 00257 00258 virtual ~AnnotationTable(); 00259 00265 ASDM &getContainer() const; 00266 00272 unsigned int size() const; 00273 00281 std::string getName() const; 00282 00290 static std::string name() ; 00291 00296 std::string getVersion() const ; 00297 00303 static const std::vector<std::string>& getAttributesNames(); 00304 00310 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00311 00315 Entity getEntity() const; 00316 00321 void setEntity(Entity e); 00322 00330 std::string toXML() ; 00331 00332 #ifndef WITHOUT_ACS 00333 // Conversion Methods 00339 asdmIDL::AnnotationTableIDL *toIDL() ; 00340 #endif 00341 00342 #ifndef WITHOUT_ACS 00343 00349 void fromIDL(asdmIDL::AnnotationTableIDL x) ; 00350 #endif 00351 00352 // 00353 // ====> Row creation. 00354 // 00355 00360 AnnotationRow *newRow(); 00361 00362 00374 AnnotationRow *newRow(ArrayTime time, string issue, string details); 00375 00376 00377 00390 AnnotationRow *newRow(AnnotationRow *row); 00391 00392 // 00393 // ====> Append a row to its table. 00394 // 00395 00396 00397 00398 00408 AnnotationRow* add(AnnotationRow* x) ; 00409 00410 00411 00412 // 00413 // ====> Methods returning rows. 00414 // 00415 00421 std::vector<AnnotationRow *> get() ; 00422 00429 const std::vector<AnnotationRow *>& get() const ; 00430 00431 00432 00433 00434 00444 AnnotationRow* getRowByKey(Tag annotationId); 00445 00446 00447 00448 00449 00463 AnnotationRow* lookup(ArrayTime time, string issue, string details); 00464 00465 00466 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00467 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00468 00469 private: 00470 00479 AnnotationTable (ASDM & container); 00480 00481 ASDM & container; 00482 00483 bool archiveAsBin; // If true archive binary else archive XML 00484 bool fileAsBin ; // If true file binary else file XML 00485 00486 std::string version ; 00487 00488 Entity entity; 00489 00490 00491 // A map for the autoincrementation algorithm 00492 std::map<std::string,int> noAutoIncIds; 00493 void autoIncrement(std::string key, AnnotationRow* x); 00494 00495 00499 static std::string itsName; 00500 00504 static std::vector<std::string> attributesNames; 00505 00509 static std::vector<std::string> attributesNamesInBin; 00510 00511 00515 static bool initAttributesNames(), initAttributesNamesDone ; 00516 00517 00521 static std::vector<std::string> key; 00522 00523 00533 AnnotationRow* checkAndAdd(AnnotationRow* x) ; 00534 00540 void append(AnnotationRow* x) ; 00541 00547 void addWithoutCheckingUnique(AnnotationRow* x) ; 00548 00549 00550 00551 00552 00553 // A data structure to store the pointers on the table's rows. 00554 00555 // In all cases we maintain a private vector of AnnotationRow s. 00556 std::vector<AnnotationRow * > privateRows; 00557 00558 00559 00560 std::vector<AnnotationRow *> row; 00561 00562 00563 void error() ; //throw(ConversionException); 00564 00565 00572 void fromXML(std::string& xmlDoc) ; 00573 00574 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00575 00580 void setFromMIMEFile(const std::string& directory); 00581 /* 00582 void openMIMEFile(const std::string& directory); 00583 */ 00584 void setFromXMLFile(const std::string& directory); 00585 00593 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00594 00595 00602 void setFromMIME(const std::string & mimeMsg); 00603 00607 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00608 00618 void toFile(std::string directory); 00619 00623 bool loadInProgress; 00624 void checkPresenceInMemory() { 00625 if (!presentInMemory && !loadInProgress) { 00626 loadInProgress = true; 00627 setFromFile(getContainer().getDirectory()); 00628 presentInMemory = true; 00629 loadInProgress = false; 00630 } 00631 } 00640 void setFromFile(const std::string& directory); 00641 00642 }; 00643 00644 } // End namespace asdm 00645 00646 #endif /* AnnotationTable_CLASS */