casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
HolographyTable.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 HolographyTable.h
00032  */
00033  
00034 #ifndef HolographyTable_CLASS
00035 #define HolographyTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047         
00048 #include <Length.h>
00049         
00050 
00051 
00052 
00053 
00054         
00055 
00056         
00057 
00058         
00059 
00060         
00061 
00062         
00063 #include "CHolographyChannelType.h"
00064         
00065 
00066 
00067 
00068 #include <ConversionException.h>
00069 #include <DuplicateKey.h>
00070 #include <UniquenessViolationException.h>
00071 #include <NoSuchRow.h>
00072 #include <DuplicateKey.h>
00073 
00074 
00075 #ifndef WITHOUT_ACS
00076 #include <asdmIDLC.h>
00077 #endif
00078 
00079 #include <Representable.h>
00080 
00081 #include <pthread.h>
00082 
00083 namespace asdm {
00084 
00085 //class asdm::ASDM;
00086 //class asdm::HolographyRow;
00087 
00088 class ASDM;
00089 class HolographyRow;
00151 class HolographyTable : public Representable {
00152         friend class ASDM;
00153 
00154 public:
00155 
00156 
00162         static const std::vector<std::string>& getKeyName();
00163 
00164 
00165         virtual ~HolographyTable();
00166         
00172         ASDM &getContainer() const;
00173         
00179         unsigned int size() const;
00180         
00188         std::string getName() const;
00189         
00197         static std::string name() ;     
00198         
00203          std::string getVersion() const ;
00204         
00210          static const std::vector<std::string>& getAttributesNames();
00211 
00217          static const std::vector<std::string>& defaultAttributesNamesInBin();
00218          
00222         Entity getEntity() const;
00223 
00228         void setEntity(Entity e);
00229                 
00237         std::string toXML()  ;
00238 
00239 #ifndef WITHOUT_ACS
00240         // Conversion Methods
00246         asdmIDL::HolographyTableIDL *toIDL() ;
00247         
00255          void toIDL(asdmIDL::HolographyTableIDL& x) const;
00256          
00257 #endif
00258 
00259 #ifndef WITHOUT_ACS
00260 
00266         void fromIDL(asdmIDL::HolographyTableIDL x) ;
00267 #endif
00268         
00269         //
00270         // ====> Row creation.
00271         //
00272         
00277         HolographyRow *newRow();
00278         
00279         
00293         HolographyRow *newRow(Length distance, Length focus, int numCorr, vector<HolographyChannelTypeMod::HolographyChannelType > type);
00294         
00295 
00296 
00309          HolographyRow *newRow(HolographyRow *row); 
00310 
00311         //
00312         // ====> Append a row to its table.
00313         //
00314 
00315         
00316         
00317         
00327          HolographyRow* add(HolographyRow* x) ;
00328 
00329 
00330 
00331         //
00332         // ====> Methods returning rows.
00333         //
00334                 
00340         std::vector<HolographyRow *> get() ;
00341         
00348          const std::vector<HolographyRow *>& get() const ;
00349         
00350 
00351 
00352  
00353         
00363         HolographyRow* getRowByKey(Tag holographyId);
00364 
00365                 
00366 
00367 
00368 
00384         HolographyRow* lookup(Length distance, Length focus, int numCorr, vector<HolographyChannelTypeMod::HolographyChannelType > type); 
00385 
00386 
00387         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00388         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00389 
00390 private:
00391 
00400         HolographyTable (ASDM & container);
00401 
00402         ASDM & container;
00403         
00404         bool archiveAsBin; // If true archive binary else archive XML
00405         bool fileAsBin ; // If true file binary else file XML   
00406         
00407         std::string version ; 
00408         
00409         Entity entity;
00410         
00411 
00412         // A map for the autoincrementation algorithm
00413         std::map<std::string,int>  noAutoIncIds;
00414         void autoIncrement(std::string key, HolographyRow* x);
00415 
00416 
00426         HolographyRow* checkAndAdd(HolographyRow* x, bool skipCheckUniqueness=false) ;
00427         
00433          void append(HolographyRow* x) ;
00434          
00440          void addWithoutCheckingUnique(HolographyRow* x) ;
00441          
00442          
00443 
00444 
00445 
00446 // A data structure to store the pointers on the table's rows.
00447 
00448 // In all cases we maintain a private vector of HolographyRow s.
00449    std::vector<HolographyRow * > privateRows;
00450    
00451 
00452                         
00453         std::vector<HolographyRow *> row;
00454 
00455         
00456         void error() ; //throw(ConversionException);
00457 
00458         
00465         void fromXML(std::string& xmlDoc) ;
00466                 
00467         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00468 
00473         void setFromMIMEFile(const std::string& directory);
00474         /*
00475         void openMIMEFile(const std::string& directory);
00476         */
00477         void setFromXMLFile(const std::string& directory);
00478         
00486         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00487   
00488         
00495          void setFromMIME(const std::string & mimeMsg);
00496         
00500         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00501         
00511           void toFile(std::string directory);
00512           
00516           bool loadInProgress;
00517           void checkPresenceInMemory() {
00518                 if (!presentInMemory && !loadInProgress) {
00519                         loadInProgress = true;
00520                         setFromFile(getContainer().getDirectory());
00521                         presentInMemory = true;
00522                         loadInProgress = false;
00523                 }
00524           }
00533          void setFromFile(const std::string& directory);        
00534  
00535 };
00536 
00537 } // End namespace asdm
00538 
00539 #endif /* HolographyTable_CLASS */