casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalWVRTable.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 CalWVRTable.h
00032  */
00033  
00034 #ifndef CalWVRTable_CLASS
00035 #define CalWVRTable_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 #include <Length.h>
00053         
00054 
00055         
00056 #include <Temperature.h>
00057         
00058 
00059         
00060 #include <Frequency.h>
00061         
00062 
00063 
00064 
00065 
00066         
00067 
00068         
00069 
00070         
00071 #include "CWVRMethod.h"
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 #include <ConversionException.h>
00103 #include <DuplicateKey.h>
00104 #include <UniquenessViolationException.h>
00105 #include <NoSuchRow.h>
00106 #include <DuplicateKey.h>
00107 
00108 
00109 #ifndef WITHOUT_ACS
00110 #include <asdmIDLC.h>
00111 #endif
00112 
00113 #include <Representable.h>
00114 
00115 namespace asdm {
00116 
00117 //class asdm::ASDM;
00118 //class asdm::CalWVRRow;
00119 
00120 class ASDM;
00121 class CalWVRRow;
00278 class CalWVRTable : public Representable {
00279         friend class ASDM;
00280 
00281 public:
00282 
00283 
00289         static std::vector<std::string> getKeyName();
00290 
00291 
00292         virtual ~CalWVRTable();
00293         
00299         ASDM &getContainer() const;
00300         
00306         unsigned int size() const;
00307         
00315         std::string getName() const;
00316         
00324         static std::string name() ;     
00325         
00330          std::string getVersion() const ;
00331         
00337          static const std::vector<std::string>& getAttributesNames();
00338 
00344          static const std::vector<std::string>& defaultAttributesNamesInBin();
00345          
00349         Entity getEntity() const;
00350 
00355         void setEntity(Entity e);
00356                 
00364         std::string toXML()  ;
00365 
00366 #ifndef WITHOUT_ACS
00367         // Conversion Methods
00373         asdmIDL::CalWVRTableIDL *toIDL() ;
00374 #endif
00375 
00376 #ifndef WITHOUT_ACS
00377 
00383         void fromIDL(asdmIDL::CalWVRTableIDL x) ;
00384 #endif
00385         
00386         //
00387         // ====> Row creation.
00388         //
00389         
00394         CalWVRRow *newRow();
00395         
00396         
00438         CalWVRRow *newRow(string antennaName, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, WVRMethodMod::WVRMethod wvrMethod, int numInputAntennas, vector<string > inputAntennaNames, int numChan, vector<Frequency > chanFreq, vector<Frequency > chanWidth, vector<vector<Temperature > > refTemp, int numPoly, vector<vector<vector<float > > > pathCoeff, vector<Frequency > polyFreqLimits, vector<float > wetPath, vector<float > dryPath, Length water);
00439         
00440 
00441 
00454          CalWVRRow *newRow(CalWVRRow *row); 
00455 
00456         //
00457         // ====> Append a row to its table.
00458         //
00459  
00460         
00473         CalWVRRow* add(CalWVRRow* x) ; 
00474 
00475  
00476 
00477 
00478 
00479         //
00480         // ====> Methods returning rows.
00481         //
00482                 
00488         std::vector<CalWVRRow *> get() ;
00489         
00496          const std::vector<CalWVRRow *>& get() const ;
00497         
00498 
00499 
00500  
00501         
00515         CalWVRRow* getRowByKey(string antennaName, Tag calDataId, Tag calReductionId);
00516 
00517                 
00518 
00519 
00520 
00564         CalWVRRow* lookup(string antennaName, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, WVRMethodMod::WVRMethod wvrMethod, int numInputAntennas, vector<string > inputAntennaNames, int numChan, vector<Frequency > chanFreq, vector<Frequency > chanWidth, vector<vector<Temperature > > refTemp, int numPoly, vector<vector<vector<float > > > pathCoeff, vector<Frequency > polyFreqLimits, vector<float > wetPath, vector<float > dryPath, Length water); 
00565 
00566 
00567         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00568         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00569 
00570 private:
00571 
00580         CalWVRTable (ASDM & container);
00581 
00582         ASDM & container;
00583         
00584         bool archiveAsBin; // If true archive binary else archive XML
00585         bool fileAsBin ; // If true file binary else file XML   
00586         
00587         std::string version ; 
00588         
00589         Entity entity;
00590         
00591 
00592 
00596         static std::string itsName;
00597         
00601         static std::vector<std::string> attributesNames;
00602         
00606         static std::vector<std::string> attributesNamesInBin;
00607         
00608 
00612         static bool initAttributesNames(), initAttributesNamesDone ;
00613         
00614 
00618         static std::vector<std::string> key;
00619 
00620 
00628         CalWVRRow* checkAndAdd(CalWVRRow* x) ;
00629         
00635          void append(CalWVRRow* x) ;
00636          
00642          void addWithoutCheckingUnique(CalWVRRow* x) ;
00643          
00644          
00645 
00646 
00647 
00648 // A data structure to store the pointers on the table's rows.
00649 
00650 // In all cases we maintain a private vector of CalWVRRow s.
00651    std::vector<CalWVRRow * > privateRows;
00652    
00653 
00654                         
00655         std::vector<CalWVRRow *> row;
00656 
00657         
00658         void error() ; //throw(ConversionException);
00659 
00660         
00667         void fromXML(std::string& xmlDoc) ;
00668                 
00669         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00670 
00675         void setFromMIMEFile(const std::string& directory);
00676         /*
00677         void openMIMEFile(const std::string& directory);
00678         */
00679         void setFromXMLFile(const std::string& directory);
00680         
00688         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00689   
00690         
00697          void setFromMIME(const std::string & mimeMsg);
00698         
00702         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00703         
00713           void toFile(std::string directory);
00714           
00718           bool loadInProgress;
00719           void checkPresenceInMemory() {
00720                 if (!presentInMemory && !loadInProgress) {
00721                         loadInProgress = true;
00722                         setFromFile(getContainer().getDirectory());
00723                         presentInMemory = true;
00724                         loadInProgress = false;
00725                 }
00726           }
00735          void setFromFile(const std::string& directory);        
00736  
00737 };
00738 
00739 } // End namespace asdm
00740 
00741 #endif /* CalWVRTable_CLASS */