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 FlagTable.h 00032 */ 00033 00034 #ifndef FlagTable_CLASS 00035 #define FlagTable_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 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 #include "CPolarizationType.h" 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 namespace asdm { 00090 00091 //class asdm::ASDM; 00092 //class asdm::FlagRow; 00093 00094 class ASDM; 00095 class FlagRow; 00209 class FlagTable : public Representable { 00210 friend class ASDM; 00211 00212 public: 00213 00214 00220 static std::vector<std::string> getKeyName(); 00221 00222 00223 virtual ~FlagTable(); 00224 00230 ASDM &getContainer() const; 00231 00237 unsigned int size() const; 00238 00246 std::string getName() const; 00247 00255 static std::string name() ; 00256 00261 std::string getVersion() const ; 00262 00268 static const std::vector<std::string>& getAttributesNames(); 00269 00275 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00276 00280 Entity getEntity() const; 00281 00286 void setEntity(Entity e); 00287 00295 std::string toXML() ; 00296 00297 #ifndef WITHOUT_ACS 00298 // Conversion Methods 00304 asdmIDL::FlagTableIDL *toIDL() ; 00305 #endif 00306 00307 #ifndef WITHOUT_ACS 00308 00314 void fromIDL(asdmIDL::FlagTableIDL x) ; 00315 #endif 00316 00317 // 00318 // ====> Row creation. 00319 // 00320 00325 FlagRow *newRow(); 00326 00327 00343 FlagRow *newRow(ArrayTime startTime, ArrayTime endTime, string reason, int numAntenna, vector<Tag> antennaId); 00344 00345 00346 00359 FlagRow *newRow(FlagRow *row); 00360 00361 // 00362 // ====> Append a row to its table. 00363 // 00364 00365 00366 00367 00377 FlagRow* add(FlagRow* x) ; 00378 00379 00380 00381 // 00382 // ====> Methods returning rows. 00383 // 00384 00390 std::vector<FlagRow *> get() ; 00391 00398 const std::vector<FlagRow *>& get() const ; 00399 00400 00401 00402 00403 00413 FlagRow* getRowByKey(Tag flagId); 00414 00415 00416 00417 00418 00436 FlagRow* lookup(ArrayTime startTime, ArrayTime endTime, string reason, int numAntenna, vector<Tag> antennaId); 00437 00438 00439 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00440 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00441 00442 private: 00443 00452 FlagTable (ASDM & container); 00453 00454 ASDM & container; 00455 00456 bool archiveAsBin; // If true archive binary else archive XML 00457 bool fileAsBin ; // If true file binary else file XML 00458 00459 std::string version ; 00460 00461 Entity entity; 00462 00463 00464 // A map for the autoincrementation algorithm 00465 std::map<std::string,int> noAutoIncIds; 00466 void autoIncrement(std::string key, FlagRow* x); 00467 00468 00472 static std::string itsName; 00473 00477 static std::vector<std::string> attributesNames; 00478 00482 static std::vector<std::string> attributesNamesInBin; 00483 00484 00488 static bool initAttributesNames(), initAttributesNamesDone ; 00489 00490 00494 static std::vector<std::string> key; 00495 00496 00506 FlagRow* checkAndAdd(FlagRow* x) ; 00507 00513 void append(FlagRow* x) ; 00514 00520 void addWithoutCheckingUnique(FlagRow* x) ; 00521 00522 00523 00524 00525 00526 // A data structure to store the pointers on the table's rows. 00527 00528 // In all cases we maintain a private vector of FlagRow s. 00529 std::vector<FlagRow * > privateRows; 00530 00531 00532 00533 std::vector<FlagRow *> row; 00534 00535 00536 void error() ; //throw(ConversionException); 00537 00538 00545 void fromXML(std::string& xmlDoc) ; 00546 00547 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00548 00553 void setFromMIMEFile(const std::string& directory); 00554 /* 00555 void openMIMEFile(const std::string& directory); 00556 */ 00557 void setFromXMLFile(const std::string& directory); 00558 00566 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00567 00568 00575 void setFromMIME(const std::string & mimeMsg); 00576 00580 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00581 00591 void toFile(std::string directory); 00592 00596 bool loadInProgress; 00597 void checkPresenceInMemory() { 00598 if (!presentInMemory && !loadInProgress) { 00599 loadInProgress = true; 00600 setFromFile(getContainer().getDirectory()); 00601 presentInMemory = true; 00602 loadInProgress = false; 00603 } 00604 } 00613 void setFromFile(const std::string& directory); 00614 00615 }; 00616 00617 } // End namespace asdm 00618 00619 #endif /* FlagTable_CLASS */