casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PolarizationTable.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 PolarizationTable.h
00032  */
00033  
00034 #ifndef PolarizationTable_CLASS
00035 #define PolarizationTable_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 #include "CStokesParameter.h"
00056         
00057 
00058         
00059 #include "CPolarizationType.h"
00060         
00061 
00062 
00063 
00064 #include <ConversionException.h>
00065 #include <DuplicateKey.h>
00066 #include <UniquenessViolationException.h>
00067 #include <NoSuchRow.h>
00068 #include <DuplicateKey.h>
00069 
00070 
00071 #ifndef WITHOUT_ACS
00072 #include <asdmIDLC.h>
00073 #endif
00074 
00075 #include <Representable.h>
00076 
00077 #include <pthread.h>
00078 
00079 namespace asdm {
00080 
00081 //class asdm::ASDM;
00082 //class asdm::PolarizationRow;
00083 
00084 class ASDM;
00085 class PolarizationRow;
00140 class PolarizationTable : public Representable {
00141         friend class ASDM;
00142 
00143 public:
00144 
00145 
00151         static const std::vector<std::string>& getKeyName();
00152 
00153 
00154         virtual ~PolarizationTable();
00155         
00161         ASDM &getContainer() const;
00162         
00168         unsigned int size() const;
00169         
00177         std::string getName() const;
00178         
00186         static std::string name() ;     
00187         
00192          std::string getVersion() const ;
00193         
00199          static const std::vector<std::string>& getAttributesNames();
00200 
00206          static const std::vector<std::string>& defaultAttributesNamesInBin();
00207          
00211         Entity getEntity() const;
00212 
00217         void setEntity(Entity e);
00218                 
00226         std::string toXML()  ;
00227 
00228 #ifndef WITHOUT_ACS
00229         // Conversion Methods
00235         asdmIDL::PolarizationTableIDL *toIDL() ;
00236         
00244          void toIDL(asdmIDL::PolarizationTableIDL& x) const;
00245          
00246 #endif
00247 
00248 #ifndef WITHOUT_ACS
00249 
00255         void fromIDL(asdmIDL::PolarizationTableIDL x) ;
00256 #endif
00257         
00258         //
00259         // ====> Row creation.
00260         //
00261         
00266         PolarizationRow *newRow();
00267         
00268         
00280         PolarizationRow *newRow(int numCorr, vector<StokesParameterMod::StokesParameter > corrType, vector<vector<PolarizationTypeMod::PolarizationType > > corrProduct);
00281         
00282 
00283 
00296          PolarizationRow *newRow(PolarizationRow *row); 
00297 
00298         //
00299         // ====> Append a row to its table.
00300         //
00301 
00302         
00303         
00304         
00314          PolarizationRow* add(PolarizationRow* x) ;
00315 
00316 
00317 
00318         //
00319         // ====> Methods returning rows.
00320         //
00321                 
00327         std::vector<PolarizationRow *> get() ;
00328         
00335          const std::vector<PolarizationRow *>& get() const ;
00336         
00337 
00338 
00339  
00340         
00350         PolarizationRow* getRowByKey(Tag polarizationId);
00351 
00352                 
00353 
00354 
00355 
00369         PolarizationRow* lookup(int numCorr, vector<StokesParameterMod::StokesParameter > corrType, vector<vector<PolarizationTypeMod::PolarizationType > > corrProduct); 
00370 
00371 
00372         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00373         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00374 
00375 private:
00376 
00385         PolarizationTable (ASDM & container);
00386 
00387         ASDM & container;
00388         
00389         bool archiveAsBin; // If true archive binary else archive XML
00390         bool fileAsBin ; // If true file binary else file XML   
00391         
00392         std::string version ; 
00393         
00394         Entity entity;
00395         
00396 
00397         // A map for the autoincrementation algorithm
00398         std::map<std::string,int>  noAutoIncIds;
00399         void autoIncrement(std::string key, PolarizationRow* x);
00400 
00401 
00411         PolarizationRow* checkAndAdd(PolarizationRow* x, bool skipCheckUniqueness=false) ;
00412         
00418          void append(PolarizationRow* x) ;
00419          
00425          void addWithoutCheckingUnique(PolarizationRow* x) ;
00426          
00427          
00428 
00429 
00430 
00431 // A data structure to store the pointers on the table's rows.
00432 
00433 // In all cases we maintain a private vector of PolarizationRow s.
00434    std::vector<PolarizationRow * > privateRows;
00435    
00436 
00437                         
00438         std::vector<PolarizationRow *> row;
00439 
00440         
00441         void error() ; //throw(ConversionException);
00442 
00443         
00450         void fromXML(std::string& xmlDoc) ;
00451                 
00452         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00453 
00458         void setFromMIMEFile(const std::string& directory);
00459         /*
00460         void openMIMEFile(const std::string& directory);
00461         */
00462         void setFromXMLFile(const std::string& directory);
00463         
00471         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00472   
00473         
00480          void setFromMIME(const std::string & mimeMsg);
00481         
00485         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00486         
00496           void toFile(std::string directory);
00497           
00501           bool loadInProgress;
00502           void checkPresenceInMemory() {
00503                 if (!presentInMemory && !loadInProgress) {
00504                         loadInProgress = true;
00505                         setFromFile(getContainer().getDirectory());
00506                         presentInMemory = true;
00507                         loadInProgress = false;
00508                 }
00509           }
00518          void setFromFile(const std::string& directory);        
00519  
00520 };
00521 
00522 } // End namespace asdm
00523 
00524 #endif /* PolarizationTable_CLASS */