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 StationTable.h 00032 */ 00033 00034 #ifndef StationTable_CLASS 00035 #define StationTable_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 <Length.h> 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 #include "CStationType.h" 00066 00067 00068 00069 00070 00071 00072 #include <ConversionException.h> 00073 #include <DuplicateKey.h> 00074 #include <UniquenessViolationException.h> 00075 #include <NoSuchRow.h> 00076 #include <DuplicateKey.h> 00077 00078 00079 #ifndef WITHOUT_ACS 00080 #include <asdmIDLC.h> 00081 #endif 00082 00083 #include <Representable.h> 00084 00085 #include <pthread.h> 00086 00087 namespace asdm { 00088 00089 //class asdm::ASDM; 00090 //class asdm::StationRow; 00091 00092 class ASDM; 00093 class StationRow; 00158 class StationTable : public Representable { 00159 friend class ASDM; 00160 00161 public: 00162 00163 00169 static const std::vector<std::string>& getKeyName(); 00170 00171 00172 virtual ~StationTable(); 00173 00179 ASDM &getContainer() const; 00180 00186 unsigned int size() const; 00187 00195 std::string getName() const; 00196 00204 static std::string name() ; 00205 00210 std::string getVersion() const ; 00211 00217 static const std::vector<std::string>& getAttributesNames(); 00218 00224 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00225 00229 Entity getEntity() const; 00230 00235 void setEntity(Entity e); 00236 00244 std::string toXML() ; 00245 00246 #ifndef WITHOUT_ACS 00247 // Conversion Methods 00253 asdmIDL::StationTableIDL *toIDL() ; 00254 00262 void toIDL(asdmIDL::StationTableIDL& x) const; 00263 00264 #endif 00265 00266 #ifndef WITHOUT_ACS 00267 00273 void fromIDL(asdmIDL::StationTableIDL x) ; 00274 #endif 00275 00276 // 00277 // ====> Row creation. 00278 // 00279 00284 StationRow *newRow(); 00285 00286 00298 StationRow *newRow(string name, vector<Length > position, StationTypeMod::StationType type); 00299 00300 00301 00314 StationRow *newRow(StationRow *row); 00315 00316 // 00317 // ====> Append a row to its table. 00318 // 00319 00320 00321 00322 00332 StationRow* add(StationRow* x) ; 00333 00334 00335 00336 // 00337 // ====> Methods returning rows. 00338 // 00339 00345 std::vector<StationRow *> get() ; 00346 00353 const std::vector<StationRow *>& get() const ; 00354 00355 00356 00357 00358 00368 StationRow* getRowByKey(Tag stationId); 00369 00370 00371 00372 00373 00387 StationRow* lookup(string name, vector<Length > position, StationTypeMod::StationType type); 00388 00389 00390 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00391 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00392 00393 private: 00394 00403 StationTable (ASDM & container); 00404 00405 ASDM & container; 00406 00407 bool archiveAsBin; // If true archive binary else archive XML 00408 bool fileAsBin ; // If true file binary else file XML 00409 00410 std::string version ; 00411 00412 Entity entity; 00413 00414 00415 // A map for the autoincrementation algorithm 00416 std::map<std::string,int> noAutoIncIds; 00417 void autoIncrement(std::string key, StationRow* x); 00418 00419 00429 StationRow* checkAndAdd(StationRow* x, bool skipCheckUniqueness=false) ; 00430 00436 void append(StationRow* x) ; 00437 00443 void addWithoutCheckingUnique(StationRow* x) ; 00444 00445 00446 00447 00448 00449 // A data structure to store the pointers on the table's rows. 00450 00451 // In all cases we maintain a private vector of StationRow s. 00452 std::vector<StationRow * > privateRows; 00453 00454 00455 00456 std::vector<StationRow *> row; 00457 00458 00459 void error() ; //throw(ConversionException); 00460 00461 00468 void fromXML(std::string& xmlDoc) ; 00469 00470 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00471 00476 void setFromMIMEFile(const std::string& directory); 00477 /* 00478 void openMIMEFile(const std::string& directory); 00479 */ 00480 void setFromXMLFile(const std::string& directory); 00481 00489 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00490 00491 00498 void setFromMIME(const std::string & mimeMsg); 00499 00503 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00504 00514 void toFile(std::string directory); 00515 00519 bool loadInProgress; 00520 void checkPresenceInMemory() { 00521 if (!presentInMemory && !loadInProgress) { 00522 loadInProgress = true; 00523 setFromFile(getContainer().getDirectory()); 00524 presentInMemory = true; 00525 loadInProgress = false; 00526 } 00527 } 00536 void setFromFile(const std::string& directory); 00537 00538 }; 00539 00540 } // End namespace asdm 00541 00542 #endif /* StationTable_CLASS */