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 namespace asdm {
00100 
00101 //class asdm::ASDM;
00102 //class asdm::ConfigDescriptionRow;
00103 
00104 class ASDM;
00105 class ConfigDescriptionRow;
00261 class ConfigDescriptionTable : public Representable {
00262         friend class ASDM;
00263 
00264 public:
00265 
00266 
00272         static std::vector<std::string> getKeyName();
00273 
00274 
00275         virtual ~ConfigDescriptionTable();
00276         
00282         ASDM &getContainer() const;
00283         
00289         unsigned int size() const;
00290         
00298         std::string getName() const;
00299         
00307         static std::string name() ;     
00308         
00313          std::string getVersion() const ;
00314         
00320          static const std::vector<std::string>& getAttributesNames();
00321 
00327          static const std::vector<std::string>& defaultAttributesNamesInBin();
00328          
00332         Entity getEntity() const;
00333 
00338         void setEntity(Entity e);
00339                 
00347         std::string toXML()  ;
00348 
00349 #ifndef WITHOUT_ACS
00350         // Conversion Methods
00356         asdmIDL::ConfigDescriptionTableIDL *toIDL() ;
00357 #endif
00358 
00359 #ifndef WITHOUT_ACS
00360 
00366         void fromIDL(asdmIDL::ConfigDescriptionTableIDL x) ;
00367 #endif
00368         
00369         //
00370         // ====> Row creation.
00371         //
00372         
00377         ConfigDescriptionRow *newRow();
00378         
00379         
00411         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);
00412         
00413 
00414 
00427          ConfigDescriptionRow *newRow(ConfigDescriptionRow *row); 
00428 
00429         //
00430         // ====> Append a row to its table.
00431         //
00432 
00433         
00434         
00435         
00445          ConfigDescriptionRow* add(ConfigDescriptionRow* x) ;
00446 
00447 
00448 
00449         //
00450         // ====> Methods returning rows.
00451         //
00452                 
00458         std::vector<ConfigDescriptionRow *> get() ;
00459         
00466          const std::vector<ConfigDescriptionRow *>& get() const ;
00467         
00468 
00469 
00470  
00471         
00481         ConfigDescriptionRow* getRowByKey(Tag configDescriptionId);
00482 
00483                 
00484 
00485 
00486 
00520         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); 
00521 
00522 
00523         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00524         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00525 
00526 private:
00527 
00536         ConfigDescriptionTable (ASDM & container);
00537 
00538         ASDM & container;
00539         
00540         bool archiveAsBin; // If true archive binary else archive XML
00541         bool fileAsBin ; // If true file binary else file XML   
00542         
00543         std::string version ; 
00544         
00545         Entity entity;
00546         
00547 
00548         // A map for the autoincrementation algorithm
00549         std::map<std::string,int>  noAutoIncIds;
00550         void autoIncrement(std::string key, ConfigDescriptionRow* x);
00551 
00552 
00556         static std::string itsName;
00557         
00561         static std::vector<std::string> attributesNames;
00562         
00566         static std::vector<std::string> attributesNamesInBin;
00567         
00568 
00572         static bool initAttributesNames(), initAttributesNamesDone ;
00573         
00574 
00578         static std::vector<std::string> key;
00579 
00580 
00590         ConfigDescriptionRow* checkAndAdd(ConfigDescriptionRow* x) ;
00591         
00597          void append(ConfigDescriptionRow* x) ;
00598          
00604          void addWithoutCheckingUnique(ConfigDescriptionRow* x) ;
00605          
00606          
00607 
00608 
00609 
00610 // A data structure to store the pointers on the table's rows.
00611 
00612 // In all cases we maintain a private vector of ConfigDescriptionRow s.
00613    std::vector<ConfigDescriptionRow * > privateRows;
00614    
00615 
00616                         
00617         std::vector<ConfigDescriptionRow *> row;
00618 
00619         
00620         void error() ; //throw(ConversionException);
00621 
00622         
00629         void fromXML(std::string& xmlDoc) ;
00630                 
00631         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00632 
00637         void setFromMIMEFile(const std::string& directory);
00638         /*
00639         void openMIMEFile(const std::string& directory);
00640         */
00641         void setFromXMLFile(const std::string& directory);
00642         
00650         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00651   
00652         
00659          void setFromMIME(const std::string & mimeMsg);
00660         
00664         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00665         
00675           void toFile(std::string directory);
00676           
00680           bool loadInProgress;
00681           void checkPresenceInMemory() {
00682                 if (!presentInMemory && !loadInProgress) {
00683                         loadInProgress = true;
00684                         setFromFile(getContainer().getDirectory());
00685                         presentInMemory = true;
00686                         loadInProgress = false;
00687                 }
00688           }
00697          void setFromFile(const std::string& directory);        
00698  
00699 };
00700 
00701 } // End namespace asdm
00702 
00703 #endif /* ConfigDescriptionTable_CLASS */