casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TotalPowerTable.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 TotalPowerTable.h
00032  */
00033  
00034 #ifndef TotalPowerTable_CLASS
00035 #define TotalPowerTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <Interval.h>
00049         
00050 
00051         
00052 #include <Tag.h>
00053         
00054 
00055         
00056 #include <Length.h>
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 #include <ConversionException.h>
00089 #include <DuplicateKey.h>
00090 #include <UniquenessViolationException.h>
00091 #include <NoSuchRow.h>
00092 #include <DuplicateKey.h>
00093 
00094 
00095 #ifndef WITHOUT_ACS
00096 #include <asdmIDLC.h>
00097 #endif
00098 
00099 #include <Representable.h>
00100 
00101 namespace asdm {
00102 
00103 //class asdm::ASDM;
00104 //class asdm::TotalPowerRow;
00105 
00106 class ASDM;
00107 class TotalPowerRow;
00253 class TotalPowerTable : public Representable {
00254         friend class ASDM;
00255 
00256 public:
00257 
00258 
00264         static std::vector<std::string> getKeyName();
00265 
00266 
00267         virtual ~TotalPowerTable();
00268         
00274         ASDM &getContainer() const;
00275         
00281         unsigned int size() const;
00282         
00290         std::string getName() const;
00291         
00299         static std::string name() ;     
00300         
00305          std::string getVersion() const ;
00306         
00312          static const std::vector<std::string>& getAttributesNames();
00313 
00319          static const std::vector<std::string>& defaultAttributesNamesInBin();
00320          
00324         Entity getEntity() const;
00325 
00330         void setEntity(Entity e);
00331                 
00339         std::string toXML()  ;
00340 
00341 #ifndef WITHOUT_ACS
00342         // Conversion Methods
00348         asdmIDL::TotalPowerTableIDL *toIDL() ;
00349 #endif
00350 
00351 #ifndef WITHOUT_ACS
00352 
00358         void fromIDL(asdmIDL::TotalPowerTableIDL x) ;
00359 #endif
00360         
00361         //
00362         // ====> Row creation.
00363         //
00364         
00369         TotalPowerRow *newRow();
00370         
00371         
00407         TotalPowerRow *newRow(ArrayTime time, Tag configDescriptionId, Tag fieldId, int scanNumber, int subscanNumber, int integrationNumber, vector<vector<Length > > uvw, vector<vector<Interval > > exposure, vector<vector<ArrayTime > > timeCentroid, vector<vector<vector<float > > > floatData, vector<int > flagAnt, vector<vector<int > > flagPol, Interval interval, vector<Tag>  stateId, Tag execBlockId);
00408         
00409 
00410 
00423          TotalPowerRow *newRow(TotalPowerRow *row); 
00424 
00425         //
00426         // ====> Append a row to its table.
00427         //
00428  
00429         
00446         TotalPowerRow* add(TotalPowerRow* x) ; 
00447 
00448  
00449 
00450 
00451 
00452         //
00453         // ====> Methods returning rows.
00454         //
00455                 
00461         std::vector<TotalPowerRow *> get() ;
00462         
00469          const std::vector<TotalPowerRow *>& get() const ;
00470         
00471 
00482          std::vector <TotalPowerRow*> *getByContext(Tag configDescriptionId, Tag fieldId);
00483          
00484 
00485 
00486  
00487         
00501         TotalPowerRow* getRowByKey(ArrayTime time, Tag configDescriptionId, Tag fieldId);
00502 
00503                 
00504 
00505 
00506 
00544         TotalPowerRow* lookup(ArrayTime time, Tag configDescriptionId, Tag fieldId, int scanNumber, int subscanNumber, int integrationNumber, vector<vector<Length > > uvw, vector<vector<Interval > > exposure, vector<vector<ArrayTime > > timeCentroid, vector<vector<vector<float > > > floatData, vector<int > flagAnt, vector<vector<int > > flagPol, Interval interval, vector<Tag>  stateId, Tag execBlockId); 
00545 
00546 
00547         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00548         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00549 
00550 private:
00551 
00560         TotalPowerTable (ASDM & container);
00561 
00562         ASDM & container;
00563         
00564         bool archiveAsBin; // If true archive binary else archive XML
00565         bool fileAsBin ; // If true file binary else file XML   
00566         
00567         std::string version ; 
00568         
00569         Entity entity;
00570         
00571 
00572 
00576         static std::string itsName;
00577         
00581         static std::vector<std::string> attributesNames;
00582         
00586         static std::vector<std::string> attributesNamesInBin;
00587         
00588 
00592         static bool initAttributesNames(), initAttributesNamesDone ;
00593         
00594 
00598         static std::vector<std::string> key;
00599 
00600 
00608         TotalPowerRow* checkAndAdd(TotalPowerRow* x) ;
00609         
00615          void append(TotalPowerRow* x) ;
00616          
00622          void addWithoutCheckingUnique(TotalPowerRow* x) ;
00623          
00624          
00625 
00626 
00627         
00628         
00636         TotalPowerRow * insertByTime(TotalPowerRow* x, std::vector<TotalPowerRow *>&row );
00637          
00638 
00639 
00640 // A data structure to store the pointers on the table's rows.
00641 
00642 // In all cases we maintain a private vector of TotalPowerRow s.
00643    std::vector<TotalPowerRow * > privateRows;
00644    
00645 
00646         
00647 
00648         
00649         
00650                 
00651                                 
00652         typedef std::vector <TotalPowerRow* > TIME_ROWS;
00653         std::map<std::string, TIME_ROWS > context;
00654                 
00659          std::string Key(Tag configDescriptionId, Tag fieldId) ;
00660                  
00661                 
00662         
00663         
00669         void getByKeyNoAutoIncNoTime(std::vector <TotalPowerRow*>& vin, std::vector <TotalPowerRow*>& vout,  Tag configDescriptionId, Tag fieldId);
00670         
00671 
00672         
00673         void error() ; //throw(ConversionException);
00674 
00675         
00682         void fromXML(std::string& xmlDoc) ;
00683                 
00684         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00685 
00690         void setFromMIMEFile(const std::string& directory);
00691         /*
00692         void openMIMEFile(const std::string& directory);
00693         */
00694         void setFromXMLFile(const std::string& directory);
00695         
00703         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00704   
00705         
00712          void setFromMIME(const std::string & mimeMsg);
00713         
00717         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00718         
00728           void toFile(std::string directory);
00729           
00733           bool loadInProgress;
00734           void checkPresenceInMemory() {
00735                 if (!presentInMemory && !loadInProgress) {
00736                         loadInProgress = true;
00737                         setFromFile(getContainer().getDirectory());
00738                         presentInMemory = true;
00739                         loadInProgress = false;
00740                 }
00741           }
00750          void setFromFile(const std::string& directory);        
00751  
00752 };
00753 
00754 } // End namespace asdm
00755 
00756 #endif /* TotalPowerTable_CLASS */