casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FocusModelTable.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 FocusModelTable.h
00032  */
00033  
00034 #ifndef FocusModelTable_CLASS
00035 #define FocusModelTable_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 #include "CPolarizationType.h"
00054         
00055 
00056         
00057 #include "CReceiverBand.h"
00058         
00059 
00060         
00061 
00062         
00063 
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::FocusModelRow;
00091 
00092 class ASDM;
00093 class FocusModelRow;
00192 class FocusModelTable : public Representable {
00193         friend class ASDM;
00194 
00195 public:
00196 
00197 
00203         static const std::vector<std::string>& getKeyName();
00204 
00205 
00206         virtual ~FocusModelTable();
00207         
00213         ASDM &getContainer() const;
00214         
00220         unsigned int size() const;
00221         
00229         std::string getName() const;
00230         
00238         static std::string name() ;     
00239         
00244          std::string getVersion() const ;
00245         
00251          static const std::vector<std::string>& getAttributesNames();
00252 
00258          static const std::vector<std::string>& defaultAttributesNamesInBin();
00259          
00263         Entity getEntity() const;
00264 
00269         void setEntity(Entity e);
00270                 
00278         std::string toXML()  ;
00279 
00280 #ifndef WITHOUT_ACS
00281         // Conversion Methods
00287         asdmIDL::FocusModelTableIDL *toIDL() ;
00288         
00296          void toIDL(asdmIDL::FocusModelTableIDL& x) const;
00297          
00298 #endif
00299 
00300 #ifndef WITHOUT_ACS
00301 
00307         void fromIDL(asdmIDL::FocusModelTableIDL x) ;
00308 #endif
00309         
00310         //
00311         // ====> Row creation.
00312         //
00313         
00318         FocusModelRow *newRow();
00319         
00320         
00344         FocusModelRow *newRow(Tag antennaId, PolarizationTypeMod::PolarizationType polarizationType, ReceiverBandMod::ReceiverBand receiverBand, int numCoeff, vector<string > coeffName, vector<string > coeffFormula, vector<float > coeffVal, string assocNature, int assocFocusModelId);
00345         
00346 
00347 
00360          FocusModelRow *newRow(FocusModelRow *row); 
00361 
00362         //
00363         // ====> Append a row to its table.
00364         //
00365 
00366         
00367         
00368         
00378          FocusModelRow* add(FocusModelRow* x) ;
00379 
00380 
00381 
00382         //
00383         // ====> Methods returning rows.
00384         //
00385                 
00391         std::vector<FocusModelRow *> get() ;
00392         
00399          const std::vector<FocusModelRow *>& get() const ;
00400         
00401 
00402 
00403  
00404         
00416         FocusModelRow* getRowByKey(Tag antennaId, int focusModelId);
00417 
00418                 
00419         
00427         std::vector <FocusModelRow *>  getRowByFocusModelId(int);
00428 
00429 
00430 
00456         FocusModelRow* lookup(Tag antennaId, PolarizationTypeMod::PolarizationType polarizationType, ReceiverBandMod::ReceiverBand receiverBand, int numCoeff, vector<string > coeffName, vector<string > coeffFormula, vector<float > coeffVal, string assocNature, int assocFocusModelId); 
00457 
00458 
00459         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00460         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00461 
00462 private:
00463 
00472         FocusModelTable (ASDM & container);
00473 
00474         ASDM & container;
00475         
00476         bool archiveAsBin; // If true archive binary else archive XML
00477         bool fileAsBin ; // If true file binary else file XML   
00478         
00479         std::string version ; 
00480         
00481         Entity entity;
00482         
00483 
00484         // A map for the autoincrementation algorithm
00485         std::map<std::string,int>  noAutoIncIds;
00486         void autoIncrement(std::string key, FocusModelRow* x);
00487 
00488 
00498         FocusModelRow* checkAndAdd(FocusModelRow* x, bool skipCheckUniqueness=false) ;
00499         
00505          void append(FocusModelRow* x) ;
00506          
00512          void addWithoutCheckingUnique(FocusModelRow* x) ;
00513          
00514          
00515 
00516 
00517 
00518 // A data structure to store the pointers on the table's rows.
00519 
00520 // In all cases we maintain a private vector of FocusModelRow s.
00521    std::vector<FocusModelRow * > privateRows;
00522    
00523 
00524                         
00525         std::vector<FocusModelRow *> row;
00526 
00527         
00528         void error() ; //throw(ConversionException);
00529 
00530         
00537         void fromXML(std::string& xmlDoc) ;
00538                 
00539         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00540 
00545         void setFromMIMEFile(const std::string& directory);
00546         /*
00547         void openMIMEFile(const std::string& directory);
00548         */
00549         void setFromXMLFile(const std::string& directory);
00550         
00558         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00559   
00560         
00567          void setFromMIME(const std::string & mimeMsg);
00568         
00572         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00573         
00583           void toFile(std::string directory);
00584           
00588           bool loadInProgress;
00589           void checkPresenceInMemory() {
00590                 if (!presentInMemory && !loadInProgress) {
00591                         loadInProgress = true;
00592                         setFromFile(getContainer().getDirectory());
00593                         presentInMemory = true;
00594                         loadInProgress = false;
00595                 }
00596           }
00605          void setFromFile(const std::string& directory);        
00606  
00607 };
00608 
00609 } // End namespace asdm
00610 
00611 #endif /* FocusModelTable_CLASS */