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 FieldTable.h 00032 */ 00033 00034 #ifndef FieldTable_CLASS 00035 #define FieldTable_CLASS 00036 00037 #include <string> 00038 #include <vector> 00039 #include <map> 00040 00041 00042 00043 00044 #include <ArrayTime.h> 00045 00046 00047 00048 #include <Angle.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 00070 00071 00072 00073 00074 00075 #include "CDirectionReferenceCode.h" 00076 00077 00078 00079 00080 00081 00082 00083 00084 #include <ConversionException.h> 00085 #include <DuplicateKey.h> 00086 #include <UniquenessViolationException.h> 00087 #include <NoSuchRow.h> 00088 #include <DuplicateKey.h> 00089 00090 00091 #ifndef WITHOUT_ACS 00092 #include <asdmIDLC.h> 00093 #endif 00094 00095 #include <Representable.h> 00096 00097 #include <pthread.h> 00098 00099 namespace asdm { 00100 00101 //class asdm::ASDM; 00102 //class asdm::FieldRow; 00103 00104 class ASDM; 00105 class FieldRow; 00233 class FieldTable : public Representable { 00234 friend class ASDM; 00235 00236 public: 00237 00238 00244 static const std::vector<std::string>& getKeyName(); 00245 00246 00247 virtual ~FieldTable(); 00248 00254 ASDM &getContainer() const; 00255 00261 unsigned int size() const; 00262 00270 std::string getName() const; 00271 00279 static std::string name() ; 00280 00285 std::string getVersion() const ; 00286 00292 static const std::vector<std::string>& getAttributesNames(); 00293 00299 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00300 00304 Entity getEntity() const; 00305 00310 void setEntity(Entity e); 00311 00319 std::string toXML() ; 00320 00321 #ifndef WITHOUT_ACS 00322 // Conversion Methods 00328 asdmIDL::FieldTableIDL *toIDL() ; 00329 00337 void toIDL(asdmIDL::FieldTableIDL& x) const; 00338 00339 #endif 00340 00341 #ifndef WITHOUT_ACS 00342 00348 void fromIDL(asdmIDL::FieldTableIDL x) ; 00349 #endif 00350 00351 // 00352 // ====> Row creation. 00353 // 00354 00359 FieldRow *newRow(); 00360 00361 00377 FieldRow *newRow(string fieldName, int numPoly, vector<vector<Angle > > delayDir, vector<vector<Angle > > phaseDir, vector<vector<Angle > > referenceDir); 00378 00379 00380 00393 FieldRow *newRow(FieldRow *row); 00394 00395 // 00396 // ====> Append a row to its table. 00397 // 00398 00399 00400 00401 00411 FieldRow* add(FieldRow* x) ; 00412 00413 00414 00415 // 00416 // ====> Methods returning rows. 00417 // 00418 00424 std::vector<FieldRow *> get() ; 00425 00432 const std::vector<FieldRow *>& get() const ; 00433 00434 00435 00436 00437 00447 FieldRow* getRowByKey(Tag fieldId); 00448 00449 00450 00451 00452 00470 FieldRow* lookup(string fieldName, int numPoly, vector<vector<Angle > > delayDir, vector<vector<Angle > > phaseDir, vector<vector<Angle > > referenceDir); 00471 00472 00473 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00474 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00475 00476 private: 00477 00486 FieldTable (ASDM & container); 00487 00488 ASDM & container; 00489 00490 bool archiveAsBin; // If true archive binary else archive XML 00491 bool fileAsBin ; // If true file binary else file XML 00492 00493 std::string version ; 00494 00495 Entity entity; 00496 00497 00498 // A map for the autoincrementation algorithm 00499 std::map<std::string,int> noAutoIncIds; 00500 void autoIncrement(std::string key, FieldRow* x); 00501 00502 00512 FieldRow* checkAndAdd(FieldRow* x, bool skipCheckUniqueness=false) ; 00513 00519 void append(FieldRow* x) ; 00520 00526 void addWithoutCheckingUnique(FieldRow* x) ; 00527 00528 00529 00530 00531 00532 // A data structure to store the pointers on the table's rows. 00533 00534 // In all cases we maintain a private vector of FieldRow s. 00535 std::vector<FieldRow * > privateRows; 00536 00537 00538 00539 std::vector<FieldRow *> row; 00540 00541 00542 void error() ; //throw(ConversionException); 00543 00544 00551 void fromXML(std::string& xmlDoc) ; 00552 00553 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00554 00559 void setFromMIMEFile(const std::string& directory); 00560 /* 00561 void openMIMEFile(const std::string& directory); 00562 */ 00563 void setFromXMLFile(const std::string& directory); 00564 00572 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00573 00574 00581 void setFromMIME(const std::string & mimeMsg); 00582 00586 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00587 00597 void toFile(std::string directory); 00598 00602 bool loadInProgress; 00603 void checkPresenceInMemory() { 00604 if (!presentInMemory && !loadInProgress) { 00605 loadInProgress = true; 00606 setFromFile(getContainer().getDirectory()); 00607 presentInMemory = true; 00608 loadInProgress = false; 00609 } 00610 } 00619 void setFromFile(const std::string& directory); 00620 00621 }; 00622 00623 } // End namespace asdm 00624 00625 #endif /* FieldTable_CLASS */