casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ScanTable.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 ScanTable.h
00032  */
00033  
00034 #ifndef ScanTable_CLASS
00035 #define ScanTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <Tag.h>
00049         
00050 
00051 
00052 
00053 
00054         
00055 
00056         
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 #include "CScanIntent.h"
00066         
00067 
00068         
00069 #include "CCalDataOrigin.h"
00070         
00071 
00072         
00073 
00074         
00075 #include "CCalibrationFunction.h"
00076         
00077 
00078         
00079 #include "CCalibrationSet.h"
00080         
00081 
00082         
00083 #include "CAntennaMotionPattern.h"
00084         
00085 
00086         
00087 
00088         
00089 
00090         
00091 
00092 
00093 
00094 #include <ConversionException.h>
00095 #include <DuplicateKey.h>
00096 #include <UniquenessViolationException.h>
00097 #include <NoSuchRow.h>
00098 #include <DuplicateKey.h>
00099 
00100 
00101 #ifndef WITHOUT_ACS
00102 #include <asdmIDLC.h>
00103 #endif
00104 
00105 #include <Representable.h>
00106 
00107 #include <pthread.h>
00108 
00109 namespace asdm {
00110 
00111 //class asdm::ASDM;
00112 //class asdm::ScanRow;
00113 
00114 class ASDM;
00115 class ScanRow;
00252 class ScanTable : public Representable {
00253         friend class ASDM;
00254 
00255 public:
00256 
00257 
00263         static const std::vector<std::string>& getKeyName();
00264 
00265 
00266         virtual ~ScanTable();
00267         
00273         ASDM &getContainer() const;
00274         
00280         unsigned int size() const;
00281         
00289         std::string getName() const;
00290         
00298         static std::string name() ;     
00299         
00304          std::string getVersion() const ;
00305         
00311          static const std::vector<std::string>& getAttributesNames();
00312 
00318          static const std::vector<std::string>& defaultAttributesNamesInBin();
00319          
00323         Entity getEntity() const;
00324 
00329         void setEntity(Entity e);
00330                 
00338         std::string toXML()  ;
00339 
00340 #ifndef WITHOUT_ACS
00341         // Conversion Methods
00347         asdmIDL::ScanTableIDL *toIDL() ;
00348         
00356          void toIDL(asdmIDL::ScanTableIDL& x) const;
00357          
00358 #endif
00359 
00360 #ifndef WITHOUT_ACS
00361 
00367         void fromIDL(asdmIDL::ScanTableIDL x) ;
00368 #endif
00369         
00370         //
00371         // ====> Row creation.
00372         //
00373         
00378         ScanRow *newRow();
00379         
00380         
00404         ScanRow *newRow(Tag execBlockId, int scanNumber, ArrayTime startTime, ArrayTime endTime, int numIntent, int numSubscan, vector<ScanIntentMod::ScanIntent > scanIntent, vector<CalDataOriginMod::CalDataOrigin > calDataType, vector<bool > calibrationOnLine);
00405         
00406 
00407 
00420          ScanRow *newRow(ScanRow *row); 
00421 
00422         //
00423         // ====> Append a row to its table.
00424         //
00425  
00426         
00439         ScanRow* add(ScanRow* x) ; 
00440 
00441  
00442 
00443 
00444 
00445         //
00446         // ====> Methods returning rows.
00447         //
00448                 
00454         std::vector<ScanRow *> get() ;
00455         
00462          const std::vector<ScanRow *>& get() const ;
00463         
00464 
00465 
00466  
00467         
00479         ScanRow* getRowByKey(Tag execBlockId, int scanNumber);
00480 
00481                 
00482 
00483 
00484 
00510         ScanRow* lookup(Tag execBlockId, int scanNumber, ArrayTime startTime, ArrayTime endTime, int numIntent, int numSubscan, vector<ScanIntentMod::ScanIntent > scanIntent, vector<CalDataOriginMod::CalDataOrigin > calDataType, vector<bool > calibrationOnLine); 
00511 
00512 
00513         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00514         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00515 
00516 private:
00517 
00526         ScanTable (ASDM & container);
00527 
00528         ASDM & container;
00529         
00530         bool archiveAsBin; // If true archive binary else archive XML
00531         bool fileAsBin ; // If true file binary else file XML   
00532         
00533         std::string version ; 
00534         
00535         Entity entity;
00536         
00537 
00538 
00546         ScanRow* checkAndAdd(ScanRow* x, bool skipCheckUniqueness=false) ;
00547         
00553          void append(ScanRow* x) ;
00554          
00560          void addWithoutCheckingUnique(ScanRow* x) ;
00561          
00562          
00563 
00564 
00565 
00566 // A data structure to store the pointers on the table's rows.
00567 
00568 // In all cases we maintain a private vector of ScanRow s.
00569    std::vector<ScanRow * > privateRows;
00570    
00571 
00572                         
00573         std::vector<ScanRow *> row;
00574 
00575         
00576         void error() ; //throw(ConversionException);
00577 
00578         
00585         void fromXML(std::string& xmlDoc) ;
00586                 
00587         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00588 
00593         void setFromMIMEFile(const std::string& directory);
00594         /*
00595         void openMIMEFile(const std::string& directory);
00596         */
00597         void setFromXMLFile(const std::string& directory);
00598         
00606         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00607   
00608         
00615          void setFromMIME(const std::string & mimeMsg);
00616         
00620         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00621         
00631           void toFile(std::string directory);
00632           
00636           bool loadInProgress;
00637           void checkPresenceInMemory() {
00638                 if (!presentInMemory && !loadInProgress) {
00639                         loadInProgress = true;
00640                         setFromFile(getContainer().getDirectory());
00641                         presentInMemory = true;
00642                         loadInProgress = false;
00643                 }
00644           }
00653          void setFromFile(const std::string& directory);        
00654  
00655 };
00656 
00657 } // End namespace asdm
00658 
00659 #endif /* ScanTable_CLASS */