casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalFocusModelTable.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 CalFocusModelTable.h
00032  */
00033  
00034 #ifndef CalFocusModelTable_CLASS
00035 #define CalFocusModelTable_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 <Length.h>
00053         
00054 
00055 
00056 
00057 
00058         
00059 
00060         
00061 #include "CReceiverBand.h"
00062         
00063 
00064         
00065 #include "CPolarizationType.h"
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 #include "CAntennaMake.h"
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 #include <ConversionException.h>
00099 #include <DuplicateKey.h>
00100 #include <UniquenessViolationException.h>
00101 #include <NoSuchRow.h>
00102 #include <DuplicateKey.h>
00103 
00104 
00105 #ifndef WITHOUT_ACS
00106 #include <asdmIDLC.h>
00107 #endif
00108 
00109 #include <Representable.h>
00110 
00111 namespace asdm {
00112 
00113 //class asdm::ASDM;
00114 //class asdm::CalFocusModelRow;
00115 
00116 class ASDM;
00117 class CalFocusModelRow;
00278 class CalFocusModelTable : public Representable {
00279         friend class ASDM;
00280 
00281 public:
00282 
00283 
00289         static std::vector<std::string> getKeyName();
00290 
00291 
00292         virtual ~CalFocusModelTable();
00293         
00299         ASDM &getContainer() const;
00300         
00306         unsigned int size() const;
00307         
00315         std::string getName() const;
00316         
00324         static std::string name() ;     
00325         
00330          std::string getVersion() const ;
00331         
00337          static const std::vector<std::string>& getAttributesNames();
00338 
00344          static const std::vector<std::string>& defaultAttributesNamesInBin();
00345          
00349         Entity getEntity() const;
00350 
00355         void setEntity(Entity e);
00356                 
00364         std::string toXML()  ;
00365 
00366 #ifndef WITHOUT_ACS
00367         // Conversion Methods
00373         asdmIDL::CalFocusModelTableIDL *toIDL() ;
00374 #endif
00375 
00376 #ifndef WITHOUT_ACS
00377 
00383         void fromIDL(asdmIDL::CalFocusModelTableIDL x) ;
00384 #endif
00385         
00386         //
00387         // ====> Row creation.
00388         //
00389         
00394         CalFocusModelRow *newRow();
00395         
00396         
00438         CalFocusModelRow *newRow(string antennaName, ReceiverBandMod::ReceiverBand receiverBand, PolarizationTypeMod::PolarizationType polarizationType, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, AntennaMakeMod::AntennaMake antennaMake, int numCoeff, int numSourceObs, vector<string > coeffName, vector<string > coeffFormula, vector<float > coeffValue, vector<float > coeffError, vector<bool > coeffFixed, string focusModel, vector<Length > focusRMS, double reducedChiSquared);
00439         
00440 
00441 
00454          CalFocusModelRow *newRow(CalFocusModelRow *row); 
00455 
00456         //
00457         // ====> Append a row to its table.
00458         //
00459  
00460         
00473         CalFocusModelRow* add(CalFocusModelRow* x) ; 
00474 
00475  
00476 
00477 
00478 
00479         //
00480         // ====> Methods returning rows.
00481         //
00482                 
00488         std::vector<CalFocusModelRow *> get() ;
00489         
00496          const std::vector<CalFocusModelRow *>& get() const ;
00497         
00498 
00499 
00500  
00501         
00519         CalFocusModelRow* getRowByKey(string antennaName, ReceiverBandMod::ReceiverBand receiverBand, PolarizationTypeMod::PolarizationType polarizationType, Tag calDataId, Tag calReductionId);
00520 
00521                 
00522 
00523 
00524 
00568         CalFocusModelRow* lookup(string antennaName, ReceiverBandMod::ReceiverBand receiverBand, PolarizationTypeMod::PolarizationType polarizationType, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, AntennaMakeMod::AntennaMake antennaMake, int numCoeff, int numSourceObs, vector<string > coeffName, vector<string > coeffFormula, vector<float > coeffValue, vector<float > coeffError, vector<bool > coeffFixed, string focusModel, vector<Length > focusRMS, double reducedChiSquared); 
00569 
00570 
00571         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00572         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00573 
00574 private:
00575 
00584         CalFocusModelTable (ASDM & container);
00585 
00586         ASDM & container;
00587         
00588         bool archiveAsBin; // If true archive binary else archive XML
00589         bool fileAsBin ; // If true file binary else file XML   
00590         
00591         std::string version ; 
00592         
00593         Entity entity;
00594         
00595 
00596 
00600         static std::string itsName;
00601         
00605         static std::vector<std::string> attributesNames;
00606         
00610         static std::vector<std::string> attributesNamesInBin;
00611         
00612 
00616         static bool initAttributesNames(), initAttributesNamesDone ;
00617         
00618 
00622         static std::vector<std::string> key;
00623 
00624 
00632         CalFocusModelRow* checkAndAdd(CalFocusModelRow* x) ;
00633         
00639          void append(CalFocusModelRow* x) ;
00640          
00646          void addWithoutCheckingUnique(CalFocusModelRow* x) ;
00647          
00648          
00649 
00650 
00651 
00652 // A data structure to store the pointers on the table's rows.
00653 
00654 // In all cases we maintain a private vector of CalFocusModelRow s.
00655    std::vector<CalFocusModelRow * > privateRows;
00656    
00657 
00658                         
00659         std::vector<CalFocusModelRow *> row;
00660 
00661         
00662         void error() ; //throw(ConversionException);
00663 
00664         
00671         void fromXML(std::string& xmlDoc) ;
00672                 
00673         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00674 
00679         void setFromMIMEFile(const std::string& directory);
00680         /*
00681         void openMIMEFile(const std::string& directory);
00682         */
00683         void setFromXMLFile(const std::string& directory);
00684         
00692         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00693   
00694         
00701          void setFromMIME(const std::string & mimeMsg);
00702         
00706         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00707         
00717           void toFile(std::string directory);
00718           
00722           bool loadInProgress;
00723           void checkPresenceInMemory() {
00724                 if (!presentInMemory && !loadInProgress) {
00725                         loadInProgress = true;
00726                         setFromFile(getContainer().getDirectory());
00727                         presentInMemory = true;
00728                         loadInProgress = false;
00729                 }
00730           }
00739          void setFromFile(const std::string& directory);        
00740  
00741 };
00742 
00743 } // End namespace asdm
00744 
00745 #endif /* CalFocusModelTable_CLASS */