casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ConfigDescriptionTable.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 ConfigDescriptionTable.h
00032  */
00033  
00034 #ifndef ConfigDescriptionTable_CLASS
00035 #define ConfigDescriptionTable_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         
00057 #include "CCorrelationMode.h"
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 #include "CAtmPhaseCorrection.h"
00066         
00067 
00068         
00069 #include "CProcessorType.h"
00070         
00071 
00072         
00073 
00074         
00075 #include "CSpectralResolutionType.h"
00076         
00077 
00078         
00079 
00080         
00081 #include "CSpectralResolutionType.h"
00082         
00083 
00084 
00085 
00086 #include <ConversionException.h>
00087 #include <DuplicateKey.h>
00088 #include <UniquenessViolationException.h>
00089 #include <NoSuchRow.h>
00090 #include <DuplicateKey.h>
00091 
00092 
00093 #ifndef WITHOUT_ACS
00094 #include <asdmIDLC.h>
00095 #endif
00096 
00097 #include <Representable.h>
00098 
00099 #include <pthread.h>
00100 
00101 namespace asdm {
00102 
00103 //class asdm::ASDM;
00104 //class asdm::ConfigDescriptionRow;
00105 
00106 class ASDM;
00107 class ConfigDescriptionRow;
00263 class ConfigDescriptionTable : public Representable {
00264         friend class ASDM;
00265 
00266 public:
00267 
00268 
00274         static const std::vector<std::string>& getKeyName();
00275 
00276 
00277         virtual ~ConfigDescriptionTable();
00278         
00284         ASDM &getContainer() const;
00285         
00291         unsigned int size() const;
00292         
00300         std::string getName() const;
00301         
00309         static std::string name() ;     
00310         
00315          std::string getVersion() const ;
00316         
00322          static const std::vector<std::string>& getAttributesNames();
00323 
00329          static const std::vector<std::string>& defaultAttributesNamesInBin();
00330          
00334         Entity getEntity() const;
00335 
00340         void setEntity(Entity e);
00341                 
00349         std::string toXML()  ;
00350 
00351 #ifndef WITHOUT_ACS
00352         // Conversion Methods
00358         asdmIDL::ConfigDescriptionTableIDL *toIDL() ;
00359         
00367          void toIDL(asdmIDL::ConfigDescriptionTableIDL& x) const;
00368          
00369 #endif
00370 
00371 #ifndef WITHOUT_ACS
00372 
00378         void fromIDL(asdmIDL::ConfigDescriptionTableIDL x) ;
00379 #endif
00380         
00381         //
00382         // ====> Row creation.
00383         //
00384         
00389         ConfigDescriptionRow *newRow();
00390         
00391         
00423         ConfigDescriptionRow *newRow(int numAntenna, int numDataDescription, int numFeed, CorrelationModeMod::CorrelationMode correlationMode, int numAtmPhaseCorrection, vector<AtmPhaseCorrectionMod::AtmPhaseCorrection > atmPhaseCorrection, ProcessorTypeMod::ProcessorType processorType, SpectralResolutionTypeMod::SpectralResolutionType spectralType, vector<Tag>  antennaId, vector<int>  feedId, vector<Tag>  switchCycleId, vector<Tag>  dataDescriptionId, Tag processorId);
00424         
00425 
00426 
00439          ConfigDescriptionRow *newRow(ConfigDescriptionRow *row); 
00440 
00441         //
00442         // ====> Append a row to its table.
00443         //
00444 
00445         
00446         
00447         
00457          ConfigDescriptionRow* add(ConfigDescriptionRow* x) ;
00458 
00459 
00460 
00461         //
00462         // ====> Methods returning rows.
00463         //
00464                 
00470         std::vector<ConfigDescriptionRow *> get() ;
00471         
00478          const std::vector<ConfigDescriptionRow *>& get() const ;
00479         
00480 
00481 
00482  
00483         
00493         ConfigDescriptionRow* getRowByKey(Tag configDescriptionId);
00494 
00495                 
00496 
00497 
00498 
00532         ConfigDescriptionRow* lookup(int numAntenna, int numDataDescription, int numFeed, CorrelationModeMod::CorrelationMode correlationMode, int numAtmPhaseCorrection, vector<AtmPhaseCorrectionMod::AtmPhaseCorrection > atmPhaseCorrection, ProcessorTypeMod::ProcessorType processorType, SpectralResolutionTypeMod::SpectralResolutionType spectralType, vector<Tag>  antennaId, vector<int>  feedId, vector<Tag>  switchCycleId, vector<Tag>  dataDescriptionId, Tag processorId); 
00533 
00534 
00535         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00536         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00537 
00538 private:
00539 
00548         ConfigDescriptionTable (ASDM & container);
00549 
00550         ASDM & container;
00551         
00552         bool archiveAsBin; // If true archive binary else archive XML
00553         bool fileAsBin ; // If true file binary else file XML   
00554         
00555         std::string version ; 
00556         
00557         Entity entity;
00558         
00559 
00560         // A map for the autoincrementation algorithm
00561         std::map<std::string,int>  noAutoIncIds;
00562         void autoIncrement(std::string key, ConfigDescriptionRow* x);
00563 
00564 
00574         ConfigDescriptionRow* checkAndAdd(ConfigDescriptionRow* x, bool skipCheckUniqueness=false) ;
00575         
00581          void append(ConfigDescriptionRow* x) ;
00582          
00588          void addWithoutCheckingUnique(ConfigDescriptionRow* x) ;
00589          
00590          
00591 
00592 
00593 
00594 // A data structure to store the pointers on the table's rows.
00595 
00596 // In all cases we maintain a private vector of ConfigDescriptionRow s.
00597    std::vector<ConfigDescriptionRow * > privateRows;
00598    
00599 
00600                         
00601         std::vector<ConfigDescriptionRow *> row;
00602 
00603         
00604         void error() ; //throw(ConversionException);
00605 
00606         
00613         void fromXML(std::string& xmlDoc) ;
00614                 
00615         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00616 
00621         void setFromMIMEFile(const std::string& directory);
00622         /*
00623         void openMIMEFile(const std::string& directory);
00624         */
00625         void setFromXMLFile(const std::string& directory);
00626         
00634         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00635   
00636         
00643          void setFromMIME(const std::string & mimeMsg);
00644         
00648         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00649         
00659           void toFile(std::string directory);
00660           
00664           bool loadInProgress;
00665           void checkPresenceInMemory() {
00666                 if (!presentInMemory && !loadInProgress) {
00667                         loadInProgress = true;
00668                         setFromFile(getContainer().getDirectory());
00669                         presentInMemory = true;
00670                         loadInProgress = false;
00671                 }
00672           }
00681          void setFromFile(const std::string& directory);        
00682  
00683 };
00684 
00685 } // End namespace asdm
00686 
00687 #endif /* ConfigDescriptionTable_CLASS */