casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FeedTable.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 FeedTable.h
00032  */
00033  
00034 #ifndef FeedTable_CLASS
00035 #define FeedTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Angle.h>
00045         
00046 
00047         
00048 #include <Tag.h>
00049         
00050 
00051         
00052 #include <Length.h>
00053         
00054 
00055         
00056 #include <ArrayTimeInterval.h>
00057         
00058 
00059         
00060 #include <ComplexWrapper.h>
00061         
00062 
00063 
00064 
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 #include "CPolarizationType.h"
00078         
00079 
00080         
00081 
00082         
00083 
00084         
00085 
00086         
00087 
00088         
00089 
00090 
00091 
00092 #include <ConversionException.h>
00093 #include <DuplicateKey.h>
00094 #include <UniquenessViolationException.h>
00095 #include <NoSuchRow.h>
00096 #include <DuplicateKey.h>
00097 
00098 
00099 #ifndef WITHOUT_ACS
00100 #include <asdmIDLC.h>
00101 #endif
00102 
00103 #include <Representable.h>
00104 
00105 #include <pthread.h>
00106 
00107 namespace asdm {
00108 
00109 //class asdm::ASDM;
00110 //class asdm::FeedRow;
00111 
00112 class ASDM;
00113 class FeedRow;
00247 class FeedTable : public Representable {
00248         friend class ASDM;
00249 
00250 public:
00251 
00252 
00258         static const std::vector<std::string>& getKeyName();
00259 
00260 
00261         virtual ~FeedTable();
00262         
00268         ASDM &getContainer() const;
00269         
00275         unsigned int size() const;
00276         
00284         std::string getName() const;
00285         
00293         static std::string name() ;     
00294         
00299          std::string getVersion() const ;
00300         
00306          static const std::vector<std::string>& getAttributesNames();
00307 
00313          static const std::vector<std::string>& defaultAttributesNamesInBin();
00314          
00318         Entity getEntity() const;
00319 
00324         void setEntity(Entity e);
00325                 
00333         std::string toXML()  ;
00334 
00335 #ifndef WITHOUT_ACS
00336         // Conversion Methods
00342         asdmIDL::FeedTableIDL *toIDL() ;
00343         
00351          void toIDL(asdmIDL::FeedTableIDL& x) const;
00352          
00353 #endif
00354 
00355 #ifndef WITHOUT_ACS
00356 
00362         void fromIDL(asdmIDL::FeedTableIDL x) ;
00363 #endif
00364         
00365         //
00366         // ====> Row creation.
00367         //
00368         
00373         FeedRow *newRow();
00374         
00375         
00401         FeedRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int numReceptor, vector<vector<double > > beamOffset, vector<vector<Length > > focusReference, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, vector<vector<Complex > > polResponse, vector<Angle > receptorAngle, vector<int>  receiverId);
00402         
00403 
00404 
00417          FeedRow *newRow(FeedRow *row); 
00418 
00419         //
00420         // ====> Append a row to its table.
00421         //
00422 
00423         
00424          
00425         
00426         
00436          FeedRow* add(FeedRow* x) ;
00437 
00438 
00439 
00440         //
00441         // ====> Methods returning rows.
00442         //
00443                 
00449         std::vector<FeedRow *> get() ;
00450         
00457          const std::vector<FeedRow *>& get() const ;
00458         
00459 
00460 
00461  
00462         
00478         FeedRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
00479 
00480                 
00481         
00489         std::vector <FeedRow *>  getRowByFeedId(int);
00490 
00491 
00492 
00520         FeedRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int numReceptor, vector<vector<double > > beamOffset, vector<vector<Length > > focusReference, vector<PolarizationTypeMod::PolarizationType > polarizationTypes, vector<vector<Complex > > polResponse, vector<Angle > receptorAngle, vector<int>  receiverId); 
00521 
00522 
00523         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00524         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00525 
00526 private:
00527 
00536         FeedTable (ASDM & container);
00537 
00538         ASDM & container;
00539         
00540         bool archiveAsBin; // If true archive binary else archive XML
00541         bool fileAsBin ; // If true file binary else file XML   
00542         
00543         std::string version ; 
00544         
00545         Entity entity;
00546         
00547 
00548 
00558         FeedRow* checkAndAdd(FeedRow* x, bool skipCheckUniqueness=false) ;
00559         
00565          void append(FeedRow* x) ;
00566          
00572          void addWithoutCheckingUnique(FeedRow* x) ;
00573          
00574          
00575 
00576 
00577         
00578         
00586          FeedRow * insertByStartTime(FeedRow* x, std::vector<FeedRow* >& row);
00587           
00588 
00589 
00590 // A data structure to store the pointers on the table's rows.
00591 
00592 // In all cases we maintain a private vector of FeedRow s.
00593    std::vector<FeedRow * > privateRows;
00594    
00595 
00596         
00597 
00598         
00599         
00600                 
00601                 
00602         typedef std::vector <std::vector <FeedRow* > > ID_TIME_ROWS;
00603         std::map<std::string, ID_TIME_ROWS > context;
00604         
00609          std::string Key(Tag antennaId, Tag spectralWindowId) ;
00610                 
00611                 
00612         
00613         
00619         void getByKeyNoAutoIncNoTime(std::vector <FeedRow*>& vin, std::vector <FeedRow*>& vout,  Tag antennaId, Tag spectralWindowId);
00620         
00621 
00622         
00623         void error() ; //throw(ConversionException);
00624 
00625         
00632         void fromXML(std::string& xmlDoc) ;
00633                 
00634         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00635 
00640         void setFromMIMEFile(const std::string& directory);
00641         /*
00642         void openMIMEFile(const std::string& directory);
00643         */
00644         void setFromXMLFile(const std::string& directory);
00645         
00653         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00654   
00655         
00662          void setFromMIME(const std::string & mimeMsg);
00663         
00667         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00668         
00678           void toFile(std::string directory);
00679           
00683           bool loadInProgress;
00684           void checkPresenceInMemory() {
00685                 if (!presentInMemory && !loadInProgress) {
00686                         loadInProgress = true;
00687                         setFromFile(getContainer().getDirectory());
00688                         presentInMemory = true;
00689                         loadInProgress = false;
00690                 }
00691           }
00700          void setFromFile(const std::string& directory);        
00701  
00702 };
00703 
00704 } // End namespace asdm
00705 
00706 #endif /* FeedTable_CLASS */