casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GainTrackingTable.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 GainTrackingTable.h
00032  */
00033  
00034 #ifndef GainTrackingTable_CLASS
00035 #define GainTrackingTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047         
00048 #include <ArrayTimeInterval.h>
00049         
00050 
00051         
00052 #include <ComplexWrapper.h>
00053         
00054 
00055 
00056 
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 #include "CPolarizationType.h"
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076 
00077 
00078 #include <ConversionException.h>
00079 #include <DuplicateKey.h>
00080 #include <UniquenessViolationException.h>
00081 #include <NoSuchRow.h>
00082 #include <DuplicateKey.h>
00083 
00084 
00085 #ifndef WITHOUT_ACS
00086 #include <asdmIDLC.h>
00087 #endif
00088 
00089 #include <Representable.h>
00090 
00091 namespace asdm {
00092 
00093 //class asdm::ASDM;
00094 //class asdm::GainTrackingRow;
00095 
00096 class ASDM;
00097 class GainTrackingRow;
00210 class GainTrackingTable : public Representable {
00211         friend class ASDM;
00212 
00213 public:
00214 
00215 
00221         static std::vector<std::string> getKeyName();
00222 
00223 
00224         virtual ~GainTrackingTable();
00225         
00231         ASDM &getContainer() const;
00232         
00238         unsigned int size() const;
00239         
00247         std::string getName() const;
00248         
00256         static std::string name() ;     
00257         
00262          std::string getVersion() const ;
00263         
00269          static const std::vector<std::string>& getAttributesNames();
00270 
00276          static const std::vector<std::string>& defaultAttributesNamesInBin();
00277          
00281         Entity getEntity() const;
00282 
00287         void setEntity(Entity e);
00288                 
00296         std::string toXML()  ;
00297 
00298 #ifndef WITHOUT_ACS
00299         // Conversion Methods
00305         asdmIDL::GainTrackingTableIDL *toIDL() ;
00306 #endif
00307 
00308 #ifndef WITHOUT_ACS
00309 
00315         void fromIDL(asdmIDL::GainTrackingTableIDL x) ;
00316 #endif
00317         
00318         //
00319         // ====> Row creation.
00320         //
00321         
00326         GainTrackingRow *newRow();
00327         
00328         
00348         GainTrackingRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, vector<float > attenuator, vector<PolarizationTypeMod::PolarizationType > polarizationType);
00349         
00350 
00351 
00364          GainTrackingRow *newRow(GainTrackingRow *row); 
00365 
00366         //
00367         // ====> Append a row to its table.
00368         //
00369  
00370         
00387         GainTrackingRow* add(GainTrackingRow* x) ; 
00388 
00389  
00390 
00391 
00392 
00393         //
00394         // ====> Methods returning rows.
00395         //
00396                 
00402         std::vector<GainTrackingRow *> get() ;
00403         
00410          const std::vector<GainTrackingRow *>& get() const ;
00411         
00412 
00423          std::vector <GainTrackingRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
00424          
00425 
00426 
00427  
00428         
00444         GainTrackingRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
00445 
00446                 
00447 
00448 
00449 
00471         GainTrackingRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, vector<float > attenuator, vector<PolarizationTypeMod::PolarizationType > polarizationType); 
00472 
00473 
00474         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00475         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00476 
00477 private:
00478 
00487         GainTrackingTable (ASDM & container);
00488 
00489         ASDM & container;
00490         
00491         bool archiveAsBin; // If true archive binary else archive XML
00492         bool fileAsBin ; // If true file binary else file XML   
00493         
00494         std::string version ; 
00495         
00496         Entity entity;
00497         
00498 
00499 
00503         static std::string itsName;
00504         
00508         static std::vector<std::string> attributesNames;
00509         
00513         static std::vector<std::string> attributesNamesInBin;
00514         
00515 
00519         static bool initAttributesNames(), initAttributesNamesDone ;
00520         
00521 
00525         static std::vector<std::string> key;
00526 
00527 
00535         GainTrackingRow* checkAndAdd(GainTrackingRow* x) ;
00536         
00542          void append(GainTrackingRow* x) ;
00543          
00549          void addWithoutCheckingUnique(GainTrackingRow* x) ;
00550          
00551          
00552 
00553 
00554         
00555         
00563          GainTrackingRow * insertByStartTime(GainTrackingRow* x, std::vector<GainTrackingRow* >& row);
00564           
00565 
00566 
00567 // A data structure to store the pointers on the table's rows.
00568 
00569 // In all cases we maintain a private vector of GainTrackingRow s.
00570    std::vector<GainTrackingRow * > privateRows;
00571    
00572 
00573         
00574 
00575         
00576         
00577                 
00578                                 
00579         typedef std::vector <GainTrackingRow* > TIME_ROWS;
00580         std::map<std::string, TIME_ROWS > context;
00581                 
00586          std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
00587                  
00588                 
00589         
00590         
00596         void getByKeyNoAutoIncNoTime(std::vector <GainTrackingRow*>& vin, std::vector <GainTrackingRow*>& vout,  Tag antennaId, Tag spectralWindowId, int feedId);
00597         
00598 
00599         
00600         void error() ; //throw(ConversionException);
00601 
00602         
00609         void fromXML(std::string& xmlDoc) ;
00610                 
00611         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00612 
00617         void setFromMIMEFile(const std::string& directory);
00618         /*
00619         void openMIMEFile(const std::string& directory);
00620         */
00621         void setFromXMLFile(const std::string& directory);
00622         
00630         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00631   
00632         
00639          void setFromMIME(const std::string & mimeMsg);
00640         
00644         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00645         
00655           void toFile(std::string directory);
00656           
00660           bool loadInProgress;
00661           void checkPresenceInMemory() {
00662                 if (!presentInMemory && !loadInProgress) {
00663                         loadInProgress = true;
00664                         setFromFile(getContainer().getDirectory());
00665                         presentInMemory = true;
00666                         loadInProgress = false;
00667                 }
00668           }
00677          void setFromFile(const std::string& directory);        
00678  
00679 };
00680 
00681 } // End namespace asdm
00682 
00683 #endif /* GainTrackingTable_CLASS */