casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
WVMCalTable.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 WVMCalTable.h
00032  */
00033  
00034 #ifndef WVMCalTable_CLASS
00035 #define WVMCalTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047         
00048 #include <Temperature.h>
00049         
00050 
00051         
00052 #include <Frequency.h>
00053         
00054 
00055         
00056 #include <ArrayTimeInterval.h>
00057         
00058 
00059 
00060 
00061 
00062         
00063 
00064         
00065 #include "CWVRMethod.h"
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 
00078 
00079 
00080 #include <ConversionException.h>
00081 #include <DuplicateKey.h>
00082 #include <UniquenessViolationException.h>
00083 #include <NoSuchRow.h>
00084 #include <DuplicateKey.h>
00085 
00086 
00087 #ifndef WITHOUT_ACS
00088 #include <asdmIDLC.h>
00089 #endif
00090 
00091 #include <Representable.h>
00092 
00093 namespace asdm {
00094 
00095 //class asdm::ASDM;
00096 //class asdm::WVMCalRow;
00097 
00098 class ASDM;
00099 class WVMCalRow;
00193 class WVMCalTable : public Representable {
00194         friend class ASDM;
00195 
00196 public:
00197 
00198 
00204         static std::vector<std::string> getKeyName();
00205 
00206 
00207         virtual ~WVMCalTable();
00208         
00214         ASDM &getContainer() const;
00215         
00221         unsigned int size() const;
00222         
00230         std::string getName() const;
00231         
00239         static std::string name() ;     
00240         
00245          std::string getVersion() const ;
00246         
00252          static const std::vector<std::string>& getAttributesNames();
00253 
00259          static const std::vector<std::string>& defaultAttributesNamesInBin();
00260          
00264         Entity getEntity() const;
00265 
00270         void setEntity(Entity e);
00271                 
00279         std::string toXML()  ;
00280 
00281 #ifndef WITHOUT_ACS
00282         // Conversion Methods
00288         asdmIDL::WVMCalTableIDL *toIDL() ;
00289 #endif
00290 
00291 #ifndef WITHOUT_ACS
00292 
00298         void fromIDL(asdmIDL::WVMCalTableIDL x) ;
00299 #endif
00300         
00301         //
00302         // ====> Row creation.
00303         //
00304         
00309         WVMCalRow *newRow();
00310         
00311         
00335         WVMCalRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, WVRMethodMod::WVRMethod wvrMethod, vector<Frequency > polyFreqLimits, int numChan, int numPoly, vector<vector<float > > pathCoeff, vector<Temperature > refTemp);
00336         
00337 
00338 
00351          WVMCalRow *newRow(WVMCalRow *row); 
00352 
00353         //
00354         // ====> Append a row to its table.
00355         //
00356  
00357         
00374         WVMCalRow* add(WVMCalRow* x) ; 
00375 
00376  
00377 
00378 
00379 
00380         //
00381         // ====> Methods returning rows.
00382         //
00383                 
00389         std::vector<WVMCalRow *> get() ;
00390         
00397          const std::vector<WVMCalRow *>& get() const ;
00398         
00399 
00410          std::vector <WVMCalRow*> *getByContext(Tag antennaId, Tag spectralWindowId);
00411          
00412 
00413 
00414  
00415         
00429         WVMCalRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval);
00430 
00431                 
00432 
00433 
00434 
00460         WVMCalRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, WVRMethodMod::WVRMethod wvrMethod, vector<Frequency > polyFreqLimits, int numChan, int numPoly, vector<vector<float > > pathCoeff, vector<Temperature > refTemp); 
00461 
00462 
00463         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00464         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00465 
00466 private:
00467 
00476         WVMCalTable (ASDM & container);
00477 
00478         ASDM & container;
00479         
00480         bool archiveAsBin; // If true archive binary else archive XML
00481         bool fileAsBin ; // If true file binary else file XML   
00482         
00483         std::string version ; 
00484         
00485         Entity entity;
00486         
00487 
00488 
00492         static std::string itsName;
00493         
00497         static std::vector<std::string> attributesNames;
00498         
00502         static std::vector<std::string> attributesNamesInBin;
00503         
00504 
00508         static bool initAttributesNames(), initAttributesNamesDone ;
00509         
00510 
00514         static std::vector<std::string> key;
00515 
00516 
00524         WVMCalRow* checkAndAdd(WVMCalRow* x) ;
00525         
00531          void append(WVMCalRow* x) ;
00532          
00538          void addWithoutCheckingUnique(WVMCalRow* x) ;
00539          
00540          
00541 
00542 
00543         
00544         
00552          WVMCalRow * insertByStartTime(WVMCalRow* x, std::vector<WVMCalRow* >& row);
00553           
00554 
00555 
00556 // A data structure to store the pointers on the table's rows.
00557 
00558 // In all cases we maintain a private vector of WVMCalRow s.
00559    std::vector<WVMCalRow * > privateRows;
00560    
00561 
00562         
00563 
00564         
00565         
00566                 
00567                                 
00568         typedef std::vector <WVMCalRow* > TIME_ROWS;
00569         std::map<std::string, TIME_ROWS > context;
00570                 
00575          std::string Key(Tag antennaId, Tag spectralWindowId) ;
00576                  
00577                 
00578         
00579         
00585         void getByKeyNoAutoIncNoTime(std::vector <WVMCalRow*>& vin, std::vector <WVMCalRow*>& vout,  Tag antennaId, Tag spectralWindowId);
00586         
00587 
00588         
00589         void error() ; //throw(ConversionException);
00590 
00591         
00598         void fromXML(std::string& xmlDoc) ;
00599                 
00600         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00601 
00606         void setFromMIMEFile(const std::string& directory);
00607         /*
00608         void openMIMEFile(const std::string& directory);
00609         */
00610         void setFromXMLFile(const std::string& directory);
00611         
00619         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00620   
00621         
00628          void setFromMIME(const std::string & mimeMsg);
00629         
00633         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00634         
00644           void toFile(std::string directory);
00645           
00649           bool loadInProgress;
00650           void checkPresenceInMemory() {
00651                 if (!presentInMemory && !loadInProgress) {
00652                         loadInProgress = true;
00653                         setFromFile(getContainer().getDirectory());
00654                         presentInMemory = true;
00655                         loadInProgress = false;
00656                 }
00657           }
00666          void setFromFile(const std::string& directory);        
00667  
00668 };
00669 
00670 } // End namespace asdm
00671 
00672 #endif /* WVMCalTable_CLASS */