casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PointingModelTable.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 PointingModelTable.h
00032  */
00033  
00034 #ifndef PointingModelTable_CLASS
00035 #define PointingModelTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047 
00048 
00049 
00050         
00051 
00052         
00053 
00054         
00055 
00056         
00057 
00058         
00059 #include "CPolarizationType.h"
00060         
00061 
00062         
00063 #include "CReceiverBand.h"
00064         
00065 
00066         
00067 
00068         
00069 
00070 
00071 
00072 #include <ConversionException.h>
00073 #include <DuplicateKey.h>
00074 #include <UniquenessViolationException.h>
00075 #include <NoSuchRow.h>
00076 #include <DuplicateKey.h>
00077 
00078 
00079 #ifndef WITHOUT_ACS
00080 #include <asdmIDLC.h>
00081 #endif
00082 
00083 #include <Representable.h>
00084 
00085 #include <pthread.h>
00086 
00087 namespace asdm {
00088 
00089 //class asdm::ASDM;
00090 //class asdm::PointingModelRow;
00091 
00092 class ASDM;
00093 class PointingModelRow;
00195 class PointingModelTable : public Representable {
00196         friend class ASDM;
00197 
00198 public:
00199 
00200 
00206         static const std::vector<std::string>& getKeyName();
00207 
00208 
00209         virtual ~PointingModelTable();
00210         
00216         ASDM &getContainer() const;
00217         
00223         unsigned int size() const;
00224         
00232         std::string getName() const;
00233         
00241         static std::string name() ;     
00242         
00247          std::string getVersion() const ;
00248         
00254          static const std::vector<std::string>& getAttributesNames();
00255 
00261          static const std::vector<std::string>& defaultAttributesNamesInBin();
00262          
00266         Entity getEntity() const;
00267 
00272         void setEntity(Entity e);
00273                 
00281         std::string toXML()  ;
00282 
00283 #ifndef WITHOUT_ACS
00284         // Conversion Methods
00290         asdmIDL::PointingModelTableIDL *toIDL() ;
00291         
00299          void toIDL(asdmIDL::PointingModelTableIDL& x) const;
00300          
00301 #endif
00302 
00303 #ifndef WITHOUT_ACS
00304 
00310         void fromIDL(asdmIDL::PointingModelTableIDL x) ;
00311 #endif
00312         
00313         //
00314         // ====> Row creation.
00315         //
00316         
00321         PointingModelRow *newRow();
00322         
00323         
00345         PointingModelRow *newRow(Tag antennaId, int numCoeff, vector<string > coeffName, vector<float > coeffVal, PolarizationTypeMod::PolarizationType polarizationType, ReceiverBandMod::ReceiverBand receiverBand, string assocNature, int assocPointingModelId);
00346         
00347 
00348 
00361          PointingModelRow *newRow(PointingModelRow *row); 
00362 
00363         //
00364         // ====> Append a row to its table.
00365         //
00366 
00367         
00368         
00369         
00379          PointingModelRow* add(PointingModelRow* x) ;
00380 
00381 
00382 
00383         //
00384         // ====> Methods returning rows.
00385         //
00386                 
00392         std::vector<PointingModelRow *> get() ;
00393         
00400          const std::vector<PointingModelRow *>& get() const ;
00401         
00402 
00403 
00404  
00405         
00417         PointingModelRow* getRowByKey(Tag antennaId, int pointingModelId);
00418 
00419                 
00420         
00428         std::vector <PointingModelRow *>  getRowByPointingModelId(int);
00429 
00430 
00431 
00455         PointingModelRow* lookup(Tag antennaId, int numCoeff, vector<string > coeffName, vector<float > coeffVal, PolarizationTypeMod::PolarizationType polarizationType, ReceiverBandMod::ReceiverBand receiverBand, string assocNature, int assocPointingModelId); 
00456 
00457 
00458         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00459         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00460 
00461 private:
00462 
00471         PointingModelTable (ASDM & container);
00472 
00473         ASDM & container;
00474         
00475         bool archiveAsBin; // If true archive binary else archive XML
00476         bool fileAsBin ; // If true file binary else file XML   
00477         
00478         std::string version ; 
00479         
00480         Entity entity;
00481         
00482 
00483         // A map for the autoincrementation algorithm
00484         std::map<std::string,int>  noAutoIncIds;
00485         void autoIncrement(std::string key, PointingModelRow* x);
00486 
00487 
00497         PointingModelRow* checkAndAdd(PointingModelRow* x, bool skipCheckUniqueness=false) ;
00498         
00504          void append(PointingModelRow* x) ;
00505          
00511          void addWithoutCheckingUnique(PointingModelRow* x) ;
00512          
00513          
00514 
00515 
00516 
00517 // A data structure to store the pointers on the table's rows.
00518 
00519 // In all cases we maintain a private vector of PointingModelRow s.
00520    std::vector<PointingModelRow * > privateRows;
00521    
00522 
00523                         
00524         std::vector<PointingModelRow *> row;
00525 
00526         
00527         void error() ; //throw(ConversionException);
00528 
00529         
00536         void fromXML(std::string& xmlDoc) ;
00537                 
00538         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00539 
00544         void setFromMIMEFile(const std::string& directory);
00545         /*
00546         void openMIMEFile(const std::string& directory);
00547         */
00548         void setFromXMLFile(const std::string& directory);
00549         
00557         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00558   
00559         
00566          void setFromMIME(const std::string & mimeMsg);
00567         
00571         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00572         
00582           void toFile(std::string directory);
00583           
00587           bool loadInProgress;
00588           void checkPresenceInMemory() {
00589                 if (!presentInMemory && !loadInProgress) {
00590                         loadInProgress = true;
00591                         setFromFile(getContainer().getDirectory());
00592                         presentInMemory = true;
00593                         loadInProgress = false;
00594                 }
00595           }
00604          void setFromFile(const std::string& directory);        
00605  
00606 };
00607 
00608 } // End namespace asdm
00609 
00610 #endif /* PointingModelTable_CLASS */