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 namespace asdm {
00082 
00083 //class asdm::ASDM;
00084 //class asdm::HolographyRow;
00085 
00086 class ASDM;
00087 class HolographyRow;
00149 class HolographyTable : public Representable {
00150         friend class ASDM;
00151 
00152 public:
00153 
00154 
00160         static std::vector<std::string> getKeyName();
00161 
00162 
00163         virtual ~HolographyTable();
00164         
00170         ASDM &getContainer() const;
00171         
00177         unsigned int size() const;
00178         
00186         std::string getName() const;
00187         
00195         static std::string name() ;     
00196         
00201          std::string getVersion() const ;
00202         
00208          static const std::vector<std::string>& getAttributesNames();
00209 
00215          static const std::vector<std::string>& defaultAttributesNamesInBin();
00216          
00220         Entity getEntity() const;
00221 
00226         void setEntity(Entity e);
00227                 
00235         std::string toXML()  ;
00236 
00237 #ifndef WITHOUT_ACS
00238         // Conversion Methods
00244         asdmIDL::HolographyTableIDL *toIDL() ;
00245 #endif
00246 
00247 #ifndef WITHOUT_ACS
00248 
00254         void fromIDL(asdmIDL::HolographyTableIDL x) ;
00255 #endif
00256         
00257         //
00258         // ====> Row creation.
00259         //
00260         
00265         HolographyRow *newRow();
00266         
00267         
00281         HolographyRow *newRow(Length distance, Length focus, int numCorr, vector<HolographyChannelTypeMod::HolographyChannelType > type);
00282         
00283 
00284 
00297          HolographyRow *newRow(HolographyRow *row); 
00298 
00299         //
00300         // ====> Append a row to its table.
00301         //
00302 
00303         
00304         
00305         
00315          HolographyRow* add(HolographyRow* x) ;
00316 
00317 
00318 
00319         //
00320         // ====> Methods returning rows.
00321         //
00322                 
00328         std::vector<HolographyRow *> get() ;
00329         
00336          const std::vector<HolographyRow *>& get() const ;
00337         
00338 
00339 
00340  
00341         
00351         HolographyRow* getRowByKey(Tag holographyId);
00352 
00353                 
00354 
00355 
00356 
00372         HolographyRow* lookup(Length distance, Length focus, int numCorr, vector<HolographyChannelTypeMod::HolographyChannelType > type); 
00373 
00374 
00375         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00376         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00377 
00378 private:
00379 
00388         HolographyTable (ASDM & container);
00389 
00390         ASDM & container;
00391         
00392         bool archiveAsBin; // If true archive binary else archive XML
00393         bool fileAsBin ; // If true file binary else file XML   
00394         
00395         std::string version ; 
00396         
00397         Entity entity;
00398         
00399 
00400         // A map for the autoincrementation algorithm
00401         std::map<std::string,int>  noAutoIncIds;
00402         void autoIncrement(std::string key, HolographyRow* x);
00403 
00404 
00408         static std::string itsName;
00409         
00413         static std::vector<std::string> attributesNames;
00414         
00418         static std::vector<std::string> attributesNamesInBin;
00419         
00420 
00424         static bool initAttributesNames(), initAttributesNamesDone ;
00425         
00426 
00430         static std::vector<std::string> key;
00431 
00432 
00442         HolographyRow* checkAndAdd(HolographyRow* x) ;
00443         
00449          void append(HolographyRow* x) ;
00450          
00456          void addWithoutCheckingUnique(HolographyRow* x) ;
00457          
00458          
00459 
00460 
00461 
00462 // A data structure to store the pointers on the table's rows.
00463 
00464 // In all cases we maintain a private vector of HolographyRow s.
00465    std::vector<HolographyRow * > privateRows;
00466    
00467 
00468                         
00469         std::vector<HolographyRow *> row;
00470 
00471         
00472         void error() ; //throw(ConversionException);
00473 
00474         
00481         void fromXML(std::string& xmlDoc) ;
00482                 
00483         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00484 
00489         void setFromMIMEFile(const std::string& directory);
00490         /*
00491         void openMIMEFile(const std::string& directory);
00492         */
00493         void setFromXMLFile(const std::string& directory);
00494         
00502         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00503   
00504         
00511          void setFromMIME(const std::string & mimeMsg);
00512         
00516         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00517         
00527           void toFile(std::string directory);
00528           
00532           bool loadInProgress;
00533           void checkPresenceInMemory() {
00534                 if (!presentInMemory && !loadInProgress) {
00535                         loadInProgress = true;
00536                         setFromFile(getContainer().getDirectory());
00537                         presentInMemory = true;
00538                         loadInProgress = false;
00539                 }
00540           }
00549          void setFromFile(const std::string& directory);        
00550  
00551 };
00552 
00553 } // End namespace asdm
00554 
00555 #endif /* HolographyTable_CLASS */