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 #include <pthread.h>
00112 
00113 namespace asdm {
00114 
00115 //class asdm::ASDM;
00116 //class asdm::CalFocusModelRow;
00117 
00118 class ASDM;
00119 class CalFocusModelRow;
00280 class CalFocusModelTable : public Representable {
00281         friend class ASDM;
00282 
00283 public:
00284 
00285 
00291         static const std::vector<std::string>& getKeyName();
00292 
00293 
00294         virtual ~CalFocusModelTable();
00295         
00301         ASDM &getContainer() const;
00302         
00308         unsigned int size() const;
00309         
00317         std::string getName() const;
00318         
00326         static std::string name() ;     
00327         
00332          std::string getVersion() const ;
00333         
00339          static const std::vector<std::string>& getAttributesNames();
00340 
00346          static const std::vector<std::string>& defaultAttributesNamesInBin();
00347          
00351         Entity getEntity() const;
00352 
00357         void setEntity(Entity e);
00358                 
00366         std::string toXML()  ;
00367 
00368 #ifndef WITHOUT_ACS
00369         // Conversion Methods
00375         asdmIDL::CalFocusModelTableIDL *toIDL() ;
00376         
00384          void toIDL(asdmIDL::CalFocusModelTableIDL& x) const;
00385          
00386 #endif
00387 
00388 #ifndef WITHOUT_ACS
00389 
00395         void fromIDL(asdmIDL::CalFocusModelTableIDL x) ;
00396 #endif
00397         
00398         //
00399         // ====> Row creation.
00400         //
00401         
00406         CalFocusModelRow *newRow();
00407         
00408         
00450         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);
00451         
00452 
00453 
00466          CalFocusModelRow *newRow(CalFocusModelRow *row); 
00467 
00468         //
00469         // ====> Append a row to its table.
00470         //
00471  
00472         
00485         CalFocusModelRow* add(CalFocusModelRow* x) ; 
00486 
00487  
00488 
00489 
00490 
00491         //
00492         // ====> Methods returning rows.
00493         //
00494                 
00500         std::vector<CalFocusModelRow *> get() ;
00501         
00508          const std::vector<CalFocusModelRow *>& get() const ;
00509         
00510 
00511 
00512  
00513         
00531         CalFocusModelRow* getRowByKey(string antennaName, ReceiverBandMod::ReceiverBand receiverBand, PolarizationTypeMod::PolarizationType polarizationType, Tag calDataId, Tag calReductionId);
00532 
00533                 
00534 
00535 
00536 
00580         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); 
00581 
00582 
00583         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00584         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00585 
00586 private:
00587 
00596         CalFocusModelTable (ASDM & container);
00597 
00598         ASDM & container;
00599         
00600         bool archiveAsBin; // If true archive binary else archive XML
00601         bool fileAsBin ; // If true file binary else file XML   
00602         
00603         std::string version ; 
00604         
00605         Entity entity;
00606         
00607 
00608 
00616         CalFocusModelRow* checkAndAdd(CalFocusModelRow* x, bool skipCheckUniqueness=false) ;
00617         
00623          void append(CalFocusModelRow* x) ;
00624          
00630          void addWithoutCheckingUnique(CalFocusModelRow* x) ;
00631          
00632          
00633 
00634 
00635 
00636 // A data structure to store the pointers on the table's rows.
00637 
00638 // In all cases we maintain a private vector of CalFocusModelRow s.
00639    std::vector<CalFocusModelRow * > privateRows;
00640    
00641 
00642                         
00643         std::vector<CalFocusModelRow *> row;
00644 
00645         
00646         void error() ; //throw(ConversionException);
00647 
00648         
00655         void fromXML(std::string& xmlDoc) ;
00656                 
00657         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00658 
00663         void setFromMIMEFile(const std::string& directory);
00664         /*
00665         void openMIMEFile(const std::string& directory);
00666         */
00667         void setFromXMLFile(const std::string& directory);
00668         
00676         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00677   
00678         
00685          void setFromMIME(const std::string & mimeMsg);
00686         
00690         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00691         
00701           void toFile(std::string directory);
00702           
00706           bool loadInProgress;
00707           void checkPresenceInMemory() {
00708                 if (!presentInMemory && !loadInProgress) {
00709                         loadInProgress = true;
00710                         setFromFile(getContainer().getDirectory());
00711                         presentInMemory = true;
00712                         loadInProgress = false;
00713                 }
00714           }
00723          void setFromFile(const std::string& directory);        
00724  
00725 };
00726 
00727 } // End namespace asdm
00728 
00729 #endif /* CalFocusModelTable_CLASS */