casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FreqOffsetTable.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 FreqOffsetTable.h
00032  */
00033  
00034 #ifndef FreqOffsetTable_CLASS
00035 #define FreqOffsetTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047         
00048 #include <Frequency.h>
00049         
00050 
00051         
00052 #include <ArrayTimeInterval.h>
00053         
00054 
00055 
00056 
00057 
00058         
00059 
00060         
00061 
00062 
00063 
00064 #include <ConversionException.h>
00065 #include <DuplicateKey.h>
00066 #include <UniquenessViolationException.h>
00067 #include <NoSuchRow.h>
00068 #include <DuplicateKey.h>
00069 
00070 
00071 #ifndef WITHOUT_ACS
00072 #include <asdmIDLC.h>
00073 #endif
00074 
00075 #include <Representable.h>
00076 
00077 namespace asdm {
00078 
00079 //class asdm::ASDM;
00080 //class asdm::FreqOffsetRow;
00081 
00082 class ASDM;
00083 class FreqOffsetRow;
00151 class FreqOffsetTable : public Representable {
00152         friend class ASDM;
00153 
00154 public:
00155 
00156 
00162         static std::vector<std::string> getKeyName();
00163 
00164 
00165         virtual ~FreqOffsetTable();
00166         
00172         ASDM &getContainer() const;
00173         
00179         unsigned int size() const;
00180         
00188         std::string getName() const;
00189         
00197         static std::string name() ;     
00198         
00203          std::string getVersion() const ;
00204         
00210          static const std::vector<std::string>& getAttributesNames();
00211 
00217          static const std::vector<std::string>& defaultAttributesNamesInBin();
00218          
00222         Entity getEntity() const;
00223 
00228         void setEntity(Entity e);
00229                 
00237         std::string toXML()  ;
00238 
00239 #ifndef WITHOUT_ACS
00240         // Conversion Methods
00246         asdmIDL::FreqOffsetTableIDL *toIDL() ;
00247 #endif
00248 
00249 #ifndef WITHOUT_ACS
00250 
00256         void fromIDL(asdmIDL::FreqOffsetTableIDL x) ;
00257 #endif
00258         
00259         //
00260         // ====> Row creation.
00261         //
00262         
00267         FreqOffsetRow *newRow();
00268         
00269         
00285         FreqOffsetRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, Frequency offset);
00286         
00287 
00288 
00301          FreqOffsetRow *newRow(FreqOffsetRow *row); 
00302 
00303         //
00304         // ====> Append a row to its table.
00305         //
00306  
00307         
00324         FreqOffsetRow* add(FreqOffsetRow* x) ; 
00325 
00326  
00327 
00328 
00329 
00330         //
00331         // ====> Methods returning rows.
00332         //
00333                 
00339         std::vector<FreqOffsetRow *> get() ;
00340         
00347          const std::vector<FreqOffsetRow *>& get() const ;
00348         
00349 
00360          std::vector <FreqOffsetRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
00361          
00362 
00363 
00364  
00365         
00381         FreqOffsetRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
00382 
00383                 
00384 
00385 
00386 
00404         FreqOffsetRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, Frequency offset); 
00405 
00406 
00407         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00408         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00409 
00410 private:
00411 
00420         FreqOffsetTable (ASDM & container);
00421 
00422         ASDM & container;
00423         
00424         bool archiveAsBin; // If true archive binary else archive XML
00425         bool fileAsBin ; // If true file binary else file XML   
00426         
00427         std::string version ; 
00428         
00429         Entity entity;
00430         
00431 
00432 
00436         static std::string itsName;
00437         
00441         static std::vector<std::string> attributesNames;
00442         
00446         static std::vector<std::string> attributesNamesInBin;
00447         
00448 
00452         static bool initAttributesNames(), initAttributesNamesDone ;
00453         
00454 
00458         static std::vector<std::string> key;
00459 
00460 
00468         FreqOffsetRow* checkAndAdd(FreqOffsetRow* x) ;
00469         
00475          void append(FreqOffsetRow* x) ;
00476          
00482          void addWithoutCheckingUnique(FreqOffsetRow* x) ;
00483          
00484          
00485 
00486 
00487         
00488         
00496          FreqOffsetRow * insertByStartTime(FreqOffsetRow* x, std::vector<FreqOffsetRow* >& row);
00497           
00498 
00499 
00500 // A data structure to store the pointers on the table's rows.
00501 
00502 // In all cases we maintain a private vector of FreqOffsetRow s.
00503    std::vector<FreqOffsetRow * > privateRows;
00504    
00505 
00506         
00507 
00508         
00509         
00510                 
00511                                 
00512         typedef std::vector <FreqOffsetRow* > TIME_ROWS;
00513         std::map<std::string, TIME_ROWS > context;
00514                 
00519          std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
00520                  
00521                 
00522         
00523         
00529         void getByKeyNoAutoIncNoTime(std::vector <FreqOffsetRow*>& vin, std::vector <FreqOffsetRow*>& vout,  Tag antennaId, Tag spectralWindowId, int feedId);
00530         
00531 
00532         
00533         void error() ; //throw(ConversionException);
00534 
00535         
00542         void fromXML(std::string& xmlDoc) ;
00543                 
00544         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00545 
00550         void setFromMIMEFile(const std::string& directory);
00551         /*
00552         void openMIMEFile(const std::string& directory);
00553         */
00554         void setFromXMLFile(const std::string& directory);
00555         
00563         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00564   
00565         
00572          void setFromMIME(const std::string & mimeMsg);
00573         
00577         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00578         
00588           void toFile(std::string directory);
00589           
00593           bool loadInProgress;
00594           void checkPresenceInMemory() {
00595                 if (!presentInMemory && !loadInProgress) {
00596                         loadInProgress = true;
00597                         setFromFile(getContainer().getDirectory());
00598                         presentInMemory = true;
00599                         loadInProgress = false;
00600                 }
00601           }
00610          void setFromFile(const std::string& directory);        
00611  
00612 };
00613 
00614 } // End namespace asdm
00615 
00616 #endif /* FreqOffsetTable_CLASS */