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 
00081 
00082 #include <ConversionException.h>
00083 #include <DuplicateKey.h>
00084 #include <UniquenessViolationException.h>
00085 #include <NoSuchRow.h>
00086 #include <DuplicateKey.h>
00087 
00088 
00089 #ifndef WITHOUT_ACS
00090 #include <asdmIDLC.h>
00091 #endif
00092 
00093 #include <Representable.h>
00094 
00095 #include <pthread.h>
00096 
00097 namespace asdm {
00098 
00099 //class asdm::ASDM;
00100 //class asdm::WVMCalRow;
00101 
00102 class ASDM;
00103 class WVMCalRow;
00211 class WVMCalTable : public Representable {
00212         friend class ASDM;
00213 
00214 public:
00215 
00216 
00222         static const std::vector<std::string>& getKeyName();
00223 
00224 
00225         virtual ~WVMCalTable();
00226         
00232         ASDM &getContainer() const;
00233         
00239         unsigned int size() const;
00240         
00248         std::string getName() const;
00249         
00257         static std::string name() ;     
00258         
00263          std::string getVersion() const ;
00264         
00270          static const std::vector<std::string>& getAttributesNames();
00271 
00277          static const std::vector<std::string>& defaultAttributesNamesInBin();
00278          
00282         Entity getEntity() const;
00283 
00288         void setEntity(Entity e);
00289                 
00297         std::string toXML()  ;
00298 
00299 #ifndef WITHOUT_ACS
00300         // Conversion Methods
00306         asdmIDL::WVMCalTableIDL *toIDL() ;
00307         
00315          void toIDL(asdmIDL::WVMCalTableIDL& x) const;
00316          
00317 #endif
00318 
00319 #ifndef WITHOUT_ACS
00320 
00326         void fromIDL(asdmIDL::WVMCalTableIDL x) ;
00327 #endif
00328         
00329         //
00330         // ====> Row creation.
00331         //
00332         
00337         WVMCalRow *newRow();
00338         
00339         
00367         WVMCalRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, WVRMethodMod::WVRMethod wvrMethod, vector<Frequency > polyFreqLimits, int numInputAntenna, int numChan, int numPoly, vector<vector<vector<float > > > pathCoeff, vector<vector<Temperature > > refTemp, vector<Tag>  inputAntennaId);
00368         
00369 
00370 
00383          WVMCalRow *newRow(WVMCalRow *row); 
00384 
00385         //
00386         // ====> Append a row to its table.
00387         //
00388  
00389         
00406         WVMCalRow* add(WVMCalRow* x) ; 
00407 
00408  
00409 
00410 
00411 
00412         //
00413         // ====> Methods returning rows.
00414         //
00415                 
00421         std::vector<WVMCalRow *> get() ;
00422         
00429          const std::vector<WVMCalRow *>& get() const ;
00430         
00431 
00442          std::vector <WVMCalRow*> *getByContext(Tag antennaId, Tag spectralWindowId);
00443          
00444 
00445 
00446  
00447         
00461         WVMCalRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval);
00462 
00463                 
00464 
00465 
00466 
00496         WVMCalRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, WVRMethodMod::WVRMethod wvrMethod, vector<Frequency > polyFreqLimits, int numInputAntenna, int numChan, int numPoly, vector<vector<vector<float > > > pathCoeff, vector<vector<Temperature > > refTemp, vector<Tag>  inputAntennaId); 
00497 
00498 
00499         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00500         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00501 
00502 private:
00503 
00512         WVMCalTable (ASDM & container);
00513 
00514         ASDM & container;
00515         
00516         bool archiveAsBin; // If true archive binary else archive XML
00517         bool fileAsBin ; // If true file binary else file XML   
00518         
00519         std::string version ; 
00520         
00521         Entity entity;
00522         
00523 
00524 
00532         WVMCalRow* checkAndAdd(WVMCalRow* x, bool skipCheckUniqueness=false) ;
00533         
00539          void append(WVMCalRow* x) ;
00540          
00546          void addWithoutCheckingUnique(WVMCalRow* x) ;
00547          
00548          
00549 
00550 
00551         
00552         
00560          WVMCalRow * insertByStartTime(WVMCalRow* x, std::vector<WVMCalRow* >& row);
00561           
00562 
00563 
00564 // A data structure to store the pointers on the table's rows.
00565 
00566 // In all cases we maintain a private vector of WVMCalRow s.
00567    std::vector<WVMCalRow * > privateRows;
00568    
00569 
00570         
00571 
00572         
00573         
00574                 
00575                                 
00576         typedef std::vector <WVMCalRow* > TIME_ROWS;
00577         std::map<std::string, TIME_ROWS > context;
00578                 
00583          std::string Key(Tag antennaId, Tag spectralWindowId) ;
00584                  
00585                 
00586         
00587         
00593         void getByKeyNoAutoIncNoTime(std::vector <WVMCalRow*>& vin, std::vector <WVMCalRow*>& vout,  Tag antennaId, Tag spectralWindowId);
00594         
00595 
00596         
00597         void error() ; //throw(ConversionException);
00598 
00599         
00606         void fromXML(std::string& xmlDoc) ;
00607                 
00608         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00609 
00614         void setFromMIMEFile(const std::string& directory);
00615         /*
00616         void openMIMEFile(const std::string& directory);
00617         */
00618         void setFromXMLFile(const std::string& directory);
00619         
00627         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00628   
00629         
00636          void setFromMIME(const std::string & mimeMsg);
00637         
00641         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00642         
00652           void toFile(std::string directory);
00653           
00657           bool loadInProgress;
00658           void checkPresenceInMemory() {
00659                 if (!presentInMemory && !loadInProgress) {
00660                         loadInProgress = true;
00661                         setFromFile(getContainer().getDirectory());
00662                         presentInMemory = true;
00663                         loadInProgress = false;
00664                 }
00665           }
00674          void setFromFile(const std::string& directory);        
00675  
00676 };
00677 
00678 } // End namespace asdm
00679 
00680 #endif /* WVMCalTable_CLASS */