casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ExecBlockTable.h
Go to the documentation of this file.
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 ExecBlockTable.h
00032  */
00033  
00034 #ifndef ExecBlockTable_CLASS
00035 #define ExecBlockTable_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 <Tag.h>
00053         
00054 
00055         
00056 #include <Length.h>
00057         
00058 
00059         
00060 #include <EntityRef.h>
00061         
00062 
00063 
00064 
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 
00078         
00079 
00080         
00081 
00082         
00083 
00084         
00085 
00086         
00087 
00088         
00089 
00090         
00091 
00092         
00093 
00094         
00095 
00096         
00097 
00098         
00099 
00100         
00101 
00102         
00103 
00104         
00105 
00106         
00107 
00108         
00109 
00110         
00111 
00112         
00113 
00114         
00115 
00116         
00117 
00118 
00119 
00120 #include <ConversionException.h>
00121 #include <DuplicateKey.h>
00122 #include <UniquenessViolationException.h>
00123 #include <NoSuchRow.h>
00124 #include <DuplicateKey.h>
00125 
00126 
00127 #ifndef WITHOUT_ACS
00128 #include <asdmIDLC.h>
00129 #endif
00130 
00131 #include <Representable.h>
00132 
00133 namespace asdm {
00134 
00135 //class asdm::ASDM;
00136 //class asdm::ExecBlockRow;
00137 
00138 class ASDM;
00139 class ExecBlockRow;
00372 class ExecBlockTable : public Representable {
00373         friend class ASDM;
00374 
00375 public:
00376 
00377 
00383         static std::vector<std::string> getKeyName();
00384 
00385 
00386         virtual ~ExecBlockTable();
00387         
00393         ASDM &getContainer() const;
00394         
00400         unsigned int size() const;
00401         
00409         std::string getName() const;
00410         
00418         static std::string name() ;     
00419         
00424          std::string getVersion() const ;
00425         
00431          static const std::vector<std::string>& getAttributesNames();
00432 
00438          static const std::vector<std::string>& defaultAttributesNamesInBin();
00439          
00443         Entity getEntity() const;
00444 
00449         void setEntity(Entity e);
00450                 
00458         std::string toXML()  ;
00459 
00460 #ifndef WITHOUT_ACS
00461         // Conversion Methods
00467         asdmIDL::ExecBlockTableIDL *toIDL() ;
00468 #endif
00469 
00470 #ifndef WITHOUT_ACS
00471 
00477         void fromIDL(asdmIDL::ExecBlockTableIDL x) ;
00478 #endif
00479         
00480         //
00481         // ====> Row creation.
00482         //
00483         
00488         ExecBlockRow *newRow();
00489         
00490         
00536         ExecBlockRow *newRow(ArrayTime startTime, ArrayTime endTime, int execBlockNum, EntityRef execBlockUID, EntityRef projectUID, string configName, string telescopeName, string observerName, int numObservingLog, vector<string > observingLog, EntityRef sessionReference, Length baseRangeMin, Length baseRangeMax, Length baseRmsMinor, Length baseRmsMajor, Angle basePa, bool aborted, int numAntenna, vector<Tag>  antennaId, Tag sBSummaryId);
00537         
00538 
00539 
00552          ExecBlockRow *newRow(ExecBlockRow *row); 
00553 
00554         //
00555         // ====> Append a row to its table.
00556         //
00557 
00558         
00559         
00560         
00570          ExecBlockRow* add(ExecBlockRow* x) ;
00571 
00572 
00573 
00574         //
00575         // ====> Methods returning rows.
00576         //
00577                 
00583         std::vector<ExecBlockRow *> get() ;
00584         
00591          const std::vector<ExecBlockRow *>& get() const ;
00592         
00593 
00594 
00595  
00596         
00606         ExecBlockRow* getRowByKey(Tag execBlockId);
00607 
00608                 
00609 
00610 
00611 
00659         ExecBlockRow* lookup(ArrayTime startTime, ArrayTime endTime, int execBlockNum, EntityRef execBlockUID, EntityRef projectUID, string configName, string telescopeName, string observerName, int numObservingLog, vector<string > observingLog, EntityRef sessionReference, Length baseRangeMin, Length baseRangeMax, Length baseRmsMinor, Length baseRmsMajor, Angle basePa, bool aborted, int numAntenna, vector<Tag>  antennaId, Tag sBSummaryId); 
00660 
00661 
00662         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00663         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00664 
00665 private:
00666 
00675         ExecBlockTable (ASDM & container);
00676 
00677         ASDM & container;
00678         
00679         bool archiveAsBin; // If true archive binary else archive XML
00680         bool fileAsBin ; // If true file binary else file XML   
00681         
00682         std::string version ; 
00683         
00684         Entity entity;
00685         
00686 
00687         // A map for the autoincrementation algorithm
00688         std::map<std::string,int>  noAutoIncIds;
00689         void autoIncrement(std::string key, ExecBlockRow* x);
00690 
00691 
00695         static std::string itsName;
00696         
00700         static std::vector<std::string> attributesNames;
00701         
00705         static std::vector<std::string> attributesNamesInBin;
00706         
00707 
00711         static bool initAttributesNames(), initAttributesNamesDone ;
00712         
00713 
00717         static std::vector<std::string> key;
00718 
00719 
00729         ExecBlockRow* checkAndAdd(ExecBlockRow* x) ;
00730         
00736          void append(ExecBlockRow* x) ;
00737          
00743          void addWithoutCheckingUnique(ExecBlockRow* x) ;
00744          
00745          
00746 
00747 
00748 
00749 // A data structure to store the pointers on the table's rows.
00750 
00751 // In all cases we maintain a private vector of ExecBlockRow s.
00752    std::vector<ExecBlockRow * > privateRows;
00753    
00754 
00755                         
00756         std::vector<ExecBlockRow *> row;
00757 
00758         
00759         void error() ; //throw(ConversionException);
00760 
00761         
00768         void fromXML(std::string& xmlDoc) ;
00769                 
00770         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00771 
00776         void setFromMIMEFile(const std::string& directory);
00777         /*
00778         void openMIMEFile(const std::string& directory);
00779         */
00780         void setFromXMLFile(const std::string& directory);
00781         
00789         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00790   
00791         
00798          void setFromMIME(const std::string & mimeMsg);
00799         
00803         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00804         
00814           void toFile(std::string directory);
00815           
00819           bool loadInProgress;
00820           void checkPresenceInMemory() {
00821                 if (!presentInMemory && !loadInProgress) {
00822                         loadInProgress = true;
00823                         setFromFile(getContainer().getDirectory());
00824                         presentInMemory = true;
00825                         loadInProgress = false;
00826                 }
00827           }
00836          void setFromFile(const std::string& directory);        
00837  
00838 };
00839 
00840 } // End namespace asdm
00841 
00842 #endif /* ExecBlockTable_CLASS */