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 #include <pthread.h>
00096 
00097 namespace asdm {
00098 
00099 //class asdm::ASDM;
00100 //class asdm::SubscanRow;
00101 
00102 class ASDM;
00103 class SubscanRow;
00214 class SubscanTable : public Representable {
00215         friend class ASDM;
00216 
00217 public:
00218 
00219 
00225         static const std::vector<std::string>& getKeyName();
00226 
00227 
00228         virtual ~SubscanTable();
00229         
00235         ASDM &getContainer() const;
00236         
00242         unsigned int size() const;
00243         
00251         std::string getName() const;
00252         
00260         static std::string name() ;     
00261         
00266          std::string getVersion() const ;
00267         
00273          static const std::vector<std::string>& getAttributesNames();
00274 
00280          static const std::vector<std::string>& defaultAttributesNamesInBin();
00281          
00285         Entity getEntity() const;
00286 
00291         void setEntity(Entity e);
00292                 
00300         std::string toXML()  ;
00301 
00302 #ifndef WITHOUT_ACS
00303         // Conversion Methods
00309         asdmIDL::SubscanTableIDL *toIDL() ;
00310         
00318          void toIDL(asdmIDL::SubscanTableIDL& x) const;
00319          
00320 #endif
00321 
00322 #ifndef WITHOUT_ACS
00323 
00329         void fromIDL(asdmIDL::SubscanTableIDL x) ;
00330 #endif
00331         
00332         //
00333         // ====> Row creation.
00334         //
00335         
00340         SubscanRow *newRow();
00341         
00342         
00366         SubscanRow *newRow(Tag execBlockId, int scanNumber, int subscanNumber, ArrayTime startTime, ArrayTime endTime, string fieldName, SubscanIntentMod::SubscanIntent subscanIntent, int numIntegration, vector<int > numSubintegration);
00367         
00368 
00369 
00382          SubscanRow *newRow(SubscanRow *row); 
00383 
00384         //
00385         // ====> Append a row to its table.
00386         //
00387  
00388         
00401         SubscanRow* add(SubscanRow* x) ; 
00402 
00403  
00404 
00405 
00406 
00407         //
00408         // ====> Methods returning rows.
00409         //
00410                 
00416         std::vector<SubscanRow *> get() ;
00417         
00424          const std::vector<SubscanRow *>& get() const ;
00425         
00426 
00427 
00428  
00429         
00443         SubscanRow* getRowByKey(Tag execBlockId, int scanNumber, int subscanNumber);
00444 
00445                 
00446 
00447 
00448 
00474         SubscanRow* lookup(Tag execBlockId, int scanNumber, int subscanNumber, ArrayTime startTime, ArrayTime endTime, string fieldName, SubscanIntentMod::SubscanIntent subscanIntent, int numIntegration, vector<int > numSubintegration); 
00475 
00476 
00477         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00478         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00479 
00480 private:
00481 
00490         SubscanTable (ASDM & container);
00491 
00492         ASDM & container;
00493         
00494         bool archiveAsBin; // If true archive binary else archive XML
00495         bool fileAsBin ; // If true file binary else file XML   
00496         
00497         std::string version ; 
00498         
00499         Entity entity;
00500         
00501 
00502 
00510         SubscanRow* checkAndAdd(SubscanRow* x, bool skipCheckUniqueness=false) ;
00511         
00517          void append(SubscanRow* x) ;
00518          
00524          void addWithoutCheckingUnique(SubscanRow* x) ;
00525          
00526          
00527 
00528 
00529 
00530 // A data structure to store the pointers on the table's rows.
00531 
00532 // In all cases we maintain a private vector of SubscanRow s.
00533    std::vector<SubscanRow * > privateRows;
00534    
00535 
00536                         
00537         std::vector<SubscanRow *> row;
00538 
00539         
00540         void error() ; //throw(ConversionException);
00541 
00542         
00549         void fromXML(std::string& xmlDoc) ;
00550                 
00551         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00552 
00557         void setFromMIMEFile(const std::string& directory);
00558         /*
00559         void openMIMEFile(const std::string& directory);
00560         */
00561         void setFromXMLFile(const std::string& directory);
00562         
00570         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00571   
00572         
00579          void setFromMIME(const std::string & mimeMsg);
00580         
00584         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00585         
00595           void toFile(std::string directory);
00596           
00600           bool loadInProgress;
00601           void checkPresenceInMemory() {
00602                 if (!presentInMemory && !loadInProgress) {
00603                         loadInProgress = true;
00604                         setFromFile(getContainer().getDirectory());
00605                         presentInMemory = true;
00606                         loadInProgress = false;
00607                 }
00608           }
00617          void setFromFile(const std::string& directory);        
00618  
00619 };
00620 
00621 } // End namespace asdm
00622 
00623 #endif /* SubscanTable_CLASS */