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 namespace asdm { 00098 00099 //class asdm::ASDM; 00100 //class asdm::MainRow; 00101 00102 class ASDM; 00103 class MainRow; 00226 class MainTable : public Representable { 00227 friend class ASDM; 00228 00229 public: 00230 00231 00237 static std::vector<std::string> getKeyName(); 00238 00239 00240 virtual ~MainTable(); 00241 00247 ASDM &getContainer() const; 00248 00254 unsigned int size() const; 00255 00263 std::string getName() const; 00264 00272 static std::string name() ; 00273 00278 std::string getVersion() const ; 00279 00285 static const std::vector<std::string>& getAttributesNames(); 00286 00292 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00293 00297 Entity getEntity() const; 00298 00303 void setEntity(Entity e); 00304 00312 std::string toXML() ; 00313 00314 #ifndef WITHOUT_ACS 00315 // Conversion Methods 00321 asdmIDL::MainTableIDL *toIDL() ; 00322 #endif 00323 00324 #ifndef WITHOUT_ACS 00325 00331 void fromIDL(asdmIDL::MainTableIDL x) ; 00332 #endif 00333 00334 // 00335 // ====> Row creation. 00336 // 00337 00342 MainRow *newRow(); 00343 00344 00376 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); 00377 00378 00379 00392 MainRow *newRow(MainRow *row); 00393 00394 // 00395 // ====> Append a row to its table. 00396 // 00397 00398 00415 MainRow* add(MainRow* x) ; 00416 00417 00418 00419 00420 00421 // 00422 // ====> Methods returning rows. 00423 // 00424 00430 std::vector<MainRow *> get() ; 00431 00438 const std::vector<MainRow *>& get() const ; 00439 00440 00451 std::vector <MainRow*> *getByContext(Tag configDescriptionId, Tag fieldId); 00452 00453 00454 00455 00456 00470 MainRow* getRowByKey(ArrayTime time, Tag configDescriptionId, Tag fieldId); 00471 00472 00473 00474 00475 00509 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); 00510 00511 00512 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00513 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00514 00515 private: 00516 00525 MainTable (ASDM & container); 00526 00527 ASDM & container; 00528 00529 bool archiveAsBin; // If true archive binary else archive XML 00530 bool fileAsBin ; // If true file binary else file XML 00531 00532 std::string version ; 00533 00534 Entity entity; 00535 00536 00537 00541 static std::string itsName; 00542 00546 static std::vector<std::string> attributesNames; 00547 00551 static std::vector<std::string> attributesNamesInBin; 00552 00553 00557 static bool initAttributesNames(), initAttributesNamesDone ; 00558 00559 00563 static std::vector<std::string> key; 00564 00565 00573 MainRow* checkAndAdd(MainRow* x) ; 00574 00580 void append(MainRow* x) ; 00581 00587 void addWithoutCheckingUnique(MainRow* x) ; 00588 00589 00590 00591 00592 00593 00601 MainRow * insertByTime(MainRow* x, std::vector<MainRow *>&row ); 00602 00603 00604 00605 // A data structure to store the pointers on the table's rows. 00606 00607 // In all cases we maintain a private vector of MainRow s. 00608 std::vector<MainRow * > privateRows; 00609 00610 00611 00612 00613 00614 00615 00616 00617 typedef std::vector <MainRow* > TIME_ROWS; 00618 std::map<std::string, TIME_ROWS > context; 00619 00624 std::string Key(Tag configDescriptionId, Tag fieldId) ; 00625 00626 00627 00628 00634 void getByKeyNoAutoIncNoTime(std::vector <MainRow*>& vin, std::vector <MainRow*>& vout, Tag configDescriptionId, Tag fieldId); 00635 00636 00637 00638 void error() ; //throw(ConversionException); 00639 00640 00647 void fromXML(std::string& xmlDoc) ; 00648 00649 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00650 00655 void setFromMIMEFile(const std::string& directory); 00656 /* 00657 void openMIMEFile(const std::string& directory); 00658 */ 00659 void setFromXMLFile(const std::string& directory); 00660 00668 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00669 00670 00677 void setFromMIME(const std::string & mimeMsg); 00678 00682 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00683 00693 void toFile(std::string directory); 00694 00698 bool loadInProgress; 00699 void checkPresenceInMemory() { 00700 if (!presentInMemory && !loadInProgress) { 00701 loadInProgress = true; 00702 setFromFile(getContainer().getDirectory()); 00703 presentInMemory = true; 00704 loadInProgress = false; 00705 } 00706 } 00715 void setFromFile(const std::string& directory); 00716 00717 }; 00718 00719 } // End namespace asdm 00720 00721 #endif /* MainTable_CLASS */