casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ReceiverTable.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 ReceiverTable.h
00032  */
00033  
00034 #ifndef ReceiverTable_CLASS
00035 #define ReceiverTable_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         
00065 
00066         
00067 #include "CReceiverBand.h"
00068         
00069 
00070         
00071 
00072         
00073 #include "CReceiverSideband.h"
00074         
00075 
00076         
00077 #include "CNetSideband.h"
00078         
00079 
00080 
00081 
00082 #include <ConversionException.h>
00083 #include <DuplicateKey.h>
00084 #include <UniquenessViolationException.h>
00085 #include <NoSuchRow.h>
00086 #include <DuplicateKey.h>
00087 
00088 
00089 #ifndef WITHOUT_ACS
00090 #include <asdmIDLC.h>
00091 #endif
00092 
00093 #include <Representable.h>
00094 
00095 namespace asdm {
00096 
00097 //class asdm::ASDM;
00098 //class asdm::ReceiverRow;
00099 
00100 class ASDM;
00101 class ReceiverRow;
00195 class ReceiverTable : public Representable {
00196         friend class ASDM;
00197 
00198 public:
00199 
00200 
00206         static std::vector<std::string> getKeyName();
00207 
00208 
00209         virtual ~ReceiverTable();
00210         
00216         ASDM &getContainer() const;
00217         
00223         unsigned int size() const;
00224         
00232         std::string getName() const;
00233         
00241         static std::string name() ;     
00242         
00247          std::string getVersion() const ;
00248         
00254          static const std::vector<std::string>& getAttributesNames();
00255 
00261          static const std::vector<std::string>& defaultAttributesNamesInBin();
00262          
00266         Entity getEntity() const;
00267 
00272         void setEntity(Entity e);
00273                 
00281         std::string toXML()  ;
00282 
00283 #ifndef WITHOUT_ACS
00284         // Conversion Methods
00290         asdmIDL::ReceiverTableIDL *toIDL() ;
00291 #endif
00292 
00293 #ifndef WITHOUT_ACS
00294 
00300         void fromIDL(asdmIDL::ReceiverTableIDL x) ;
00301 #endif
00302         
00303         //
00304         // ====> Row creation.
00305         //
00306         
00311         ReceiverRow *newRow();
00312         
00313         
00335         ReceiverRow *newRow(Tag spectralWindowId, ArrayTimeInterval timeInterval, string name, int numLO, ReceiverBandMod::ReceiverBand frequencyBand, vector<Frequency > freqLO, ReceiverSidebandMod::ReceiverSideband receiverSideband, vector<NetSidebandMod::NetSideband > sidebandLO);
00336         
00337 
00338 
00351          ReceiverRow *newRow(ReceiverRow *row); 
00352 
00353         //
00354         // ====> Append a row to its table.
00355         //
00356 
00357         
00358          
00359         
00360         
00370          ReceiverRow* add(ReceiverRow* x) ;
00371 
00372 
00373 
00374         //
00375         // ====> Methods returning rows.
00376         //
00377                 
00383         std::vector<ReceiverRow *> get() ;
00384         
00391          const std::vector<ReceiverRow *>& get() const ;
00392         
00393 
00394 
00395  
00396         
00410         ReceiverRow* getRowByKey(int receiverId, Tag spectralWindowId, ArrayTimeInterval timeInterval);
00411 
00412                 
00413         
00421         std::vector <ReceiverRow *>  getRowByReceiverId(int);
00422 
00423 
00424 
00448         ReceiverRow* lookup(Tag spectralWindowId, ArrayTimeInterval timeInterval, string name, int numLO, ReceiverBandMod::ReceiverBand frequencyBand, vector<Frequency > freqLO, ReceiverSidebandMod::ReceiverSideband receiverSideband, vector<NetSidebandMod::NetSideband > sidebandLO); 
00449 
00450 
00451         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00452         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00453 
00454 private:
00455 
00464         ReceiverTable (ASDM & container);
00465 
00466         ASDM & container;
00467         
00468         bool archiveAsBin; // If true archive binary else archive XML
00469         bool fileAsBin ; // If true file binary else file XML   
00470         
00471         std::string version ; 
00472         
00473         Entity entity;
00474         
00475 
00476 
00480         static std::string itsName;
00481         
00485         static std::vector<std::string> attributesNames;
00486         
00490         static std::vector<std::string> attributesNamesInBin;
00491         
00492 
00496         static bool initAttributesNames(), initAttributesNamesDone ;
00497         
00498 
00502         static std::vector<std::string> key;
00503 
00504 
00514         ReceiverRow* checkAndAdd(ReceiverRow* x) ;
00515         
00521          void append(ReceiverRow* x) ;
00522          
00528          void addWithoutCheckingUnique(ReceiverRow* x) ;
00529          
00530          
00531 
00532 
00533         
00534         
00542          ReceiverRow * insertByStartTime(ReceiverRow* x, std::vector<ReceiverRow* >& row);
00543           
00544 
00545 
00546 // A data structure to store the pointers on the table's rows.
00547 
00548 // In all cases we maintain a private vector of ReceiverRow s.
00549    std::vector<ReceiverRow * > privateRows;
00550    
00551 
00552         
00553 
00554         
00555         
00556                 
00557                 
00558         typedef std::vector <std::vector <ReceiverRow* > > ID_TIME_ROWS;
00559         std::map<std::string, ID_TIME_ROWS > context;
00560         
00565          std::string Key(Tag spectralWindowId) ;
00566                 
00567                 
00568         
00569         
00575         void getByKeyNoAutoIncNoTime(std::vector <ReceiverRow*>& vin, std::vector <ReceiverRow*>& vout,  Tag spectralWindowId);
00576         
00577 
00578         
00579         void error() ; //throw(ConversionException);
00580 
00581         
00588         void fromXML(std::string& xmlDoc) ;
00589                 
00590         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00591 
00596         void setFromMIMEFile(const std::string& directory);
00597         /*
00598         void openMIMEFile(const std::string& directory);
00599         */
00600         void setFromXMLFile(const std::string& directory);
00601         
00609         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00610   
00611         
00618          void setFromMIME(const std::string & mimeMsg);
00619         
00623         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00624         
00634           void toFile(std::string directory);
00635           
00639           bool loadInProgress;
00640           void checkPresenceInMemory() {
00641                 if (!presentInMemory && !loadInProgress) {
00642                         loadInProgress = true;
00643                         setFromFile(getContainer().getDirectory());
00644                         presentInMemory = true;
00645                         loadInProgress = false;
00646                 }
00647           }
00656          void setFromFile(const std::string& directory);        
00657  
00658 };
00659 
00660 } // End namespace asdm
00661 
00662 #endif /* ReceiverTable_CLASS */