casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PointingTable.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 PointingTable.h
00032  */
00033  
00034 #ifndef PointingTable_CLASS
00035 #define PointingTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <Angle.h>
00049         
00050 
00051         
00052 #include <Tag.h>
00053         
00054 
00055         
00056 #include <ArrayTimeInterval.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 #include "CDirectionReferenceCode.h"
00088         
00089 
00090         
00091 
00092         
00093 
00094         
00095 
00096 
00097 
00098 #include <ConversionException.h>
00099 #include <DuplicateKey.h>
00100 #include <UniquenessViolationException.h>
00101 #include <NoSuchRow.h>
00102 #include <DuplicateKey.h>
00103 
00104 
00105 #ifndef WITHOUT_ACS
00106 #include <asdmIDLC.h>
00107 #endif
00108 
00109 #include <Representable.h>
00110 
00111 #include <pthread.h>
00112 
00113 namespace asdm {
00114 
00115 //class asdm::ASDM;
00116 //class asdm::PointingRow;
00117 
00118 class ASDM;
00119 class PointingRow;
00277 class PointingTable : public Representable {
00278         friend class ASDM;
00279 
00280 public:
00281 
00282 
00288         static const std::vector<std::string>& getKeyName();
00289 
00290 
00291         virtual ~PointingTable();
00292         
00298         ASDM &getContainer() const;
00299         
00305         unsigned int size() const;
00306         
00314         std::string getName() const;
00315         
00323         static std::string name() ;     
00324         
00329          std::string getVersion() const ;
00330         
00336          static const std::vector<std::string>& getAttributesNames();
00337 
00343          static const std::vector<std::string>& defaultAttributesNamesInBin();
00344          
00348         Entity getEntity() const;
00349 
00354         void setEntity(Entity e);
00355                 
00363         std::string toXML()  ;
00364 
00365 #ifndef WITHOUT_ACS
00366         // Conversion Methods
00372         asdmIDL::PointingTableIDL *toIDL() ;
00373         
00381          void toIDL(asdmIDL::PointingTableIDL& x) const;
00382          
00383 #endif
00384 
00385 #ifndef WITHOUT_ACS
00386 
00392         void fromIDL(asdmIDL::PointingTableIDL x) ;
00393 #endif
00394         
00395         //
00396         // ====> Row creation.
00397         //
00398         
00403         PointingRow *newRow();
00404         
00405         
00435         PointingRow *newRow(Tag antennaId, ArrayTimeInterval timeInterval, int numSample, vector<vector<Angle > > encoder, bool pointingTracking, bool usePolynomials, ArrayTime timeOrigin, int numTerm, vector<vector<Angle > > pointingDirection, vector<vector<Angle > > target, vector<vector<Angle > > offset, int pointingModelId);
00436         
00437 
00438 
00451          PointingRow *newRow(PointingRow *row); 
00452 
00453         //
00454         // ====> Append a row to its table.
00455         //
00456  
00457         
00474         PointingRow* add(PointingRow* x) ; 
00475 
00476  
00477 
00478 
00479 
00480         //
00481         // ====> Methods returning rows.
00482         //
00483                 
00489         std::vector<PointingRow *> get() ;
00490         
00497          const std::vector<PointingRow *>& get() const ;
00498         
00499 
00510          std::vector <PointingRow*> *getByContext(Tag antennaId);
00511          
00512 
00513 
00514  
00515         
00527         PointingRow* getRowByKey(Tag antennaId, ArrayTimeInterval timeInterval);
00528 
00529                 
00530 
00531 
00532 
00564         PointingRow* lookup(Tag antennaId, ArrayTimeInterval timeInterval, int numSample, vector<vector<Angle > > encoder, bool pointingTracking, bool usePolynomials, ArrayTime timeOrigin, int numTerm, vector<vector<Angle > > pointingDirection, vector<vector<Angle > > target, vector<vector<Angle > > offset, int pointingModelId); 
00565 
00566 
00567         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00568         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00569 
00570 private:
00571 
00580         PointingTable (ASDM & container);
00581 
00582         ASDM & container;
00583         
00584         bool archiveAsBin; // If true archive binary else archive XML
00585         bool fileAsBin ; // If true file binary else file XML   
00586         
00587         std::string version ; 
00588         
00589         Entity entity;
00590         
00591 
00592 
00600         PointingRow* checkAndAdd(PointingRow* x, bool skipCheckUniqueness=false) ;
00601         
00607          void append(PointingRow* x) ;
00608          
00614          void addWithoutCheckingUnique(PointingRow* x) ;
00615          
00616          
00617 
00618 
00619         
00620         
00628          PointingRow * insertByStartTime(PointingRow* x, std::vector<PointingRow* >& row);
00629           
00630 
00631 
00632 // A data structure to store the pointers on the table's rows.
00633 
00634 // In all cases we maintain a private vector of PointingRow s.
00635    std::vector<PointingRow * > privateRows;
00636    
00637 
00638         
00639 
00640         
00641         
00642                 
00643                                 
00644         typedef std::vector <PointingRow* > TIME_ROWS;
00645         std::map<std::string, TIME_ROWS > context;
00646                 
00651          std::string Key(Tag antennaId) ;
00652                  
00653                 
00654         
00655         
00661         void getByKeyNoAutoIncNoTime(std::vector <PointingRow*>& vin, std::vector <PointingRow*>& vout,  Tag antennaId);
00662         
00663 
00664         
00665         void error() ; //throw(ConversionException);
00666 
00667         
00674         void fromXML(std::string& xmlDoc) ;
00675                 
00676         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00677 
00682         void setFromMIMEFile(const std::string& directory);
00683         /*
00684         void openMIMEFile(const std::string& directory);
00685         */
00686         void setFromXMLFile(const std::string& directory);
00687         
00695         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00696   
00697         
00704          void setFromMIME(const std::string & mimeMsg);
00705         
00709         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00710         
00720           void toFile(std::string directory);
00721           
00725           bool loadInProgress;
00726           void checkPresenceInMemory() {
00727                 if (!presentInMemory && !loadInProgress) {
00728                         loadInProgress = true;
00729                         setFromFile(getContainer().getDirectory());
00730                         presentInMemory = true;
00731                         loadInProgress = false;
00732                 }
00733           }
00742          void setFromFile(const std::string& directory);        
00743  
00744 };
00745 
00746 } // End namespace asdm
00747 
00748 #endif /* PointingTable_CLASS */