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 namespace asdm { 00110 00111 //class asdm::ASDM; 00112 //class asdm::CalDataRow; 00113 00114 class ASDM; 00115 class CalDataRow; 00243 class CalDataTable : public Representable { 00244 friend class ASDM; 00245 00246 public: 00247 00248 00254 static std::vector<std::string> getKeyName(); 00255 00256 00257 virtual ~CalDataTable(); 00258 00264 ASDM &getContainer() const; 00265 00271 unsigned int size() const; 00272 00280 std::string getName() const; 00281 00289 static std::string name() ; 00290 00295 std::string getVersion() const ; 00296 00302 static const std::vector<std::string>& getAttributesNames(); 00303 00309 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00310 00314 Entity getEntity() const; 00315 00320 void setEntity(Entity e); 00321 00329 std::string toXML() ; 00330 00331 #ifndef WITHOUT_ACS 00332 // Conversion Methods 00338 asdmIDL::CalDataTableIDL *toIDL() ; 00339 #endif 00340 00341 #ifndef WITHOUT_ACS 00342 00348 void fromIDL(asdmIDL::CalDataTableIDL x) ; 00349 #endif 00350 00351 // 00352 // ====> Row creation. 00353 // 00354 00359 CalDataRow *newRow(); 00360 00361 00381 CalDataRow *newRow(ArrayTime startTimeObserved, ArrayTime endTimeObserved, EntityRef execBlockUID, CalDataOriginMod::CalDataOrigin calDataType, CalTypeMod::CalType calType, int numScan, vector<int > scanSet); 00382 00383 00384 00397 CalDataRow *newRow(CalDataRow *row); 00398 00399 // 00400 // ====> Append a row to its table. 00401 // 00402 00403 00404 00405 00415 CalDataRow* add(CalDataRow* x) ; 00416 00417 00418 00419 // 00420 // ====> Methods returning rows. 00421 // 00422 00428 std::vector<CalDataRow *> get() ; 00429 00436 const std::vector<CalDataRow *>& get() const ; 00437 00438 00439 00440 00441 00451 CalDataRow* getRowByKey(Tag calDataId); 00452 00453 00454 00455 00456 00478 CalDataRow* lookup(ArrayTime startTimeObserved, ArrayTime endTimeObserved, EntityRef execBlockUID, CalDataOriginMod::CalDataOrigin calDataType, CalTypeMod::CalType calType, int numScan, vector<int > scanSet); 00479 00480 00481 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00482 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00483 00484 private: 00485 00494 CalDataTable (ASDM & container); 00495 00496 ASDM & container; 00497 00498 bool archiveAsBin; // If true archive binary else archive XML 00499 bool fileAsBin ; // If true file binary else file XML 00500 00501 std::string version ; 00502 00503 Entity entity; 00504 00505 00506 // A map for the autoincrementation algorithm 00507 std::map<std::string,int> noAutoIncIds; 00508 void autoIncrement(std::string key, CalDataRow* x); 00509 00510 00514 static std::string itsName; 00515 00519 static std::vector<std::string> attributesNames; 00520 00524 static std::vector<std::string> attributesNamesInBin; 00525 00526 00530 static bool initAttributesNames(), initAttributesNamesDone ; 00531 00532 00536 static std::vector<std::string> key; 00537 00538 00548 CalDataRow* checkAndAdd(CalDataRow* x) ; 00549 00555 void append(CalDataRow* x) ; 00556 00562 void addWithoutCheckingUnique(CalDataRow* x) ; 00563 00564 00565 00566 00567 00568 // A data structure to store the pointers on the table's rows. 00569 00570 // In all cases we maintain a private vector of CalDataRow s. 00571 std::vector<CalDataRow * > privateRows; 00572 00573 00574 00575 std::vector<CalDataRow *> row; 00576 00577 00578 void error() ; //throw(ConversionException); 00579 00580 00587 void fromXML(std::string& xmlDoc) ; 00588 00589 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00590 00595 void setFromMIMEFile(const std::string& directory); 00596 /* 00597 void openMIMEFile(const std::string& directory); 00598 */ 00599 void setFromXMLFile(const std::string& directory); 00600 00608 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00609 00610 00617 void setFromMIME(const std::string & mimeMsg); 00618 00622 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00623 00633 void toFile(std::string directory); 00634 00638 bool loadInProgress; 00639 void checkPresenceInMemory() { 00640 if (!presentInMemory && !loadInProgress) { 00641 loadInProgress = true; 00642 setFromFile(getContainer().getDirectory()); 00643 presentInMemory = true; 00644 loadInProgress = false; 00645 } 00646 } 00655 void setFromFile(const std::string& directory); 00656 00657 }; 00658 00659 } // End namespace asdm 00660 00661 #endif /* CalDataTable_CLASS */