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 #include <pthread.h>
00102 
00103 namespace asdm {
00104 
00105 //class asdm::ASDM;
00106 //class asdm::TotalPowerRow;
00107 
00108 class ASDM;
00109 class TotalPowerRow;
00255 class TotalPowerTable : public Representable {
00256         friend class ASDM;
00257 
00258 public:
00259 
00260 
00266         static const std::vector<std::string>& getKeyName();
00267 
00268 
00269         virtual ~TotalPowerTable();
00270         
00276         ASDM &getContainer() const;
00277         
00283         unsigned int size() const;
00284         
00292         std::string getName() const;
00293         
00301         static std::string name() ;     
00302         
00307          std::string getVersion() const ;
00308         
00314          static const std::vector<std::string>& getAttributesNames();
00315 
00321          static const std::vector<std::string>& defaultAttributesNamesInBin();
00322          
00326         Entity getEntity() const;
00327 
00332         void setEntity(Entity e);
00333                 
00341         std::string toXML()  ;
00342 
00343 #ifndef WITHOUT_ACS
00344         // Conversion Methods
00350         asdmIDL::TotalPowerTableIDL *toIDL() ;
00351         
00359          void toIDL(asdmIDL::TotalPowerTableIDL& x) const;
00360          
00361 #endif
00362 
00363 #ifndef WITHOUT_ACS
00364 
00370         void fromIDL(asdmIDL::TotalPowerTableIDL x) ;
00371 #endif
00372         
00373         //
00374         // ====> Row creation.
00375         //
00376         
00381         TotalPowerRow *newRow();
00382         
00383         
00419         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);
00420         
00421 
00422 
00435          TotalPowerRow *newRow(TotalPowerRow *row); 
00436 
00437         //
00438         // ====> Append a row to its table.
00439         //
00440  
00441         
00458         TotalPowerRow* add(TotalPowerRow* x) ; 
00459 
00460  
00461 
00462 
00463 
00464         //
00465         // ====> Methods returning rows.
00466         //
00467                 
00473         std::vector<TotalPowerRow *> get() ;
00474         
00481          const std::vector<TotalPowerRow *>& get() const ;
00482         
00483 
00494          std::vector <TotalPowerRow*> *getByContext(Tag configDescriptionId, Tag fieldId);
00495          
00496 
00497 
00498  
00499         
00513         TotalPowerRow* getRowByKey(ArrayTime time, Tag configDescriptionId, Tag fieldId);
00514 
00515                 
00516 
00517 
00518 
00556         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); 
00557 
00558 
00559         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00560         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00561 
00562 private:
00563 
00572         TotalPowerTable (ASDM & container);
00573 
00574         ASDM & container;
00575         
00576         bool archiveAsBin; // If true archive binary else archive XML
00577         bool fileAsBin ; // If true file binary else file XML   
00578         
00579         std::string version ; 
00580         
00581         Entity entity;
00582         
00583 
00584 
00592         TotalPowerRow* checkAndAdd(TotalPowerRow* x, bool skipCheckUniqueness=false) ;
00593         
00599          void append(TotalPowerRow* x) ;
00600          
00606          void addWithoutCheckingUnique(TotalPowerRow* x) ;
00607          
00608          
00609 
00610 
00611         
00612         
00620         TotalPowerRow * insertByTime(TotalPowerRow* x, std::vector<TotalPowerRow *>&row );
00621          
00622 
00623 
00624 // A data structure to store the pointers on the table's rows.
00625 
00626 // In all cases we maintain a private vector of TotalPowerRow s.
00627    std::vector<TotalPowerRow * > privateRows;
00628    
00629 
00630         
00631 
00632         
00633         
00634                 
00635                                 
00636         typedef std::vector <TotalPowerRow* > TIME_ROWS;
00637         std::map<std::string, TIME_ROWS > context;
00638                 
00643          std::string Key(Tag configDescriptionId, Tag fieldId) ;
00644                  
00645                 
00646         
00647         
00653         void getByKeyNoAutoIncNoTime(std::vector <TotalPowerRow*>& vin, std::vector <TotalPowerRow*>& vout,  Tag configDescriptionId, Tag fieldId);
00654         
00655 
00656         
00657         void error() ; //throw(ConversionException);
00658 
00659         
00666         void fromXML(std::string& xmlDoc) ;
00667                 
00668         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00669 
00674         void setFromMIMEFile(const std::string& directory);
00675         /*
00676         void openMIMEFile(const std::string& directory);
00677         */
00678         void setFromXMLFile(const std::string& directory);
00679         
00687         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00688   
00689         
00696          void setFromMIME(const std::string & mimeMsg);
00697         
00701         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00702         
00712           void toFile(std::string directory);
00713           
00717           bool loadInProgress;
00718           void checkPresenceInMemory() {
00719                 if (!presentInMemory && !loadInProgress) {
00720                         loadInProgress = true;
00721                         setFromFile(getContainer().getDirectory());
00722                         presentInMemory = true;
00723                         loadInProgress = false;
00724                 }
00725           }
00734          void setFromFile(const std::string& directory);        
00735  
00736 };
00737 
00738 } // End namespace asdm
00739 
00740 #endif /* TotalPowerTable_CLASS */