casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SubscanTable.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 SubscanTable.h
00032  */
00033  
00034 #ifndef SubscanTable_CLASS
00035 #define SubscanTable_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 
00053 
00054         
00055 
00056         
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 #include "CSubscanIntent.h"
00066         
00067 
00068         
00069 #include "CSwitchingMode.h"
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 #include "CCorrelatorCalibration.h"
00078         
00079 
00080 
00081 
00082 #include <ConversionException.h>
00083 #include <DuplicateKey.h>
00084 #include <UniquenessViolationException.h>
00085 #include <NoSuchRow.h>
00086 #include <DuplicateKey.h>
00087 
00088 
00089 #ifndef WITHOUT_ACS
00090 #include <asdmIDLC.h>
00091 #endif
00092 
00093 #include <Representable.h>
00094 
00095 namespace asdm {
00096 
00097 //class asdm::ASDM;
00098 //class asdm::SubscanRow;
00099 
00100 class ASDM;
00101 class SubscanRow;
00212 class SubscanTable : public Representable {
00213         friend class ASDM;
00214 
00215 public:
00216 
00217 
00223         static std::vector<std::string> getKeyName();
00224 
00225 
00226         virtual ~SubscanTable();
00227         
00233         ASDM &getContainer() const;
00234         
00240         unsigned int size() const;
00241         
00249         std::string getName() const;
00250         
00258         static std::string name() ;     
00259         
00264          std::string getVersion() const ;
00265         
00271          static const std::vector<std::string>& getAttributesNames();
00272 
00278          static const std::vector<std::string>& defaultAttributesNamesInBin();
00279          
00283         Entity getEntity() const;
00284 
00289         void setEntity(Entity e);
00290                 
00298         std::string toXML()  ;
00299 
00300 #ifndef WITHOUT_ACS
00301         // Conversion Methods
00307         asdmIDL::SubscanTableIDL *toIDL() ;
00308 #endif
00309 
00310 #ifndef WITHOUT_ACS
00311 
00317         void fromIDL(asdmIDL::SubscanTableIDL x) ;
00318 #endif
00319         
00320         //
00321         // ====> Row creation.
00322         //
00323         
00328         SubscanRow *newRow();
00329         
00330         
00354         SubscanRow *newRow(Tag execBlockId, int scanNumber, int subscanNumber, ArrayTime startTime, ArrayTime endTime, string fieldName, SubscanIntentMod::SubscanIntent subscanIntent, int numIntegration, vector<int > numSubintegration);
00355         
00356 
00357 
00370          SubscanRow *newRow(SubscanRow *row); 
00371 
00372         //
00373         // ====> Append a row to its table.
00374         //
00375  
00376         
00389         SubscanRow* add(SubscanRow* x) ; 
00390 
00391  
00392 
00393 
00394 
00395         //
00396         // ====> Methods returning rows.
00397         //
00398                 
00404         std::vector<SubscanRow *> get() ;
00405         
00412          const std::vector<SubscanRow *>& get() const ;
00413         
00414 
00415 
00416  
00417         
00431         SubscanRow* getRowByKey(Tag execBlockId, int scanNumber, int subscanNumber);
00432 
00433                 
00434 
00435 
00436 
00462         SubscanRow* lookup(Tag execBlockId, int scanNumber, int subscanNumber, ArrayTime startTime, ArrayTime endTime, string fieldName, SubscanIntentMod::SubscanIntent subscanIntent, int numIntegration, vector<int > numSubintegration); 
00463 
00464 
00465         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00466         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00467 
00468 private:
00469 
00478         SubscanTable (ASDM & container);
00479 
00480         ASDM & container;
00481         
00482         bool archiveAsBin; // If true archive binary else archive XML
00483         bool fileAsBin ; // If true file binary else file XML   
00484         
00485         std::string version ; 
00486         
00487         Entity entity;
00488         
00489 
00490 
00494         static std::string itsName;
00495         
00499         static std::vector<std::string> attributesNames;
00500         
00504         static std::vector<std::string> attributesNamesInBin;
00505         
00506 
00510         static bool initAttributesNames(), initAttributesNamesDone ;
00511         
00512 
00516         static std::vector<std::string> key;
00517 
00518 
00526         SubscanRow* checkAndAdd(SubscanRow* x) ;
00527         
00533          void append(SubscanRow* x) ;
00534          
00540          void addWithoutCheckingUnique(SubscanRow* x) ;
00541          
00542          
00543 
00544 
00545 
00546 // A data structure to store the pointers on the table's rows.
00547 
00548 // In all cases we maintain a private vector of SubscanRow s.
00549    std::vector<SubscanRow * > privateRows;
00550    
00551 
00552                         
00553         std::vector<SubscanRow *> row;
00554 
00555         
00556         void error() ; //throw(ConversionException);
00557 
00558         
00565         void fromXML(std::string& xmlDoc) ;
00566                 
00567         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00568 
00573         void setFromMIMEFile(const std::string& directory);
00574         /*
00575         void openMIMEFile(const std::string& directory);
00576         */
00577         void setFromXMLFile(const std::string& directory);
00578         
00586         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00587   
00588         
00595          void setFromMIME(const std::string & mimeMsg);
00596         
00600         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00601         
00611           void toFile(std::string directory);
00612           
00616           bool loadInProgress;
00617           void checkPresenceInMemory() {
00618                 if (!presentInMemory && !loadInProgress) {
00619                         loadInProgress = true;
00620                         setFromFile(getContainer().getDirectory());
00621                         presentInMemory = true;
00622                         loadInProgress = false;
00623                 }
00624           }
00633          void setFromFile(const std::string& directory);        
00634  
00635 };
00636 
00637 } // End namespace asdm
00638 
00639 #endif /* SubscanTable_CLASS */