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 CalDataTable.h 00032 */ 00033 00034 #ifndef CalDataTable_CLASS 00035 #define CalDataTable_CLASS 00036 00037 #include <string> 00038 #include <vector> 00039 #include <map> 00040 00041 00042 00043 00044 #include <ArrayTime.h> 00045 00046 00047 00048 #include <Tag.h> 00049 00050 00051 00052 #include <EntityRef.h> 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 #include "CCalDataOrigin.h" 00068 00069 00070 00071 #include "CCalType.h" 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 #include "CAssociatedCalNature.h" 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 #include "CScanIntent.h" 00092 00093 00094 00095 00096 #include <ConversionException.h> 00097 #include <DuplicateKey.h> 00098 #include <UniquenessViolationException.h> 00099 #include <NoSuchRow.h> 00100 #include <DuplicateKey.h> 00101 00102 00103 #ifndef WITHOUT_ACS 00104 #include <asdmIDLC.h> 00105 #endif 00106 00107 #include <Representable.h> 00108 00109 #include <pthread.h> 00110 00111 namespace asdm { 00112 00113 //class asdm::ASDM; 00114 //class asdm::CalDataRow; 00115 00116 class ASDM; 00117 class CalDataRow; 00245 class CalDataTable : public Representable { 00246 friend class ASDM; 00247 00248 public: 00249 00250 00256 static const std::vector<std::string>& getKeyName(); 00257 00258 00259 virtual ~CalDataTable(); 00260 00266 ASDM &getContainer() const; 00267 00273 unsigned int size() const; 00274 00282 std::string getName() const; 00283 00291 static std::string name() ; 00292 00297 std::string getVersion() const ; 00298 00304 static const std::vector<std::string>& getAttributesNames(); 00305 00311 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00312 00316 Entity getEntity() const; 00317 00322 void setEntity(Entity e); 00323 00331 std::string toXML() ; 00332 00333 #ifndef WITHOUT_ACS 00334 // Conversion Methods 00340 asdmIDL::CalDataTableIDL *toIDL() ; 00341 00349 void toIDL(asdmIDL::CalDataTableIDL& x) const; 00350 00351 #endif 00352 00353 #ifndef WITHOUT_ACS 00354 00360 void fromIDL(asdmIDL::CalDataTableIDL x) ; 00361 #endif 00362 00363 // 00364 // ====> Row creation. 00365 // 00366 00371 CalDataRow *newRow(); 00372 00373 00393 CalDataRow *newRow(ArrayTime startTimeObserved, ArrayTime endTimeObserved, EntityRef execBlockUID, CalDataOriginMod::CalDataOrigin calDataType, CalTypeMod::CalType calType, int numScan, vector<int > scanSet); 00394 00395 00396 00409 CalDataRow *newRow(CalDataRow *row); 00410 00411 // 00412 // ====> Append a row to its table. 00413 // 00414 00415 00416 00417 00427 CalDataRow* add(CalDataRow* x) ; 00428 00429 00430 00431 // 00432 // ====> Methods returning rows. 00433 // 00434 00440 std::vector<CalDataRow *> get() ; 00441 00448 const std::vector<CalDataRow *>& get() const ; 00449 00450 00451 00452 00453 00463 CalDataRow* getRowByKey(Tag calDataId); 00464 00465 00466 00467 00468 00490 CalDataRow* lookup(ArrayTime startTimeObserved, ArrayTime endTimeObserved, EntityRef execBlockUID, CalDataOriginMod::CalDataOrigin calDataType, CalTypeMod::CalType calType, int numScan, vector<int > scanSet); 00491 00492 00493 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00494 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00495 00496 private: 00497 00506 CalDataTable (ASDM & container); 00507 00508 ASDM & container; 00509 00510 bool archiveAsBin; // If true archive binary else archive XML 00511 bool fileAsBin ; // If true file binary else file XML 00512 00513 std::string version ; 00514 00515 Entity entity; 00516 00517 00518 // A map for the autoincrementation algorithm 00519 std::map<std::string,int> noAutoIncIds; 00520 void autoIncrement(std::string key, CalDataRow* x); 00521 00522 00532 CalDataRow* checkAndAdd(CalDataRow* x, bool skipCheckUniqueness=false) ; 00533 00539 void append(CalDataRow* x) ; 00540 00546 void addWithoutCheckingUnique(CalDataRow* x) ; 00547 00548 00549 00550 00551 00552 // A data structure to store the pointers on the table's rows. 00553 00554 // In all cases we maintain a private vector of CalDataRow s. 00555 std::vector<CalDataRow * > privateRows; 00556 00557 00558 00559 std::vector<CalDataRow *> row; 00560 00561 00562 void error() ; //throw(ConversionException); 00563 00564 00571 void fromXML(std::string& xmlDoc) ; 00572 00573 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00574 00579 void setFromMIMEFile(const std::string& directory); 00580 /* 00581 void openMIMEFile(const std::string& directory); 00582 */ 00583 void setFromXMLFile(const std::string& directory); 00584 00592 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00593 00594 00601 void setFromMIME(const std::string & mimeMsg); 00602 00606 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00607 00617 void toFile(std::string directory); 00618 00622 bool loadInProgress; 00623 void checkPresenceInMemory() { 00624 if (!presentInMemory && !loadInProgress) { 00625 loadInProgress = true; 00626 setFromFile(getContainer().getDirectory()); 00627 presentInMemory = true; 00628 loadInProgress = false; 00629 } 00630 } 00639 void setFromFile(const std::string& directory); 00640 00641 }; 00642 00643 } // End namespace asdm 00644 00645 #endif /* CalDataTable_CLASS */