casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalReductionTable.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 CalReductionTable.h
00032  */
00033  
00034 #ifndef CalReductionTable_CLASS
00035 #define CalReductionTable_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 
00066         
00067 #include "CInvalidatingCondition.h"
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 
00078 
00079 
00080 #include <ConversionException.h>
00081 #include <DuplicateKey.h>
00082 #include <UniquenessViolationException.h>
00083 #include <NoSuchRow.h>
00084 #include <DuplicateKey.h>
00085 
00086 
00087 #ifndef WITHOUT_ACS
00088 #include <asdmIDLC.h>
00089 #endif
00090 
00091 #include <Representable.h>
00092 
00093 #include <pthread.h>
00094 
00095 namespace asdm {
00096 
00097 //class asdm::ASDM;
00098 //class asdm::CalReductionRow;
00099 
00100 class ASDM;
00101 class CalReductionRow;
00205 class CalReductionTable : public Representable {
00206         friend class ASDM;
00207 
00208 public:
00209 
00210 
00216         static const std::vector<std::string>& getKeyName();
00217 
00218 
00219         virtual ~CalReductionTable();
00220         
00226         ASDM &getContainer() const;
00227         
00233         unsigned int size() const;
00234         
00242         std::string getName() const;
00243         
00251         static std::string name() ;     
00252         
00257          std::string getVersion() const ;
00258         
00264          static const std::vector<std::string>& getAttributesNames();
00265 
00271          static const std::vector<std::string>& defaultAttributesNamesInBin();
00272          
00276         Entity getEntity() const;
00277 
00282         void setEntity(Entity e);
00283                 
00291         std::string toXML()  ;
00292 
00293 #ifndef WITHOUT_ACS
00294         // Conversion Methods
00300         asdmIDL::CalReductionTableIDL *toIDL() ;
00301         
00309          void toIDL(asdmIDL::CalReductionTableIDL& x) const;
00310          
00311 #endif
00312 
00313 #ifndef WITHOUT_ACS
00314 
00320         void fromIDL(asdmIDL::CalReductionTableIDL x) ;
00321 #endif
00322         
00323         //
00324         // ====> Row creation.
00325         //
00326         
00331         CalReductionRow *newRow();
00332         
00333         
00359         CalReductionRow *newRow(int numApplied, vector<string > appliedCalibrations, int numParam, vector<string > paramSet, int numInvalidConditions, vector<InvalidatingConditionMod::InvalidatingCondition > invalidConditions, ArrayTime timeReduced, string messages, string software, string softwareVersion);
00360         
00361 
00362 
00375          CalReductionRow *newRow(CalReductionRow *row); 
00376 
00377         //
00378         // ====> Append a row to its table.
00379         //
00380 
00381         
00382         
00383         
00393          CalReductionRow* add(CalReductionRow* x) ;
00394 
00395 
00396 
00397         //
00398         // ====> Methods returning rows.
00399         //
00400                 
00406         std::vector<CalReductionRow *> get() ;
00407         
00414          const std::vector<CalReductionRow *>& get() const ;
00415         
00416 
00417 
00418  
00419         
00429         CalReductionRow* getRowByKey(Tag calReductionId);
00430 
00431                 
00432 
00433 
00434 
00462         CalReductionRow* lookup(int numApplied, vector<string > appliedCalibrations, int numParam, vector<string > paramSet, int numInvalidConditions, vector<InvalidatingConditionMod::InvalidatingCondition > invalidConditions, ArrayTime timeReduced, string messages, string software, string softwareVersion); 
00463 
00464 
00465         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00466         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00467 
00468 private:
00469 
00478         CalReductionTable (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         // A map for the autoincrementation algorithm
00491         std::map<std::string,int>  noAutoIncIds;
00492         void autoIncrement(std::string key, CalReductionRow* x);
00493 
00494 
00504         CalReductionRow* checkAndAdd(CalReductionRow* x, bool skipCheckUniqueness=false) ;
00505         
00511          void append(CalReductionRow* x) ;
00512          
00518          void addWithoutCheckingUnique(CalReductionRow* x) ;
00519          
00520          
00521 
00522 
00523 
00524 // A data structure to store the pointers on the table's rows.
00525 
00526 // In all cases we maintain a private vector of CalReductionRow s.
00527    std::vector<CalReductionRow * > privateRows;
00528    
00529 
00530                         
00531         std::vector<CalReductionRow *> row;
00532 
00533         
00534         void error() ; //throw(ConversionException);
00535 
00536         
00543         void fromXML(std::string& xmlDoc) ;
00544                 
00545         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00546 
00551         void setFromMIMEFile(const std::string& directory);
00552         /*
00553         void openMIMEFile(const std::string& directory);
00554         */
00555         void setFromXMLFile(const std::string& directory);
00556         
00564         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00565   
00566         
00573          void setFromMIME(const std::string & mimeMsg);
00574         
00578         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00579         
00589           void toFile(std::string directory);
00590           
00594           bool loadInProgress;
00595           void checkPresenceInMemory() {
00596                 if (!presentInMemory && !loadInProgress) {
00597                         loadInProgress = true;
00598                         setFromFile(getContainer().getDirectory());
00599                         presentInMemory = true;
00600                         loadInProgress = false;
00601                 }
00602           }
00611          void setFromFile(const std::string& directory);        
00612  
00613 };
00614 
00615 } // End namespace asdm
00616 
00617 #endif /* CalReductionTable_CLASS */