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 FlagCmdTable.h 00032 */ 00033 00034 #ifndef FlagCmdTable_CLASS 00035 #define FlagCmdTable_CLASS 00036 00037 #include <string> 00038 #include <vector> 00039 #include <map> 00040 00041 00042 00043 00044 #include <ArrayTimeInterval.h> 00045 00046 00047 00048 00049 00050 00051 00052 00053 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::FlagCmdRow; 00085 00086 class ASDM; 00087 class FlagCmdRow; 00163 class FlagCmdTable : public Representable { 00164 friend class ASDM; 00165 00166 public: 00167 00168 00174 static const std::vector<std::string>& getKeyName(); 00175 00176 00177 virtual ~FlagCmdTable(); 00178 00184 ASDM &getContainer() const; 00185 00191 unsigned int size() const; 00192 00200 std::string getName() const; 00201 00209 static std::string name() ; 00210 00215 std::string getVersion() const ; 00216 00222 static const std::vector<std::string>& getAttributesNames(); 00223 00229 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00230 00234 Entity getEntity() const; 00235 00240 void setEntity(Entity e); 00241 00249 std::string toXML() ; 00250 00251 #ifndef WITHOUT_ACS 00252 // Conversion Methods 00258 asdmIDL::FlagCmdTableIDL *toIDL() ; 00259 00267 void toIDL(asdmIDL::FlagCmdTableIDL& x) const; 00268 00269 #endif 00270 00271 #ifndef WITHOUT_ACS 00272 00278 void fromIDL(asdmIDL::FlagCmdTableIDL x) ; 00279 #endif 00280 00281 // 00282 // ====> Row creation. 00283 // 00284 00289 FlagCmdRow *newRow(); 00290 00291 00311 FlagCmdRow *newRow(ArrayTimeInterval timeInterval, string type, string reason, int level, int severity, bool applied, string command); 00312 00313 00314 00327 FlagCmdRow *newRow(FlagCmdRow *row); 00328 00329 // 00330 // ====> Append a row to its table. 00331 // 00332 00333 00350 FlagCmdRow* add(FlagCmdRow* x) ; 00351 00352 00353 00354 00355 00356 // 00357 // ====> Methods returning rows. 00358 // 00359 00365 std::vector<FlagCmdRow *> get() ; 00366 00373 const std::vector<FlagCmdRow *>& get() const ; 00374 00375 00386 std::vector <FlagCmdRow*> *getByContext(); 00387 00388 00389 00390 00391 00401 FlagCmdRow* getRowByKey(ArrayTimeInterval timeInterval); 00402 00403 00404 00405 00406 00428 FlagCmdRow* lookup(ArrayTimeInterval timeInterval, string type, string reason, int level, int severity, bool applied, string command); 00429 00430 00431 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00432 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00433 00434 private: 00435 00444 FlagCmdTable (ASDM & container); 00445 00446 ASDM & container; 00447 00448 bool archiveAsBin; // If true archive binary else archive XML 00449 bool fileAsBin ; // If true file binary else file XML 00450 00451 std::string version ; 00452 00453 Entity entity; 00454 00455 00456 00464 FlagCmdRow* checkAndAdd(FlagCmdRow* x, bool skipCheckUniqueness=false) ; 00465 00471 void append(FlagCmdRow* x) ; 00472 00478 void addWithoutCheckingUnique(FlagCmdRow* x) ; 00479 00480 00481 00482 00483 00484 00492 FlagCmdRow * insertByStartTime(FlagCmdRow* x, std::vector<FlagCmdRow* >& row); 00493 00494 00495 00496 // A data structure to store the pointers on the table's rows. 00497 00498 // In all cases we maintain a private vector of FlagCmdRow s. 00499 std::vector<FlagCmdRow * > privateRows; 00500 00501 00502 00503 00504 00505 00506 00507 00508 std::vector <FlagCmdRow *> row; 00509 00510 00511 00512 00513 00514 00515 void error() ; //throw(ConversionException); 00516 00517 00524 void fromXML(std::string& xmlDoc) ; 00525 00526 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00527 00532 void setFromMIMEFile(const std::string& directory); 00533 /* 00534 void openMIMEFile(const std::string& directory); 00535 */ 00536 void setFromXMLFile(const std::string& directory); 00537 00545 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00546 00547 00554 void setFromMIME(const std::string & mimeMsg); 00555 00559 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00560 00570 void toFile(std::string directory); 00571 00575 bool loadInProgress; 00576 void checkPresenceInMemory() { 00577 if (!presentInMemory && !loadInProgress) { 00578 loadInProgress = true; 00579 setFromFile(getContainer().getDirectory()); 00580 presentInMemory = true; 00581 loadInProgress = false; 00582 } 00583 } 00592 void setFromFile(const std::string& directory); 00593 00594 }; 00595 00596 } // End namespace asdm 00597 00598 #endif /* FlagCmdTable_CLASS */