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 #include <pthread.h>
00134 
00135 namespace asdm {
00136 
00137 //class asdm::ASDM;
00138 //class asdm::ExecBlockRow;
00139 
00140 class ASDM;
00141 class ExecBlockRow;
00374 class ExecBlockTable : public Representable {
00375         friend class ASDM;
00376 
00377 public:
00378 
00379 
00385         static const std::vector<std::string>& getKeyName();
00386 
00387 
00388         virtual ~ExecBlockTable();
00389         
00395         ASDM &getContainer() const;
00396         
00402         unsigned int size() const;
00403         
00411         std::string getName() const;
00412         
00420         static std::string name() ;     
00421         
00426          std::string getVersion() const ;
00427         
00433          static const std::vector<std::string>& getAttributesNames();
00434 
00440          static const std::vector<std::string>& defaultAttributesNamesInBin();
00441          
00445         Entity getEntity() const;
00446 
00451         void setEntity(Entity e);
00452                 
00460         std::string toXML()  ;
00461 
00462 #ifndef WITHOUT_ACS
00463         // Conversion Methods
00469         asdmIDL::ExecBlockTableIDL *toIDL() ;
00470         
00478          void toIDL(asdmIDL::ExecBlockTableIDL& x) const;
00479          
00480 #endif
00481 
00482 #ifndef WITHOUT_ACS
00483 
00489         void fromIDL(asdmIDL::ExecBlockTableIDL x) ;
00490 #endif
00491         
00492         //
00493         // ====> Row creation.
00494         //
00495         
00500         ExecBlockRow *newRow();
00501         
00502         
00548         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);
00549         
00550 
00551 
00564          ExecBlockRow *newRow(ExecBlockRow *row); 
00565 
00566         //
00567         // ====> Append a row to its table.
00568         //
00569 
00570         
00571         
00572         
00582          ExecBlockRow* add(ExecBlockRow* x) ;
00583 
00584 
00585 
00586         //
00587         // ====> Methods returning rows.
00588         //
00589                 
00595         std::vector<ExecBlockRow *> get() ;
00596         
00603          const std::vector<ExecBlockRow *>& get() const ;
00604         
00605 
00606 
00607  
00608         
00618         ExecBlockRow* getRowByKey(Tag execBlockId);
00619 
00620                 
00621 
00622 
00623 
00671         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); 
00672 
00673 
00674         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00675         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00676 
00677 private:
00678 
00687         ExecBlockTable (ASDM & container);
00688 
00689         ASDM & container;
00690         
00691         bool archiveAsBin; // If true archive binary else archive XML
00692         bool fileAsBin ; // If true file binary else file XML   
00693         
00694         std::string version ; 
00695         
00696         Entity entity;
00697         
00698 
00699         // A map for the autoincrementation algorithm
00700         std::map<std::string,int>  noAutoIncIds;
00701         void autoIncrement(std::string key, ExecBlockRow* x);
00702 
00703 
00713         ExecBlockRow* checkAndAdd(ExecBlockRow* x, bool skipCheckUniqueness=false) ;
00714         
00720          void append(ExecBlockRow* x) ;
00721          
00727          void addWithoutCheckingUnique(ExecBlockRow* x) ;
00728          
00729          
00730 
00731 
00732 
00733 // A data structure to store the pointers on the table's rows.
00734 
00735 // In all cases we maintain a private vector of ExecBlockRow s.
00736    std::vector<ExecBlockRow * > privateRows;
00737    
00738 
00739                         
00740         std::vector<ExecBlockRow *> row;
00741 
00742         
00743         void error() ; //throw(ConversionException);
00744 
00745         
00752         void fromXML(std::string& xmlDoc) ;
00753                 
00754         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00755 
00760         void setFromMIMEFile(const std::string& directory);
00761         /*
00762         void openMIMEFile(const std::string& directory);
00763         */
00764         void setFromXMLFile(const std::string& directory);
00765         
00773         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00774   
00775         
00782          void setFromMIME(const std::string & mimeMsg);
00783         
00787         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00788         
00798           void toFile(std::string directory);
00799           
00803           bool loadInProgress;
00804           void checkPresenceInMemory() {
00805                 if (!presentInMemory && !loadInProgress) {
00806                         loadInProgress = true;
00807                         setFromFile(getContainer().getDirectory());
00808                         presentInMemory = true;
00809                         loadInProgress = false;
00810                 }
00811           }
00820          void setFromFile(const std::string& directory);        
00821  
00822 };
00823 
00824 } // End namespace asdm
00825 
00826 #endif /* ExecBlockTable_CLASS */