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 #include <pthread.h>
00114 
00115 namespace asdm {
00116 
00117 //class asdm::ASDM;
00118 //class asdm::CalCurveRow;
00119 
00120 class ASDM;
00121 class CalCurveRow;
00285 class CalCurveTable : public Representable {
00286         friend class ASDM;
00287 
00288 public:
00289 
00290 
00296         static const std::vector<std::string>& getKeyName();
00297 
00298 
00299         virtual ~CalCurveTable();
00300         
00306         ASDM &getContainer() const;
00307         
00313         unsigned int size() const;
00314         
00322         std::string getName() const;
00323         
00331         static std::string name() ;     
00332         
00337          std::string getVersion() const ;
00338         
00344          static const std::vector<std::string>& getAttributesNames();
00345 
00351          static const std::vector<std::string>& defaultAttributesNamesInBin();
00352          
00356         Entity getEntity() const;
00357 
00362         void setEntity(Entity e);
00363                 
00371         std::string toXML()  ;
00372 
00373 #ifndef WITHOUT_ACS
00374         // Conversion Methods
00380         asdmIDL::CalCurveTableIDL *toIDL() ;
00381         
00389          void toIDL(asdmIDL::CalCurveTableIDL& x) const;
00390          
00391 #endif
00392 
00393 #ifndef WITHOUT_ACS
00394 
00400         void fromIDL(asdmIDL::CalCurveTableIDL x) ;
00401 #endif
00402         
00403         //
00404         // ====> Row creation.
00405         //
00406         
00411         CalCurveRow *newRow();
00412         
00413         
00451         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);
00452         
00453 
00454 
00467          CalCurveRow *newRow(CalCurveRow *row); 
00468 
00469         //
00470         // ====> Append a row to its table.
00471         //
00472  
00473         
00486         CalCurveRow* add(CalCurveRow* x) ; 
00487 
00488  
00489 
00490 
00491 
00492         //
00493         // ====> Methods returning rows.
00494         //
00495                 
00501         std::vector<CalCurveRow *> get() ;
00502         
00509          const std::vector<CalCurveRow *>& get() const ;
00510         
00511 
00512 
00513  
00514         
00532         CalCurveRow* getRowByKey(AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, CalCurveTypeMod::CalCurveType typeCurve, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId);
00533 
00534                 
00535 
00536 
00537 
00577         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); 
00578 
00579 
00580         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00581         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00582 
00583 private:
00584 
00593         CalCurveTable (ASDM & container);
00594 
00595         ASDM & container;
00596         
00597         bool archiveAsBin; // If true archive binary else archive XML
00598         bool fileAsBin ; // If true file binary else file XML   
00599         
00600         std::string version ; 
00601         
00602         Entity entity;
00603         
00604 
00605 
00613         CalCurveRow* checkAndAdd(CalCurveRow* x, bool skipCheckUniqueness=false) ;
00614         
00620          void append(CalCurveRow* x) ;
00621          
00627          void addWithoutCheckingUnique(CalCurveRow* x) ;
00628          
00629          
00630 
00631 
00632 
00633 // A data structure to store the pointers on the table's rows.
00634 
00635 // In all cases we maintain a private vector of CalCurveRow s.
00636    std::vector<CalCurveRow * > privateRows;
00637    
00638 
00639                         
00640         std::vector<CalCurveRow *> row;
00641 
00642         
00643         void error() ; //throw(ConversionException);
00644 
00645         
00652         void fromXML(std::string& xmlDoc) ;
00653                 
00654         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00655 
00660         void setFromMIMEFile(const std::string& directory);
00661         /*
00662         void openMIMEFile(const std::string& directory);
00663         */
00664         void setFromXMLFile(const std::string& directory);
00665         
00673         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00674   
00675         
00682          void setFromMIME(const std::string & mimeMsg);
00683         
00687         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00688         
00698           void toFile(std::string directory);
00699           
00703           bool loadInProgress;
00704           void checkPresenceInMemory() {
00705                 if (!presentInMemory && !loadInProgress) {
00706                         loadInProgress = true;
00707                         setFromFile(getContainer().getDirectory());
00708                         presentInMemory = true;
00709                         loadInProgress = false;
00710                 }
00711           }
00720          void setFromFile(const std::string& directory);        
00721  
00722 };
00723 
00724 } // End namespace asdm
00725 
00726 #endif /* CalCurveTable_CLASS */