casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalGainTable.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 CalGainTable.h
00032  */
00033  
00034 #ifndef CalGainTable_CLASS
00035 #define CalGainTable_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 
00053 
00054         
00055 
00056         
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072 
00073 
00074 #include <ConversionException.h>
00075 #include <DuplicateKey.h>
00076 #include <UniquenessViolationException.h>
00077 #include <NoSuchRow.h>
00078 #include <DuplicateKey.h>
00079 
00080 
00081 #ifndef WITHOUT_ACS
00082 #include <asdmIDLC.h>
00083 #endif
00084 
00085 #include <Representable.h>
00086 
00087 namespace asdm {
00088 
00089 //class asdm::ASDM;
00090 //class asdm::CalGainRow;
00091 
00092 class ASDM;
00093 class CalGainRow;
00199 class CalGainTable : public Representable {
00200         friend class ASDM;
00201 
00202 public:
00203 
00204 
00210         static std::vector<std::string> getKeyName();
00211 
00212 
00213         virtual ~CalGainTable();
00214         
00220         ASDM &getContainer() const;
00221         
00227         unsigned int size() const;
00228         
00236         std::string getName() const;
00237         
00245         static std::string name() ;     
00246         
00251          std::string getVersion() const ;
00252         
00258          static const std::vector<std::string>& getAttributesNames();
00259 
00265          static const std::vector<std::string>& defaultAttributesNamesInBin();
00266          
00270         Entity getEntity() const;
00271 
00276         void setEntity(Entity e);
00277                 
00285         std::string toXML()  ;
00286 
00287 #ifndef WITHOUT_ACS
00288         // Conversion Methods
00294         asdmIDL::CalGainTableIDL *toIDL() ;
00295 #endif
00296 
00297 #ifndef WITHOUT_ACS
00298 
00304         void fromIDL(asdmIDL::CalGainTableIDL x) ;
00305 #endif
00306         
00307         //
00308         // ====> Row creation.
00309         //
00310         
00315         CalGainRow *newRow();
00316         
00317         
00345         CalGainRow *newRow(Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, float gain, bool gainValid, float fit, float fitWeight, bool totalGainValid, float totalFit, float totalFitWeight);
00346         
00347 
00348 
00361          CalGainRow *newRow(CalGainRow *row); 
00362 
00363         //
00364         // ====> Append a row to its table.
00365         //
00366  
00367         
00380         CalGainRow* add(CalGainRow* x) ; 
00381 
00382  
00383 
00384 
00385 
00386         //
00387         // ====> Methods returning rows.
00388         //
00389                 
00395         std::vector<CalGainRow *> get() ;
00396         
00403          const std::vector<CalGainRow *>& get() const ;
00404         
00405 
00406 
00407  
00408         
00420         CalGainRow* getRowByKey(Tag calDataId, Tag calReductionId);
00421 
00422                 
00423 
00424 
00425 
00455         CalGainRow* lookup(Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, float gain, bool gainValid, float fit, float fitWeight, bool totalGainValid, float totalFit, float totalFitWeight); 
00456 
00457 
00458         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00459         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00460 
00461 private:
00462 
00471         CalGainTable (ASDM & container);
00472 
00473         ASDM & container;
00474         
00475         bool archiveAsBin; // If true archive binary else archive XML
00476         bool fileAsBin ; // If true file binary else file XML   
00477         
00478         std::string version ; 
00479         
00480         Entity entity;
00481         
00482 
00483 
00487         static std::string itsName;
00488         
00492         static std::vector<std::string> attributesNames;
00493         
00497         static std::vector<std::string> attributesNamesInBin;
00498         
00499 
00503         static bool initAttributesNames(), initAttributesNamesDone ;
00504         
00505 
00509         static std::vector<std::string> key;
00510 
00511 
00519         CalGainRow* checkAndAdd(CalGainRow* x) ;
00520         
00526          void append(CalGainRow* x) ;
00527          
00533          void addWithoutCheckingUnique(CalGainRow* x) ;
00534          
00535          
00536 
00537 
00538 
00539 // A data structure to store the pointers on the table's rows.
00540 
00541 // In all cases we maintain a private vector of CalGainRow s.
00542    std::vector<CalGainRow * > privateRows;
00543    
00544 
00545                         
00546         std::vector<CalGainRow *> row;
00547 
00548         
00549         void error() ; //throw(ConversionException);
00550 
00551         
00558         void fromXML(std::string& xmlDoc) ;
00559                 
00560         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00561 
00566         void setFromMIMEFile(const std::string& directory);
00567         /*
00568         void openMIMEFile(const std::string& directory);
00569         */
00570         void setFromXMLFile(const std::string& directory);
00571         
00579         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00580   
00581         
00588          void setFromMIME(const std::string & mimeMsg);
00589         
00593         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00594         
00604           void toFile(std::string directory);
00605           
00609           bool loadInProgress;
00610           void checkPresenceInMemory() {
00611                 if (!presentInMemory && !loadInProgress) {
00612                         loadInProgress = true;
00613                         setFromFile(getContainer().getDirectory());
00614                         presentInMemory = true;
00615                         loadInProgress = false;
00616                 }
00617           }
00626          void setFromFile(const std::string& directory);        
00627  
00628 };
00629 
00630 } // End namespace asdm
00631 
00632 #endif /* CalGainTable_CLASS */