casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalCurveTable.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 CalCurveTable.h
00032  */
00033  
00034 #ifndef CalCurveTable_CLASS
00035 #define CalCurveTable_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 
00057 
00058         
00059 #include "CAtmPhaseCorrection.h"
00060         
00061 
00062         
00063 #include "CCalCurveType.h"
00064         
00065 
00066         
00067 #include "CReceiverBand.h"
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 
00078         
00079 
00080         
00081 
00082         
00083 
00084         
00085 
00086         
00087 #include "CPolarizationType.h"
00088         
00089 
00090         
00091 
00092         
00093 
00094         
00095 
00096         
00097 
00098 
00099 
00100 #include <ConversionException.h>
00101 #include <DuplicateKey.h>
00102 #include <UniquenessViolationException.h>
00103 #include <NoSuchRow.h>
00104 #include <DuplicateKey.h>
00105 
00106 
00107 #ifndef WITHOUT_ACS
00108 #include <asdmIDLC.h>
00109 #endif
00110 
00111 #include <Representable.h>
00112 
00113 namespace asdm {
00114 
00115 //class asdm::ASDM;
00116 //class asdm::CalCurveRow;
00117 
00118 class ASDM;
00119 class CalCurveRow;
00283 class CalCurveTable : public Representable {
00284         friend class ASDM;
00285 
00286 public:
00287 
00288 
00294         static std::vector<std::string> getKeyName();
00295 
00296 
00297         virtual ~CalCurveTable();
00298         
00304         ASDM &getContainer() const;
00305         
00311         unsigned int size() const;
00312         
00320         std::string getName() const;
00321         
00329         static std::string name() ;     
00330         
00335          std::string getVersion() const ;
00336         
00342          static const std::vector<std::string>& getAttributesNames();
00343 
00349          static const std::vector<std::string>& defaultAttributesNamesInBin();
00350          
00354         Entity getEntity() const;
00355 
00360         void setEntity(Entity e);
00361                 
00369         std::string toXML()  ;
00370 
00371 #ifndef WITHOUT_ACS
00372         // Conversion Methods
00378         asdmIDL::CalCurveTableIDL *toIDL() ;
00379 #endif
00380 
00381 #ifndef WITHOUT_ACS
00382 
00388         void fromIDL(asdmIDL::CalCurveTableIDL x) ;
00389 #endif
00390         
00391         //
00392         // ====> Row creation.
00393         //
00394         
00399         CalCurveRow *newRow();
00400         
00401         
00439         CalCurveRow *newRow(AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, CalCurveTypeMod::CalCurveType typeCurve, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, vector<Frequency > frequencyRange, int numAntenna, int numPoly, int numReceptor, vector<string > antennaNames, string refAntennaName, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, vector<vector<vector<float > > > curve, vector<double > reducedChiSquared);
00440         
00441 
00442 
00455          CalCurveRow *newRow(CalCurveRow *row); 
00456 
00457         //
00458         // ====> Append a row to its table.
00459         //
00460  
00461         
00474         CalCurveRow* add(CalCurveRow* x) ; 
00475 
00476  
00477 
00478 
00479 
00480         //
00481         // ====> Methods returning rows.
00482         //
00483                 
00489         std::vector<CalCurveRow *> get() ;
00490         
00497          const std::vector<CalCurveRow *>& get() const ;
00498         
00499 
00500 
00501  
00502         
00520         CalCurveRow* getRowByKey(AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, CalCurveTypeMod::CalCurveType typeCurve, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId);
00521 
00522                 
00523 
00524 
00525 
00565         CalCurveRow* lookup(AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, CalCurveTypeMod::CalCurveType typeCurve, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, vector<Frequency > frequencyRange, int numAntenna, int numPoly, int numReceptor, vector<string > antennaNames, string refAntennaName, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, vector<vector<vector<float > > > curve, vector<double > reducedChiSquared); 
00566 
00567 
00568         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00569         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00570 
00571 private:
00572 
00581         CalCurveTable (ASDM & container);
00582 
00583         ASDM & container;
00584         
00585         bool archiveAsBin; // If true archive binary else archive XML
00586         bool fileAsBin ; // If true file binary else file XML   
00587         
00588         std::string version ; 
00589         
00590         Entity entity;
00591         
00592 
00593 
00597         static std::string itsName;
00598         
00602         static std::vector<std::string> attributesNames;
00603         
00607         static std::vector<std::string> attributesNamesInBin;
00608         
00609 
00613         static bool initAttributesNames(), initAttributesNamesDone ;
00614         
00615 
00619         static std::vector<std::string> key;
00620 
00621 
00629         CalCurveRow* checkAndAdd(CalCurveRow* x) ;
00630         
00636          void append(CalCurveRow* x) ;
00637          
00643          void addWithoutCheckingUnique(CalCurveRow* x) ;
00644          
00645          
00646 
00647 
00648 
00649 // A data structure to store the pointers on the table's rows.
00650 
00651 // In all cases we maintain a private vector of CalCurveRow s.
00652    std::vector<CalCurveRow * > privateRows;
00653    
00654 
00655                         
00656         std::vector<CalCurveRow *> row;
00657 
00658         
00659         void error() ; //throw(ConversionException);
00660 
00661         
00668         void fromXML(std::string& xmlDoc) ;
00669                 
00670         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00671 
00676         void setFromMIMEFile(const std::string& directory);
00677         /*
00678         void openMIMEFile(const std::string& directory);
00679         */
00680         void setFromXMLFile(const std::string& directory);
00681         
00689         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00690   
00691         
00698          void setFromMIME(const std::string & mimeMsg);
00699         
00703         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00704         
00714           void toFile(std::string directory);
00715           
00719           bool loadInProgress;
00720           void checkPresenceInMemory() {
00721                 if (!presentInMemory && !loadInProgress) {
00722                         loadInProgress = true;
00723                         setFromFile(getContainer().getDirectory());
00724                         presentInMemory = true;
00725                         loadInProgress = false;
00726                 }
00727           }
00736          void setFromFile(const std::string& directory);        
00737  
00738 };
00739 
00740 } // End namespace asdm
00741 
00742 #endif /* CalCurveTable_CLASS */