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 #include <pthread.h>
00096 
00097 namespace asdm {
00098 
00099 //class asdm::ASDM;
00100 //class asdm::ReceiverRow;
00101 
00102 class ASDM;
00103 class ReceiverRow;
00197 class ReceiverTable : public Representable {
00198         friend class ASDM;
00199 
00200 public:
00201 
00202 
00208         static const std::vector<std::string>& getKeyName();
00209 
00210 
00211         virtual ~ReceiverTable();
00212         
00218         ASDM &getContainer() const;
00219         
00225         unsigned int size() const;
00226         
00234         std::string getName() const;
00235         
00243         static std::string name() ;     
00244         
00249          std::string getVersion() const ;
00250         
00256          static const std::vector<std::string>& getAttributesNames();
00257 
00263          static const std::vector<std::string>& defaultAttributesNamesInBin();
00264          
00268         Entity getEntity() const;
00269 
00274         void setEntity(Entity e);
00275                 
00283         std::string toXML()  ;
00284 
00285 #ifndef WITHOUT_ACS
00286         // Conversion Methods
00292         asdmIDL::ReceiverTableIDL *toIDL() ;
00293         
00301          void toIDL(asdmIDL::ReceiverTableIDL& x) const;
00302          
00303 #endif
00304 
00305 #ifndef WITHOUT_ACS
00306 
00312         void fromIDL(asdmIDL::ReceiverTableIDL x) ;
00313 #endif
00314         
00315         //
00316         // ====> Row creation.
00317         //
00318         
00323         ReceiverRow *newRow();
00324         
00325         
00347         ReceiverRow *newRow(Tag spectralWindowId, ArrayTimeInterval timeInterval, string name, int numLO, ReceiverBandMod::ReceiverBand frequencyBand, vector<Frequency > freqLO, ReceiverSidebandMod::ReceiverSideband receiverSideband, vector<NetSidebandMod::NetSideband > sidebandLO);
00348         
00349 
00350 
00363          ReceiverRow *newRow(ReceiverRow *row); 
00364 
00365         //
00366         // ====> Append a row to its table.
00367         //
00368 
00369         
00370          
00371         
00372         
00382          ReceiverRow* add(ReceiverRow* x) ;
00383 
00384 
00385 
00386         //
00387         // ====> Methods returning rows.
00388         //
00389                 
00395         std::vector<ReceiverRow *> get() ;
00396         
00403          const std::vector<ReceiverRow *>& get() const ;
00404         
00405 
00406 
00407  
00408         
00422         ReceiverRow* getRowByKey(int receiverId, Tag spectralWindowId, ArrayTimeInterval timeInterval);
00423 
00424                 
00425         
00433         std::vector <ReceiverRow *>  getRowByReceiverId(int);
00434 
00435 
00436 
00460         ReceiverRow* lookup(Tag spectralWindowId, ArrayTimeInterval timeInterval, string name, int numLO, ReceiverBandMod::ReceiverBand frequencyBand, vector<Frequency > freqLO, ReceiverSidebandMod::ReceiverSideband receiverSideband, vector<NetSidebandMod::NetSideband > sidebandLO); 
00461 
00462 
00463         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00464         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00465 
00466 private:
00467 
00476         ReceiverTable (ASDM & container);
00477 
00478         ASDM & container;
00479         
00480         bool archiveAsBin; // If true archive binary else archive XML
00481         bool fileAsBin ; // If true file binary else file XML   
00482         
00483         std::string version ; 
00484         
00485         Entity entity;
00486         
00487 
00488 
00498         ReceiverRow* checkAndAdd(ReceiverRow* x, bool skipCheckUniqueness=false) ;
00499         
00505          void append(ReceiverRow* x) ;
00506          
00512          void addWithoutCheckingUnique(ReceiverRow* x) ;
00513          
00514          
00515 
00516 
00517         
00518         
00526          ReceiverRow * insertByStartTime(ReceiverRow* x, std::vector<ReceiverRow* >& row);
00527           
00528 
00529 
00530 // A data structure to store the pointers on the table's rows.
00531 
00532 // In all cases we maintain a private vector of ReceiverRow s.
00533    std::vector<ReceiverRow * > privateRows;
00534    
00535 
00536         
00537 
00538         
00539         
00540                 
00541                 
00542         typedef std::vector <std::vector <ReceiverRow* > > ID_TIME_ROWS;
00543         std::map<std::string, ID_TIME_ROWS > context;
00544         
00549          std::string Key(Tag spectralWindowId) ;
00550                 
00551                 
00552         
00553         
00559         void getByKeyNoAutoIncNoTime(std::vector <ReceiverRow*>& vin, std::vector <ReceiverRow*>& vout,  Tag spectralWindowId);
00560         
00561 
00562         
00563         void error() ; //throw(ConversionException);
00564 
00565         
00572         void fromXML(std::string& xmlDoc) ;
00573                 
00574         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00575 
00580         void setFromMIMEFile(const std::string& directory);
00581         /*
00582         void openMIMEFile(const std::string& directory);
00583         */
00584         void setFromXMLFile(const std::string& directory);
00585         
00593         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00594   
00595         
00602          void setFromMIME(const std::string & mimeMsg);
00603         
00607         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00608         
00618           void toFile(std::string directory);
00619           
00623           bool loadInProgress;
00624           void checkPresenceInMemory() {
00625                 if (!presentInMemory && !loadInProgress) {
00626                         loadInProgress = true;
00627                         setFromFile(getContainer().getDirectory());
00628                         presentInMemory = true;
00629                         loadInProgress = false;
00630                 }
00631           }
00640          void setFromFile(const std::string& directory);        
00641  
00642 };
00643 
00644 } // End namespace asdm
00645 
00646 #endif /* ReceiverTable_CLASS */