casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
AlmaRadiometerTable.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 AlmaRadiometerTable.h
00032  */
00033  
00034 #ifndef AlmaRadiometerTable_CLASS
00035 #define AlmaRadiometerTable_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 #include <ConversionException.h>
00057 #include <DuplicateKey.h>
00058 #include <UniquenessViolationException.h>
00059 #include <NoSuchRow.h>
00060 #include <DuplicateKey.h>
00061 
00062 
00063 #ifndef WITHOUT_ACS
00064 #include <asdmIDLC.h>
00065 #endif
00066 
00067 #include <Representable.h>
00068 
00069 #include <pthread.h>
00070 
00071 namespace asdm {
00072 
00073 //class asdm::ASDM;
00074 //class asdm::AlmaRadiometerRow;
00075 
00076 class ASDM;
00077 class AlmaRadiometerRow;
00125 class AlmaRadiometerTable : public Representable {
00126         friend class ASDM;
00127 
00128 public:
00129 
00130 
00136         static const std::vector<std::string>& getKeyName();
00137 
00138 
00139         virtual ~AlmaRadiometerTable();
00140         
00146         ASDM &getContainer() const;
00147         
00153         unsigned int size() const;
00154         
00162         std::string getName() const;
00163         
00171         static std::string name() ;     
00172         
00177          std::string getVersion() const ;
00178         
00184          static const std::vector<std::string>& getAttributesNames();
00185 
00191          static const std::vector<std::string>& defaultAttributesNamesInBin();
00192          
00196         Entity getEntity() const;
00197 
00202         void setEntity(Entity e);
00203                 
00211         std::string toXML()  ;
00212 
00213 #ifndef WITHOUT_ACS
00214         // Conversion Methods
00220         asdmIDL::AlmaRadiometerTableIDL *toIDL() ;
00221         
00229          void toIDL(asdmIDL::AlmaRadiometerTableIDL& x) const;
00230          
00231 #endif
00232 
00233 #ifndef WITHOUT_ACS
00234 
00240         void fromIDL(asdmIDL::AlmaRadiometerTableIDL x) ;
00241 #endif
00242         
00243         //
00244         // ====> Row creation.
00245         //
00246         
00251         AlmaRadiometerRow *newRow();
00252         
00253 
00254 
00267          AlmaRadiometerRow *newRow(AlmaRadiometerRow *row); 
00268 
00269         //
00270         // ====> Append a row to its table.
00271         //
00272 
00273         
00274         
00275         
00285          AlmaRadiometerRow* add(AlmaRadiometerRow* x) ;
00286 
00287 
00288 
00289         //
00290         // ====> Methods returning rows.
00291         //
00292                 
00298         std::vector<AlmaRadiometerRow *> get() ;
00299         
00306          const std::vector<AlmaRadiometerRow *>& get() const ;
00307         
00308 
00309 
00310  
00311         
00321         AlmaRadiometerRow* getRowByKey(Tag almaRadiometerId);
00322 
00323                 
00324 
00325 
00326 
00327 
00328         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00329         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00330 
00331 private:
00332 
00341         AlmaRadiometerTable (ASDM & container);
00342 
00343         ASDM & container;
00344         
00345         bool archiveAsBin; // If true archive binary else archive XML
00346         bool fileAsBin ; // If true file binary else file XML   
00347         
00348         std::string version ; 
00349         
00350         Entity entity;
00351         
00352 
00353         // A map for the autoincrementation algorithm
00354         std::map<std::string,int>  noAutoIncIds;
00355         void autoIncrement(std::string key, AlmaRadiometerRow* x);
00356 
00357 
00367         AlmaRadiometerRow* checkAndAdd(AlmaRadiometerRow* x, bool skipCheckUniqueness=false) ;
00368         
00374          void append(AlmaRadiometerRow* x) ;
00375          
00381          void addWithoutCheckingUnique(AlmaRadiometerRow* x) ;
00382          
00383          
00384 
00385 
00386 
00387 // A data structure to store the pointers on the table's rows.
00388 
00389 // In all cases we maintain a private vector of AlmaRadiometerRow s.
00390    std::vector<AlmaRadiometerRow * > privateRows;
00391    
00392 
00393                         
00394         std::vector<AlmaRadiometerRow *> row;
00395 
00396         
00397         void error() ; //throw(ConversionException);
00398 
00399         
00406         void fromXML(std::string& xmlDoc) ;
00407                 
00408         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00409 
00414         void setFromMIMEFile(const std::string& directory);
00415         /*
00416         void openMIMEFile(const std::string& directory);
00417         */
00418         void setFromXMLFile(const std::string& directory);
00419         
00427         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00428   
00429         
00436          void setFromMIME(const std::string & mimeMsg);
00437         
00441         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00442         
00452           void toFile(std::string directory);
00453           
00457           bool loadInProgress;
00458           void checkPresenceInMemory() {
00459                 if (!presentInMemory && !loadInProgress) {
00460                         loadInProgress = true;
00461                         setFromFile(getContainer().getDirectory());
00462                         presentInMemory = true;
00463                         loadInProgress = false;
00464                 }
00465           }
00474          void setFromFile(const std::string& directory);        
00475  
00476 };
00477 
00478 } // End namespace asdm
00479 
00480 #endif /* AlmaRadiometerTable_CLASS */