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 namespace asdm {
00122 
00123 //class asdm::ASDM;
00124 //class asdm::CalFluxRow;
00125 
00126 class ASDM;
00127 class CalFluxRow;
00301 class CalFluxTable : public Representable {
00302         friend class ASDM;
00303 
00304 public:
00305 
00306 
00312         static std::vector<std::string> getKeyName();
00313 
00314 
00315         virtual ~CalFluxTable();
00316         
00322         ASDM &getContainer() const;
00323         
00329         unsigned int size() const;
00330         
00338         std::string getName() const;
00339         
00347         static std::string name() ;     
00348         
00353          std::string getVersion() const ;
00354         
00360          static const std::vector<std::string>& getAttributesNames();
00361 
00367          static const std::vector<std::string>& defaultAttributesNamesInBin();
00368          
00372         Entity getEntity() const;
00373 
00378         void setEntity(Entity e);
00379                 
00387         std::string toXML()  ;
00388 
00389 #ifndef WITHOUT_ACS
00390         // Conversion Methods
00396         asdmIDL::CalFluxTableIDL *toIDL() ;
00397 #endif
00398 
00399 #ifndef WITHOUT_ACS
00400 
00406         void fromIDL(asdmIDL::CalFluxTableIDL x) ;
00407 #endif
00408         
00409         //
00410         // ====> Row creation.
00411         //
00412         
00417         CalFluxRow *newRow();
00418         
00419         
00449         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);
00450         
00451 
00452 
00465          CalFluxRow *newRow(CalFluxRow *row); 
00466 
00467         //
00468         // ====> Append a row to its table.
00469         //
00470  
00471         
00484         CalFluxRow* add(CalFluxRow* x) ; 
00485 
00486  
00487 
00488 
00489 
00490         //
00491         // ====> Methods returning rows.
00492         //
00493                 
00499         std::vector<CalFluxRow *> get() ;
00500         
00507          const std::vector<CalFluxRow *>& get() const ;
00508         
00509 
00510 
00511  
00512         
00526         CalFluxRow* getRowByKey(string sourceName, Tag calDataId, Tag calReductionId);
00527 
00528                 
00529 
00530 
00531 
00563         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); 
00564 
00565 
00566         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00567         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00568 
00569 private:
00570 
00579         CalFluxTable (ASDM & container);
00580 
00581         ASDM & container;
00582         
00583         bool archiveAsBin; // If true archive binary else archive XML
00584         bool fileAsBin ; // If true file binary else file XML   
00585         
00586         std::string version ; 
00587         
00588         Entity entity;
00589         
00590 
00591 
00595         static std::string itsName;
00596         
00600         static std::vector<std::string> attributesNames;
00601         
00605         static std::vector<std::string> attributesNamesInBin;
00606         
00607 
00611         static bool initAttributesNames(), initAttributesNamesDone ;
00612         
00613 
00617         static std::vector<std::string> key;
00618 
00619 
00627         CalFluxRow* checkAndAdd(CalFluxRow* x) ;
00628         
00634          void append(CalFluxRow* x) ;
00635          
00641          void addWithoutCheckingUnique(CalFluxRow* x) ;
00642          
00643          
00644 
00645 
00646 
00647 // A data structure to store the pointers on the table's rows.
00648 
00649 // In all cases we maintain a private vector of CalFluxRow s.
00650    std::vector<CalFluxRow * > privateRows;
00651    
00652 
00653                         
00654         std::vector<CalFluxRow *> row;
00655 
00656         
00657         void error() ; //throw(ConversionException);
00658 
00659         
00666         void fromXML(std::string& xmlDoc) ;
00667                 
00668         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00669 
00674         void setFromMIMEFile(const std::string& directory);
00675         /*
00676         void openMIMEFile(const std::string& directory);
00677         */
00678         void setFromXMLFile(const std::string& directory);
00679         
00687         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00688   
00689         
00696          void setFromMIME(const std::string & mimeMsg);
00697         
00701         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00702         
00712           void toFile(std::string directory);
00713           
00717           bool loadInProgress;
00718           void checkPresenceInMemory() {
00719                 if (!presentInMemory && !loadInProgress) {
00720                         loadInProgress = true;
00721                         setFromFile(getContainer().getDirectory());
00722                         presentInMemory = true;
00723                         loadInProgress = false;
00724                 }
00725           }
00734          void setFromFile(const std::string& directory);        
00735  
00736 };
00737 
00738 } // End namespace asdm
00739 
00740 #endif /* CalFluxTable_CLASS */