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 MainTable.h 00032 */ 00033 00034 #ifndef MainTable_CLASS 00035 #define MainTable_CLASS 00036 00037 #include <string> 00038 #include <vector> 00039 #include <map> 00040 00041 00042 00043 00044 #include <ArrayTime.h> 00045 00046 00047 00048 #include <Interval.h> 00049 00050 00051 00052 #include <Tag.h> 00053 00054 00055 00056 #include <EntityRef.h> 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 #include "CTimeSampling.h" 00068 00069 00070 00071 00072 00073 00074 00075 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::MainRow; 00103 00104 class ASDM; 00105 class MainRow; 00228 class MainTable : public Representable { 00229 friend class ASDM; 00230 00231 public: 00232 00233 00239 static const std::vector<std::string>& getKeyName(); 00240 00241 00242 virtual ~MainTable(); 00243 00249 ASDM &getContainer() const; 00250 00256 unsigned int size() const; 00257 00265 std::string getName() const; 00266 00274 static std::string name() ; 00275 00280 std::string getVersion() const ; 00281 00287 static const std::vector<std::string>& getAttributesNames(); 00288 00294 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00295 00299 Entity getEntity() const; 00300 00305 void setEntity(Entity e); 00306 00314 std::string toXML() ; 00315 00316 #ifndef WITHOUT_ACS 00317 // Conversion Methods 00323 asdmIDL::MainTableIDL *toIDL() ; 00324 00332 void toIDL(asdmIDL::MainTableIDL& x) const; 00333 00334 #endif 00335 00336 #ifndef WITHOUT_ACS 00337 00343 void fromIDL(asdmIDL::MainTableIDL x) ; 00344 #endif 00345 00346 // 00347 // ====> Row creation. 00348 // 00349 00354 MainRow *newRow(); 00355 00356 00388 MainRow *newRow(ArrayTime time, Tag configDescriptionId, Tag fieldId, int numAntenna, TimeSamplingMod::TimeSampling timeSampling, Interval interval, int numIntegration, int scanNumber, int subscanNumber, int64_t dataSize, EntityRef dataUID, vector<Tag> stateId, Tag execBlockId); 00389 00390 00391 00404 MainRow *newRow(MainRow *row); 00405 00406 // 00407 // ====> Append a row to its table. 00408 // 00409 00410 00427 MainRow* add(MainRow* x) ; 00428 00429 00430 00431 00432 00433 // 00434 // ====> Methods returning rows. 00435 // 00436 00442 std::vector<MainRow *> get() ; 00443 00450 const std::vector<MainRow *>& get() const ; 00451 00452 00463 std::vector <MainRow*> *getByContext(Tag configDescriptionId, Tag fieldId); 00464 00465 00466 00467 00468 00482 MainRow* getRowByKey(ArrayTime time, Tag configDescriptionId, Tag fieldId); 00483 00484 00485 00486 00487 00521 MainRow* lookup(ArrayTime time, Tag configDescriptionId, Tag fieldId, int numAntenna, TimeSamplingMod::TimeSampling timeSampling, Interval interval, int numIntegration, int scanNumber, int subscanNumber, int64_t dataSize, EntityRef dataUID, vector<Tag> stateId, Tag execBlockId); 00522 00523 00524 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00525 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00526 00527 private: 00528 00537 MainTable (ASDM & container); 00538 00539 ASDM & container; 00540 00541 bool archiveAsBin; // If true archive binary else archive XML 00542 bool fileAsBin ; // If true file binary else file XML 00543 00544 std::string version ; 00545 00546 Entity entity; 00547 00548 00549 00557 MainRow* checkAndAdd(MainRow* x, bool skipCheckUniqueness=false) ; 00558 00564 void append(MainRow* x) ; 00565 00571 void addWithoutCheckingUnique(MainRow* x) ; 00572 00573 00574 00575 00576 00577 00585 MainRow * insertByTime(MainRow* x, std::vector<MainRow *>&row ); 00586 00587 00588 00589 // A data structure to store the pointers on the table's rows. 00590 00591 // In all cases we maintain a private vector of MainRow s. 00592 std::vector<MainRow * > privateRows; 00593 00594 00595 00596 00597 00598 00599 00600 00601 typedef std::vector <MainRow* > TIME_ROWS; 00602 std::map<std::string, TIME_ROWS > context; 00603 00608 std::string Key(Tag configDescriptionId, Tag fieldId) ; 00609 00610 00611 00612 00618 void getByKeyNoAutoIncNoTime(std::vector <MainRow*>& vin, std::vector <MainRow*>& vout, Tag configDescriptionId, Tag fieldId); 00619 00620 00621 00622 void error() ; //throw(ConversionException); 00623 00624 00631 void fromXML(std::string& xmlDoc) ; 00632 00633 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00634 00639 void setFromMIMEFile(const std::string& directory); 00640 /* 00641 void openMIMEFile(const std::string& directory); 00642 */ 00643 void setFromXMLFile(const std::string& directory); 00644 00652 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00653 00654 00661 void setFromMIME(const std::string & mimeMsg); 00662 00666 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00667 00677 void toFile(std::string directory); 00678 00682 bool loadInProgress; 00683 void checkPresenceInMemory() { 00684 if (!presentInMemory && !loadInProgress) { 00685 loadInProgress = true; 00686 setFromFile(getContainer().getDirectory()); 00687 presentInMemory = true; 00688 loadInProgress = false; 00689 } 00690 } 00699 void setFromFile(const std::string& directory); 00700 00701 }; 00702 00703 } // End namespace asdm 00704 00705 #endif /* MainTable_CLASS */