casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
AntennaTable.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 AntennaTable.h
00032  */
00033  
00034 #ifndef AntennaTable_CLASS
00035 #define AntennaTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <Tag.h>
00049         
00050 
00051         
00052 #include <Length.h>
00053         
00054 
00055 
00056 
00057 
00058         
00059 
00060         
00061 
00062         
00063 #include "CAntennaMake.h"
00064         
00065 
00066         
00067 #include "CAntennaType.h"
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 
00078 
00079 
00080 #include <ConversionException.h>
00081 #include <DuplicateKey.h>
00082 #include <UniquenessViolationException.h>
00083 #include <NoSuchRow.h>
00084 #include <DuplicateKey.h>
00085 
00086 
00087 #ifndef WITHOUT_ACS
00088 #include <asdmIDLC.h>
00089 #endif
00090 
00091 #include <Representable.h>
00092 
00093 #include <pthread.h>
00094 
00095 namespace asdm {
00096 
00097 //class asdm::ASDM;
00098 //class asdm::AntennaRow;
00099 
00100 class ASDM;
00101 class AntennaRow;
00201 class AntennaTable : public Representable {
00202         friend class ASDM;
00203 
00204 public:
00205 
00206 
00212         static const std::vector<std::string>& getKeyName();
00213 
00214 
00215         virtual ~AntennaTable();
00216         
00222         ASDM &getContainer() const;
00223         
00229         unsigned int size() const;
00230         
00238         std::string getName() const;
00239         
00247         static std::string name() ;     
00248         
00253          std::string getVersion() const ;
00254         
00260          static const std::vector<std::string>& getAttributesNames();
00261 
00267          static const std::vector<std::string>& defaultAttributesNamesInBin();
00268          
00272         Entity getEntity() const;
00273 
00278         void setEntity(Entity e);
00279                 
00287         std::string toXML()  ;
00288 
00289 #ifndef WITHOUT_ACS
00290         // Conversion Methods
00296         asdmIDL::AntennaTableIDL *toIDL() ;
00297         
00305          void toIDL(asdmIDL::AntennaTableIDL& x) const;
00306          
00307 #endif
00308 
00309 #ifndef WITHOUT_ACS
00310 
00316         void fromIDL(asdmIDL::AntennaTableIDL x) ;
00317 #endif
00318         
00319         //
00320         // ====> Row creation.
00321         //
00322         
00327         AntennaRow *newRow();
00328         
00329         
00351         AntennaRow *newRow(string name, AntennaMakeMod::AntennaMake antennaMake, AntennaTypeMod::AntennaType antennaType, Length dishDiameter, vector<Length > position, vector<Length > offset, ArrayTime time, Tag stationId);
00352         
00353 
00354 
00367          AntennaRow *newRow(AntennaRow *row); 
00368 
00369         //
00370         // ====> Append a row to its table.
00371         //
00372 
00373         
00374         
00375         
00385          AntennaRow* add(AntennaRow* x) ;
00386 
00387 
00388 
00389         //
00390         // ====> Methods returning rows.
00391         //
00392                 
00398         std::vector<AntennaRow *> get() ;
00399         
00406          const std::vector<AntennaRow *>& get() const ;
00407         
00408 
00409 
00410  
00411         
00421         AntennaRow* getRowByKey(Tag antennaId);
00422 
00423                 
00424 
00425 
00426 
00450         AntennaRow* lookup(string name, AntennaMakeMod::AntennaMake antennaMake, AntennaTypeMod::AntennaType antennaType, Length dishDiameter, vector<Length > position, vector<Length > offset, ArrayTime time, Tag stationId); 
00451 
00452 
00453         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00454         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00455 
00456 private:
00457 
00466         AntennaTable (ASDM & container);
00467 
00468         ASDM & container;
00469         
00470         bool archiveAsBin; // If true archive binary else archive XML
00471         bool fileAsBin ; // If true file binary else file XML   
00472         
00473         std::string version ; 
00474         
00475         Entity entity;
00476         
00477 
00478         // A map for the autoincrementation algorithm
00479         std::map<std::string,int>  noAutoIncIds;
00480         void autoIncrement(std::string key, AntennaRow* x);
00481 
00482 
00492         AntennaRow* checkAndAdd(AntennaRow* x, bool skipCheckUniqueness=false) ;
00493         
00499          void append(AntennaRow* x) ;
00500          
00506          void addWithoutCheckingUnique(AntennaRow* x) ;
00507          
00508          
00509 
00510 
00511 
00512 // A data structure to store the pointers on the table's rows.
00513 
00514 // In all cases we maintain a private vector of AntennaRow s.
00515    std::vector<AntennaRow * > privateRows;
00516    
00517 
00518                         
00519         std::vector<AntennaRow *> row;
00520 
00521         
00522         void error() ; //throw(ConversionException);
00523 
00524         
00531         void fromXML(std::string& xmlDoc) ;
00532                 
00533         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00534 
00539         void setFromMIMEFile(const std::string& directory);
00540         /*
00541         void openMIMEFile(const std::string& directory);
00542         */
00543         void setFromXMLFile(const std::string& directory);
00544         
00552         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00553   
00554         
00561          void setFromMIME(const std::string & mimeMsg);
00562         
00566         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00567         
00577           void toFile(std::string directory);
00578           
00582           bool loadInProgress;
00583           void checkPresenceInMemory() {
00584                 if (!presentInMemory && !loadInProgress) {
00585                         loadInProgress = true;
00586                         setFromFile(getContainer().getDirectory());
00587                         presentInMemory = true;
00588                         loadInProgress = false;
00589                 }
00590           }
00599          void setFromFile(const std::string& directory);        
00600  
00601 };
00602 
00603 } // End namespace asdm
00604 
00605 #endif /* AntennaTable_CLASS */