casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalFluxTable.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 CalFluxTable.h
00032  */
00033  
00034 #ifndef CalFluxTable_CLASS
00035 #define CalFluxTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <Angle.h>
00049         
00050 
00051         
00052 #include <Tag.h>
00053         
00054 
00055         
00056 #include <Frequency.h>
00057         
00058 
00059 
00060 
00061 
00062         
00063 
00064         
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 #include "CFluxCalibrationMethod.h"
00076         
00077 
00078         
00079 
00080         
00081 
00082         
00083 #include "CStokesParameter.h"
00084         
00085 
00086         
00087 
00088         
00089 #include "CDirectionReferenceCode.h"
00090         
00091 
00092         
00093 
00094         
00095 
00096         
00097 
00098         
00099 
00100         
00101 
00102         
00103 #include "CSourceModel.h"
00104         
00105 
00106 
00107 
00108 #include <ConversionException.h>
00109 #include <DuplicateKey.h>
00110 #include <UniquenessViolationException.h>
00111 #include <NoSuchRow.h>
00112 #include <DuplicateKey.h>
00113 
00114 
00115 #ifndef WITHOUT_ACS
00116 #include <asdmIDLC.h>
00117 #endif
00118 
00119 #include <Representable.h>
00120 
00121 #include <pthread.h>
00122 
00123 namespace asdm {
00124 
00125 //class asdm::ASDM;
00126 //class asdm::CalFluxRow;
00127 
00128 class ASDM;
00129 class CalFluxRow;
00303 class CalFluxTable : public Representable {
00304         friend class ASDM;
00305 
00306 public:
00307 
00308 
00314         static const std::vector<std::string>& getKeyName();
00315 
00316 
00317         virtual ~CalFluxTable();
00318         
00324         ASDM &getContainer() const;
00325         
00331         unsigned int size() const;
00332         
00340         std::string getName() const;
00341         
00349         static std::string name() ;     
00350         
00355          std::string getVersion() const ;
00356         
00362          static const std::vector<std::string>& getAttributesNames();
00363 
00369          static const std::vector<std::string>& defaultAttributesNamesInBin();
00370          
00374         Entity getEntity() const;
00375 
00380         void setEntity(Entity e);
00381                 
00389         std::string toXML()  ;
00390 
00391 #ifndef WITHOUT_ACS
00392         // Conversion Methods
00398         asdmIDL::CalFluxTableIDL *toIDL() ;
00399         
00407          void toIDL(asdmIDL::CalFluxTableIDL& x) const;
00408          
00409 #endif
00410 
00411 #ifndef WITHOUT_ACS
00412 
00418         void fromIDL(asdmIDL::CalFluxTableIDL x) ;
00419 #endif
00420         
00421         //
00422         // ====> Row creation.
00423         //
00424         
00429         CalFluxRow *newRow();
00430         
00431         
00461         CalFluxRow *newRow(string sourceName, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, int numFrequencyRanges, int numStokes, vector<vector<Frequency > > frequencyRanges, FluxCalibrationMethodMod::FluxCalibrationMethod fluxMethod, vector<vector<double > > flux, vector<vector<double > > fluxError, vector<StokesParameterMod::StokesParameter > stokes);
00462         
00463 
00464 
00477          CalFluxRow *newRow(CalFluxRow *row); 
00478 
00479         //
00480         // ====> Append a row to its table.
00481         //
00482  
00483         
00496         CalFluxRow* add(CalFluxRow* x) ; 
00497 
00498  
00499 
00500 
00501 
00502         //
00503         // ====> Methods returning rows.
00504         //
00505                 
00511         std::vector<CalFluxRow *> get() ;
00512         
00519          const std::vector<CalFluxRow *>& get() const ;
00520         
00521 
00522 
00523  
00524         
00538         CalFluxRow* getRowByKey(string sourceName, Tag calDataId, Tag calReductionId);
00539 
00540                 
00541 
00542 
00543 
00575         CalFluxRow* lookup(string sourceName, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, int numFrequencyRanges, int numStokes, vector<vector<Frequency > > frequencyRanges, FluxCalibrationMethodMod::FluxCalibrationMethod fluxMethod, vector<vector<double > > flux, vector<vector<double > > fluxError, vector<StokesParameterMod::StokesParameter > stokes); 
00576 
00577 
00578         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00579         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00580 
00581 private:
00582 
00591         CalFluxTable (ASDM & container);
00592 
00593         ASDM & container;
00594         
00595         bool archiveAsBin; // If true archive binary else archive XML
00596         bool fileAsBin ; // If true file binary else file XML   
00597         
00598         std::string version ; 
00599         
00600         Entity entity;
00601         
00602 
00603 
00611         CalFluxRow* checkAndAdd(CalFluxRow* x, bool skipCheckUniqueness=false) ;
00612         
00618          void append(CalFluxRow* x) ;
00619          
00625          void addWithoutCheckingUnique(CalFluxRow* x) ;
00626          
00627          
00628 
00629 
00630 
00631 // A data structure to store the pointers on the table's rows.
00632 
00633 // In all cases we maintain a private vector of CalFluxRow s.
00634    std::vector<CalFluxRow * > privateRows;
00635    
00636 
00637                         
00638         std::vector<CalFluxRow *> row;
00639 
00640         
00641         void error() ; //throw(ConversionException);
00642 
00643         
00650         void fromXML(std::string& xmlDoc) ;
00651                 
00652         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00653 
00658         void setFromMIMEFile(const std::string& directory);
00659         /*
00660         void openMIMEFile(const std::string& directory);
00661         */
00662         void setFromXMLFile(const std::string& directory);
00663         
00671         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00672   
00673         
00680          void setFromMIME(const std::string & mimeMsg);
00681         
00685         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00686         
00696           void toFile(std::string directory);
00697           
00701           bool loadInProgress;
00702           void checkPresenceInMemory() {
00703                 if (!presentInMemory && !loadInProgress) {
00704                         loadInProgress = true;
00705                         setFromFile(getContainer().getDirectory());
00706                         presentInMemory = true;
00707                         loadInProgress = false;
00708                 }
00709           }
00718          void setFromFile(const std::string& directory);        
00719  
00720 };
00721 
00722 } // End namespace asdm
00723 
00724 #endif /* CalFluxTable_CLASS */