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 StateTable.h 00032 */ 00033 00034 #ifndef StateTable_CLASS 00035 #define StateTable_CLASS 00036 00037 #include <string> 00038 #include <vector> 00039 #include <map> 00040 00041 00042 00043 00044 #include <Tag.h> 00045 00046 00047 00048 00049 00050 00051 00052 00053 #include "CCalibrationDevice.h" 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 #include <ConversionException.h> 00067 #include <DuplicateKey.h> 00068 #include <UniquenessViolationException.h> 00069 #include <NoSuchRow.h> 00070 #include <DuplicateKey.h> 00071 00072 00073 #ifndef WITHOUT_ACS 00074 #include <asdmIDLC.h> 00075 #endif 00076 00077 #include <Representable.h> 00078 00079 #include <pthread.h> 00080 00081 namespace asdm { 00082 00083 //class asdm::ASDM; 00084 //class asdm::StateRow; 00085 00086 class ASDM; 00087 class StateRow; 00159 class StateTable : public Representable { 00160 friend class ASDM; 00161 00162 public: 00163 00164 00170 static const std::vector<std::string>& getKeyName(); 00171 00172 00173 virtual ~StateTable(); 00174 00180 ASDM &getContainer() const; 00181 00187 unsigned int size() const; 00188 00196 std::string getName() const; 00197 00205 static std::string name() ; 00206 00211 std::string getVersion() const ; 00212 00218 static const std::vector<std::string>& getAttributesNames(); 00219 00225 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00226 00230 Entity getEntity() const; 00231 00236 void setEntity(Entity e); 00237 00245 std::string toXML() ; 00246 00247 #ifndef WITHOUT_ACS 00248 // Conversion Methods 00254 asdmIDL::StateTableIDL *toIDL() ; 00255 00263 void toIDL(asdmIDL::StateTableIDL& x) const; 00264 00265 #endif 00266 00267 #ifndef WITHOUT_ACS 00268 00274 void fromIDL(asdmIDL::StateTableIDL x) ; 00275 #endif 00276 00277 // 00278 // ====> Row creation. 00279 // 00280 00285 StateRow *newRow(); 00286 00287 00301 StateRow *newRow(CalibrationDeviceMod::CalibrationDevice calDeviceName, bool sig, bool ref, bool onSky); 00302 00303 00304 00317 StateRow *newRow(StateRow *row); 00318 00319 // 00320 // ====> Append a row to its table. 00321 // 00322 00323 00324 00325 00335 StateRow* add(StateRow* x) ; 00336 00337 00338 00339 // 00340 // ====> Methods returning rows. 00341 // 00342 00348 std::vector<StateRow *> get() ; 00349 00356 const std::vector<StateRow *>& get() const ; 00357 00358 00359 00360 00361 00371 StateRow* getRowByKey(Tag stateId); 00372 00373 00374 00375 00376 00392 StateRow* lookup(CalibrationDeviceMod::CalibrationDevice calDeviceName, bool sig, bool ref, bool onSky); 00393 00394 00395 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00396 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00397 00398 private: 00399 00408 StateTable (ASDM & container); 00409 00410 ASDM & container; 00411 00412 bool archiveAsBin; // If true archive binary else archive XML 00413 bool fileAsBin ; // If true file binary else file XML 00414 00415 std::string version ; 00416 00417 Entity entity; 00418 00419 00420 // A map for the autoincrementation algorithm 00421 std::map<std::string,int> noAutoIncIds; 00422 void autoIncrement(std::string key, StateRow* x); 00423 00424 00434 StateRow* checkAndAdd(StateRow* x, bool skipCheckUniqueness=false) ; 00435 00441 void append(StateRow* x) ; 00442 00448 void addWithoutCheckingUnique(StateRow* x) ; 00449 00450 00451 00452 00453 00454 // A data structure to store the pointers on the table's rows. 00455 00456 // In all cases we maintain a private vector of StateRow s. 00457 std::vector<StateRow * > privateRows; 00458 00459 00460 00461 std::vector<StateRow *> row; 00462 00463 00464 void error() ; //throw(ConversionException); 00465 00466 00473 void fromXML(std::string& xmlDoc) ; 00474 00475 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00476 00481 void setFromMIMEFile(const std::string& directory); 00482 /* 00483 void openMIMEFile(const std::string& directory); 00484 */ 00485 void setFromXMLFile(const std::string& directory); 00486 00494 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00495 00496 00503 void setFromMIME(const std::string & mimeMsg); 00504 00508 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00509 00519 void toFile(std::string directory); 00520 00524 bool loadInProgress; 00525 void checkPresenceInMemory() { 00526 if (!presentInMemory && !loadInProgress) { 00527 loadInProgress = true; 00528 setFromFile(getContainer().getDirectory()); 00529 presentInMemory = true; 00530 loadInProgress = false; 00531 } 00532 } 00541 void setFromFile(const std::string& directory); 00542 00543 }; 00544 00545 } // End namespace asdm 00546 00547 #endif /* StateTable_CLASS */