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 namespace asdm {
00086 
00087 //class asdm::ASDM;
00088 //class asdm::PointingModelRow;
00089 
00090 class ASDM;
00091 class PointingModelRow;
00193 class PointingModelTable : public Representable {
00194         friend class ASDM;
00195 
00196 public:
00197 
00198 
00204         static std::vector<std::string> getKeyName();
00205 
00206 
00207         virtual ~PointingModelTable();
00208         
00214         ASDM &getContainer() const;
00215         
00221         unsigned int size() const;
00222         
00230         std::string getName() const;
00231         
00239         static std::string name() ;     
00240         
00245          std::string getVersion() const ;
00246         
00252          static const std::vector<std::string>& getAttributesNames();
00253 
00259          static const std::vector<std::string>& defaultAttributesNamesInBin();
00260          
00264         Entity getEntity() const;
00265 
00270         void setEntity(Entity e);
00271                 
00279         std::string toXML()  ;
00280 
00281 #ifndef WITHOUT_ACS
00282         // Conversion Methods
00288         asdmIDL::PointingModelTableIDL *toIDL() ;
00289 #endif
00290 
00291 #ifndef WITHOUT_ACS
00292 
00298         void fromIDL(asdmIDL::PointingModelTableIDL x) ;
00299 #endif
00300         
00301         //
00302         // ====> Row creation.
00303         //
00304         
00309         PointingModelRow *newRow();
00310         
00311         
00333         PointingModelRow *newRow(Tag antennaId, int numCoeff, vector<string > coeffName, vector<float > coeffVal, PolarizationTypeMod::PolarizationType polarizationType, ReceiverBandMod::ReceiverBand receiverBand, string assocNature, int assocPointingModelId);
00334         
00335 
00336 
00349          PointingModelRow *newRow(PointingModelRow *row); 
00350 
00351         //
00352         // ====> Append a row to its table.
00353         //
00354 
00355         
00356         
00357         
00367          PointingModelRow* add(PointingModelRow* x) ;
00368 
00369 
00370 
00371         //
00372         // ====> Methods returning rows.
00373         //
00374                 
00380         std::vector<PointingModelRow *> get() ;
00381         
00388          const std::vector<PointingModelRow *>& get() const ;
00389         
00390 
00391 
00392  
00393         
00405         PointingModelRow* getRowByKey(Tag antennaId, int pointingModelId);
00406 
00407                 
00408         
00416         std::vector <PointingModelRow *>  getRowByPointingModelId(int);
00417 
00418 
00419 
00443         PointingModelRow* lookup(Tag antennaId, int numCoeff, vector<string > coeffName, vector<float > coeffVal, PolarizationTypeMod::PolarizationType polarizationType, ReceiverBandMod::ReceiverBand receiverBand, string assocNature, int assocPointingModelId); 
00444 
00445 
00446         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00447         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00448 
00449 private:
00450 
00459         PointingModelTable (ASDM & container);
00460 
00461         ASDM & container;
00462         
00463         bool archiveAsBin; // If true archive binary else archive XML
00464         bool fileAsBin ; // If true file binary else file XML   
00465         
00466         std::string version ; 
00467         
00468         Entity entity;
00469         
00470 
00471         // A map for the autoincrementation algorithm
00472         std::map<std::string,int>  noAutoIncIds;
00473         void autoIncrement(std::string key, PointingModelRow* x);
00474 
00475 
00479         static std::string itsName;
00480         
00484         static std::vector<std::string> attributesNames;
00485         
00489         static std::vector<std::string> attributesNamesInBin;
00490         
00491 
00495         static bool initAttributesNames(), initAttributesNamesDone ;
00496         
00497 
00501         static std::vector<std::string> key;
00502 
00503 
00513         PointingModelRow* checkAndAdd(PointingModelRow* x) ;
00514         
00520          void append(PointingModelRow* x) ;
00521          
00527          void addWithoutCheckingUnique(PointingModelRow* x) ;
00528          
00529          
00530 
00531 
00532 
00533 // A data structure to store the pointers on the table's rows.
00534 
00535 // In all cases we maintain a private vector of PointingModelRow s.
00536    std::vector<PointingModelRow * > privateRows;
00537    
00538 
00539                         
00540         std::vector<PointingModelRow *> row;
00541 
00542         
00543         void error() ; //throw(ConversionException);
00544 
00545         
00552         void fromXML(std::string& xmlDoc) ;
00553                 
00554         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00555 
00560         void setFromMIMEFile(const std::string& directory);
00561         /*
00562         void openMIMEFile(const std::string& directory);
00563         */
00564         void setFromXMLFile(const std::string& directory);
00565         
00573         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00574   
00575         
00582          void setFromMIME(const std::string & mimeMsg);
00583         
00587         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00588         
00598           void toFile(std::string directory);
00599           
00603           bool loadInProgress;
00604           void checkPresenceInMemory() {
00605                 if (!presentInMemory && !loadInProgress) {
00606                         loadInProgress = true;
00607                         setFromFile(getContainer().getDirectory());
00608                         presentInMemory = true;
00609                         loadInProgress = false;
00610                 }
00611           }
00620          void setFromFile(const std::string& directory);        
00621  
00622 };
00623 
00624 } // End namespace asdm
00625 
00626 #endif /* PointingModelTable_CLASS */