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 namespace asdm {
00086 
00087 //class asdm::ASDM;
00088 //class asdm::FocusModelRow;
00089 
00090 class ASDM;
00091 class FocusModelRow;
00190 class FocusModelTable : public Representable {
00191         friend class ASDM;
00192 
00193 public:
00194 
00195 
00201         static std::vector<std::string> getKeyName();
00202 
00203 
00204         virtual ~FocusModelTable();
00205         
00211         ASDM &getContainer() const;
00212         
00218         unsigned int size() const;
00219         
00227         std::string getName() const;
00228         
00236         static std::string name() ;     
00237         
00242          std::string getVersion() const ;
00243         
00249          static const std::vector<std::string>& getAttributesNames();
00250 
00256          static const std::vector<std::string>& defaultAttributesNamesInBin();
00257          
00261         Entity getEntity() const;
00262 
00267         void setEntity(Entity e);
00268                 
00276         std::string toXML()  ;
00277 
00278 #ifndef WITHOUT_ACS
00279         // Conversion Methods
00285         asdmIDL::FocusModelTableIDL *toIDL() ;
00286 #endif
00287 
00288 #ifndef WITHOUT_ACS
00289 
00295         void fromIDL(asdmIDL::FocusModelTableIDL x) ;
00296 #endif
00297         
00298         //
00299         // ====> Row creation.
00300         //
00301         
00306         FocusModelRow *newRow();
00307         
00308         
00332         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);
00333         
00334 
00335 
00348          FocusModelRow *newRow(FocusModelRow *row); 
00349 
00350         //
00351         // ====> Append a row to its table.
00352         //
00353 
00354         
00355         
00356         
00366          FocusModelRow* add(FocusModelRow* x) ;
00367 
00368 
00369 
00370         //
00371         // ====> Methods returning rows.
00372         //
00373                 
00379         std::vector<FocusModelRow *> get() ;
00380         
00387          const std::vector<FocusModelRow *>& get() const ;
00388         
00389 
00390 
00391  
00392         
00404         FocusModelRow* getRowByKey(Tag antennaId, int focusModelId);
00405 
00406                 
00407         
00415         std::vector <FocusModelRow *>  getRowByFocusModelId(int);
00416 
00417 
00418 
00444         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); 
00445 
00446 
00447         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00448         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00449 
00450 private:
00451 
00460         FocusModelTable (ASDM & container);
00461 
00462         ASDM & container;
00463         
00464         bool archiveAsBin; // If true archive binary else archive XML
00465         bool fileAsBin ; // If true file binary else file XML   
00466         
00467         std::string version ; 
00468         
00469         Entity entity;
00470         
00471 
00472         // A map for the autoincrementation algorithm
00473         std::map<std::string,int>  noAutoIncIds;
00474         void autoIncrement(std::string key, FocusModelRow* x);
00475 
00476 
00480         static std::string itsName;
00481         
00485         static std::vector<std::string> attributesNames;
00486         
00490         static std::vector<std::string> attributesNamesInBin;
00491         
00492 
00496         static bool initAttributesNames(), initAttributesNamesDone ;
00497         
00498 
00502         static std::vector<std::string> key;
00503 
00504 
00514         FocusModelRow* checkAndAdd(FocusModelRow* x) ;
00515         
00521          void append(FocusModelRow* x) ;
00522          
00528          void addWithoutCheckingUnique(FocusModelRow* x) ;
00529          
00530          
00531 
00532 
00533 
00534 // A data structure to store the pointers on the table's rows.
00535 
00536 // In all cases we maintain a private vector of FocusModelRow s.
00537    std::vector<FocusModelRow * > privateRows;
00538    
00539 
00540                         
00541         std::vector<FocusModelRow *> row;
00542 
00543         
00544         void error() ; //throw(ConversionException);
00545 
00546         
00553         void fromXML(std::string& xmlDoc) ;
00554                 
00555         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00556 
00561         void setFromMIMEFile(const std::string& directory);
00562         /*
00563         void openMIMEFile(const std::string& directory);
00564         */
00565         void setFromXMLFile(const std::string& directory);
00566         
00574         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00575   
00576         
00583          void setFromMIME(const std::string & mimeMsg);
00584         
00588         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00589         
00599           void toFile(std::string directory);
00600           
00604           bool loadInProgress;
00605           void checkPresenceInMemory() {
00606                 if (!presentInMemory && !loadInProgress) {
00607                         loadInProgress = true;
00608                         setFromFile(getContainer().getDirectory());
00609                         presentInMemory = true;
00610                         loadInProgress = false;
00611                 }
00612           }
00621          void setFromFile(const std::string& directory);        
00622  
00623 };
00624 
00625 } // End namespace asdm
00626 
00627 #endif /* FocusModelTable_CLASS */