casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DelayModelTable.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 DelayModelTable.h
00032  */
00033  
00034 #ifndef DelayModelTable_CLASS
00035 #define DelayModelTable_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 <Frequency.h>
00053         
00054 
00055         
00056 #include <ArrayTimeInterval.h>
00057         
00058 
00059 
00060 
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 #include "CPolarizationType.h"
00106         
00107 
00108         
00109 
00110         
00111 
00112         
00113 
00114         
00115 
00116         
00117 
00118         
00119 
00120 
00121 
00122 #include <ConversionException.h>
00123 #include <DuplicateKey.h>
00124 #include <UniquenessViolationException.h>
00125 #include <NoSuchRow.h>
00126 #include <DuplicateKey.h>
00127 
00128 
00129 #ifndef WITHOUT_ACS
00130 #include <asdmIDLC.h>
00131 #endif
00132 
00133 #include <Representable.h>
00134 
00135 namespace asdm {
00136 
00137 //class asdm::ASDM;
00138 //class asdm::DelayModelRow;
00139 
00140 class ASDM;
00141 class DelayModelRow;
00392 class DelayModelTable : public Representable {
00393         friend class ASDM;
00394 
00395 public:
00396 
00397 
00403         static std::vector<std::string> getKeyName();
00404 
00405 
00406         virtual ~DelayModelTable();
00407         
00413         ASDM &getContainer() const;
00414         
00420         unsigned int size() const;
00421         
00429         std::string getName() const;
00430         
00438         static std::string name() ;     
00439         
00444          std::string getVersion() const ;
00445         
00451          static const std::vector<std::string>& getAttributesNames();
00452 
00458          static const std::vector<std::string>& defaultAttributesNamesInBin();
00459          
00463         Entity getEntity() const;
00464 
00469         void setEntity(Entity e);
00470                 
00478         std::string toXML()  ;
00479 
00480 #ifndef WITHOUT_ACS
00481         // Conversion Methods
00487         asdmIDL::DelayModelTableIDL *toIDL() ;
00488 #endif
00489 
00490 #ifndef WITHOUT_ACS
00491 
00497         void fromIDL(asdmIDL::DelayModelTableIDL x) ;
00498 #endif
00499         
00500         //
00501         // ====> Row creation.
00502         //
00503         
00508         DelayModelRow *newRow();
00509         
00510         
00534         DelayModelRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int numPoly, vector<double > phaseDelay, vector<double > phaseDelayRate, vector<double > groupDelay, vector<double > groupDelayRate, Tag fieldId);
00535         
00536 
00537 
00550          DelayModelRow *newRow(DelayModelRow *row); 
00551 
00552         //
00553         // ====> Append a row to its table.
00554         //
00555  
00556         
00573         DelayModelRow* add(DelayModelRow* x) ; 
00574 
00575  
00576 
00577 
00578 
00579         //
00580         // ====> Methods returning rows.
00581         //
00582                 
00588         std::vector<DelayModelRow *> get() ;
00589         
00596          const std::vector<DelayModelRow *>& get() const ;
00597         
00598 
00609          std::vector <DelayModelRow*> *getByContext(Tag antennaId, Tag spectralWindowId);
00610          
00611 
00612 
00613  
00614         
00628         DelayModelRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval);
00629 
00630                 
00631 
00632 
00633 
00659         DelayModelRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int numPoly, vector<double > phaseDelay, vector<double > phaseDelayRate, vector<double > groupDelay, vector<double > groupDelayRate, Tag fieldId); 
00660 
00661 
00662         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00663         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00664 
00665 private:
00666 
00675         DelayModelTable (ASDM & container);
00676 
00677         ASDM & container;
00678         
00679         bool archiveAsBin; // If true archive binary else archive XML
00680         bool fileAsBin ; // If true file binary else file XML   
00681         
00682         std::string version ; 
00683         
00684         Entity entity;
00685         
00686 
00687 
00691         static std::string itsName;
00692         
00696         static std::vector<std::string> attributesNames;
00697         
00701         static std::vector<std::string> attributesNamesInBin;
00702         
00703 
00707         static bool initAttributesNames(), initAttributesNamesDone ;
00708         
00709 
00713         static std::vector<std::string> key;
00714 
00715 
00723         DelayModelRow* checkAndAdd(DelayModelRow* x) ;
00724         
00730          void append(DelayModelRow* x) ;
00731          
00737          void addWithoutCheckingUnique(DelayModelRow* x) ;
00738          
00739          
00740 
00741 
00742         
00743         
00751          DelayModelRow * insertByStartTime(DelayModelRow* x, std::vector<DelayModelRow* >& row);
00752           
00753 
00754 
00755 // A data structure to store the pointers on the table's rows.
00756 
00757 // In all cases we maintain a private vector of DelayModelRow s.
00758    std::vector<DelayModelRow * > privateRows;
00759    
00760 
00761         
00762 
00763         
00764         
00765                 
00766                                 
00767         typedef std::vector <DelayModelRow* > TIME_ROWS;
00768         std::map<std::string, TIME_ROWS > context;
00769                 
00774          std::string Key(Tag antennaId, Tag spectralWindowId) ;
00775                  
00776                 
00777         
00778         
00784         void getByKeyNoAutoIncNoTime(std::vector <DelayModelRow*>& vin, std::vector <DelayModelRow*>& vout,  Tag antennaId, Tag spectralWindowId);
00785         
00786 
00787         
00788         void error() ; //throw(ConversionException);
00789 
00790         
00797         void fromXML(std::string& xmlDoc) ;
00798                 
00799         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00800 
00805         void setFromMIMEFile(const std::string& directory);
00806         /*
00807         void openMIMEFile(const std::string& directory);
00808         */
00809         void setFromXMLFile(const std::string& directory);
00810         
00818         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00819   
00820         
00827          void setFromMIME(const std::string & mimeMsg);
00828         
00832         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00833         
00843           void toFile(std::string directory);
00844           
00848           bool loadInProgress;
00849           void checkPresenceInMemory() {
00850                 if (!presentInMemory && !loadInProgress) {
00851                         loadInProgress = true;
00852                         setFromFile(getContainer().getDirectory());
00853                         presentInMemory = true;
00854                         loadInProgress = false;
00855                 }
00856           }
00865          void setFromFile(const std::string& directory);        
00866  
00867 };
00868 
00869 } // End namespace asdm
00870 
00871 #endif /* DelayModelTable_CLASS */