casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SysCalTable.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 SysCalTable.h
00032  */
00033  
00034 #ifndef SysCalTable_CLASS
00035 #define SysCalTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047         
00048 #include <Temperature.h>
00049         
00050 
00051         
00052 #include <ArrayTimeInterval.h>
00053         
00054 
00055 
00056 
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 
00078         
00079 
00080         
00081 
00082         
00083 
00084         
00085 
00086         
00087 
00088         
00089 
00090         
00091 
00092 
00093 
00094 #include <ConversionException.h>
00095 #include <DuplicateKey.h>
00096 #include <UniquenessViolationException.h>
00097 #include <NoSuchRow.h>
00098 #include <DuplicateKey.h>
00099 
00100 
00101 #ifndef WITHOUT_ACS
00102 #include <asdmIDLC.h>
00103 #endif
00104 
00105 #include <Representable.h>
00106 
00107 namespace asdm {
00108 
00109 //class asdm::ASDM;
00110 //class asdm::SysCalRow;
00111 
00112 class ASDM;
00113 class SysCalRow;
00289 class SysCalTable : public Representable {
00290         friend class ASDM;
00291 
00292 public:
00293 
00294 
00300         static std::vector<std::string> getKeyName();
00301 
00302 
00303         virtual ~SysCalTable();
00304         
00310         ASDM &getContainer() const;
00311         
00317         unsigned int size() const;
00318         
00326         std::string getName() const;
00327         
00335         static std::string name() ;     
00336         
00341          std::string getVersion() const ;
00342         
00348          static const std::vector<std::string>& getAttributesNames();
00349 
00355          static const std::vector<std::string>& defaultAttributesNamesInBin();
00356          
00360         Entity getEntity() const;
00361 
00366         void setEntity(Entity e);
00367                 
00375         std::string toXML()  ;
00376 
00377 #ifndef WITHOUT_ACS
00378         // Conversion Methods
00384         asdmIDL::SysCalTableIDL *toIDL() ;
00385 #endif
00386 
00387 #ifndef WITHOUT_ACS
00388 
00394         void fromIDL(asdmIDL::SysCalTableIDL x) ;
00395 #endif
00396         
00397         //
00398         // ====> Row creation.
00399         //
00400         
00405         SysCalRow *newRow();
00406         
00407         
00425         SysCalRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, int numChan);
00426         
00427 
00428 
00441          SysCalRow *newRow(SysCalRow *row); 
00442 
00443         //
00444         // ====> Append a row to its table.
00445         //
00446  
00447         
00464         SysCalRow* add(SysCalRow* x) ; 
00465 
00466  
00467 
00468 
00469 
00470         //
00471         // ====> Methods returning rows.
00472         //
00473                 
00479         std::vector<SysCalRow *> get() ;
00480         
00487          const std::vector<SysCalRow *>& get() const ;
00488         
00489 
00500          std::vector <SysCalRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
00501          
00502 
00503 
00504  
00505         
00521         SysCalRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
00522 
00523                 
00524 
00525 
00526 
00546         SysCalRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, int numChan); 
00547 
00548 
00549         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00550         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00551 
00552 private:
00553 
00562         SysCalTable (ASDM & container);
00563 
00564         ASDM & container;
00565         
00566         bool archiveAsBin; // If true archive binary else archive XML
00567         bool fileAsBin ; // If true file binary else file XML   
00568         
00569         std::string version ; 
00570         
00571         Entity entity;
00572         
00573 
00574 
00578         static std::string itsName;
00579         
00583         static std::vector<std::string> attributesNames;
00584         
00588         static std::vector<std::string> attributesNamesInBin;
00589         
00590 
00594         static bool initAttributesNames(), initAttributesNamesDone ;
00595         
00596 
00600         static std::vector<std::string> key;
00601 
00602 
00610         SysCalRow* checkAndAdd(SysCalRow* x) ;
00611         
00617          void append(SysCalRow* x) ;
00618          
00624          void addWithoutCheckingUnique(SysCalRow* x) ;
00625          
00626          
00627 
00628 
00629         
00630         
00638          SysCalRow * insertByStartTime(SysCalRow* x, std::vector<SysCalRow* >& row);
00639           
00640 
00641 
00642 // A data structure to store the pointers on the table's rows.
00643 
00644 // In all cases we maintain a private vector of SysCalRow s.
00645    std::vector<SysCalRow * > privateRows;
00646    
00647 
00648         
00649 
00650         
00651         
00652                 
00653                                 
00654         typedef std::vector <SysCalRow* > TIME_ROWS;
00655         std::map<std::string, TIME_ROWS > context;
00656                 
00661          std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
00662                  
00663                 
00664         
00665         
00671         void getByKeyNoAutoIncNoTime(std::vector <SysCalRow*>& vin, std::vector <SysCalRow*>& vout,  Tag antennaId, Tag spectralWindowId, int feedId);
00672         
00673 
00674         
00675         void error() ; //throw(ConversionException);
00676 
00677         
00684         void fromXML(std::string& xmlDoc) ;
00685                 
00686         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00687 
00692         void setFromMIMEFile(const std::string& directory);
00693         /*
00694         void openMIMEFile(const std::string& directory);
00695         */
00696         void setFromXMLFile(const std::string& directory);
00697         
00705         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00706   
00707         
00714          void setFromMIME(const std::string & mimeMsg);
00715         
00719         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00720         
00730           void toFile(std::string directory);
00731           
00735           bool loadInProgress;
00736           void checkPresenceInMemory() {
00737                 if (!presentInMemory && !loadInProgress) {
00738                         loadInProgress = true;
00739                         setFromFile(getContainer().getDirectory());
00740                         presentInMemory = true;
00741                         loadInProgress = false;
00742                 }
00743           }
00752          void setFromFile(const std::string& directory);        
00753  
00754 };
00755 
00756 } // End namespace asdm
00757 
00758 #endif /* SysCalTable_CLASS */