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 SwitchCycleTable.h 00032 */ 00033 00034 #ifndef SwitchCycleTable_CLASS 00035 #define SwitchCycleTable_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 <Interval.h> 00053 00054 00055 00056 #include <Tag.h> 00057 00058 00059 00060 #include <Frequency.h> 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 #include "CDirectionReferenceCode.h" 00080 00081 00082 00083 00084 00085 00086 #include <ConversionException.h> 00087 #include <DuplicateKey.h> 00088 #include <UniquenessViolationException.h> 00089 #include <NoSuchRow.h> 00090 #include <DuplicateKey.h> 00091 00092 00093 #ifndef WITHOUT_ACS 00094 #include <asdmIDLC.h> 00095 #endif 00096 00097 #include <Representable.h> 00098 00099 #include <pthread.h> 00100 00101 namespace asdm { 00102 00103 //class asdm::ASDM; 00104 //class asdm::SwitchCycleRow; 00105 00106 class ASDM; 00107 class SwitchCycleRow; 00193 class SwitchCycleTable : public Representable { 00194 friend class ASDM; 00195 00196 public: 00197 00198 00204 static const std::vector<std::string>& getKeyName(); 00205 00206 00207 virtual ~SwitchCycleTable(); 00208 00214 ASDM &getContainer() const; 00215 00221 unsigned int size() const; 00222 00230 std::string getName() const; 00231 00239 static std::string name() ; 00240 00245 std::string getVersion() const ; 00246 00252 static const std::vector<std::string>& getAttributesNames(); 00253 00259 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00260 00264 Entity getEntity() const; 00265 00270 void setEntity(Entity e); 00271 00279 std::string toXML() ; 00280 00281 #ifndef WITHOUT_ACS 00282 // Conversion Methods 00288 asdmIDL::SwitchCycleTableIDL *toIDL() ; 00289 00297 void toIDL(asdmIDL::SwitchCycleTableIDL& x) const; 00298 00299 #endif 00300 00301 #ifndef WITHOUT_ACS 00302 00308 void fromIDL(asdmIDL::SwitchCycleTableIDL x) ; 00309 #endif 00310 00311 // 00312 // ====> Row creation. 00313 // 00314 00319 SwitchCycleRow *newRow(); 00320 00321 00337 SwitchCycleRow *newRow(int numStep, vector<float > weightArray, vector<vector<Angle > > dirOffsetArray, vector<Frequency > freqOffsetArray, vector<Interval > stepDurationArray); 00338 00339 00340 00353 SwitchCycleRow *newRow(SwitchCycleRow *row); 00354 00355 // 00356 // ====> Append a row to its table. 00357 // 00358 00359 00360 00361 00371 SwitchCycleRow* add(SwitchCycleRow* x) ; 00372 00373 00374 00375 // 00376 // ====> Methods returning rows. 00377 // 00378 00384 std::vector<SwitchCycleRow *> get() ; 00385 00392 const std::vector<SwitchCycleRow *>& get() const ; 00393 00394 00395 00396 00397 00407 SwitchCycleRow* getRowByKey(Tag switchCycleId); 00408 00409 00410 00411 00412 00430 SwitchCycleRow* lookup(int numStep, vector<float > weightArray, vector<vector<Angle > > dirOffsetArray, vector<Frequency > freqOffsetArray, vector<Interval > stepDurationArray); 00431 00432 00433 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00434 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00435 00436 private: 00437 00446 SwitchCycleTable (ASDM & container); 00447 00448 ASDM & container; 00449 00450 bool archiveAsBin; // If true archive binary else archive XML 00451 bool fileAsBin ; // If true file binary else file XML 00452 00453 std::string version ; 00454 00455 Entity entity; 00456 00457 00458 // A map for the autoincrementation algorithm 00459 std::map<std::string,int> noAutoIncIds; 00460 void autoIncrement(std::string key, SwitchCycleRow* x); 00461 00462 00472 SwitchCycleRow* checkAndAdd(SwitchCycleRow* x, bool skipCheckUniqueness=false) ; 00473 00479 void append(SwitchCycleRow* x) ; 00480 00486 void addWithoutCheckingUnique(SwitchCycleRow* x) ; 00487 00488 00489 00490 00491 00492 // A data structure to store the pointers on the table's rows. 00493 00494 // In all cases we maintain a private vector of SwitchCycleRow s. 00495 std::vector<SwitchCycleRow * > privateRows; 00496 00497 00498 00499 std::vector<SwitchCycleRow *> row; 00500 00501 00502 void error() ; //throw(ConversionException); 00503 00504 00511 void fromXML(std::string& xmlDoc) ; 00512 00513 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00514 00519 void setFromMIMEFile(const std::string& directory); 00520 /* 00521 void openMIMEFile(const std::string& directory); 00522 */ 00523 void setFromXMLFile(const std::string& directory); 00524 00532 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00533 00534 00541 void setFromMIME(const std::string & mimeMsg); 00542 00546 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00547 00557 void toFile(std::string directory); 00558 00562 bool loadInProgress; 00563 void checkPresenceInMemory() { 00564 if (!presentInMemory && !loadInProgress) { 00565 loadInProgress = true; 00566 setFromFile(getContainer().getDirectory()); 00567 presentInMemory = true; 00568 loadInProgress = false; 00569 } 00570 } 00579 void setFromFile(const std::string& directory); 00580 00581 }; 00582 00583 } // End namespace asdm 00584 00585 #endif /* SwitchCycleTable_CLASS */