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 namespace asdm {
00094 
00095 //class asdm::ASDM;
00096 //class asdm::CalReductionRow;
00097 
00098 class ASDM;
00099 class CalReductionRow;
00203 class CalReductionTable : public Representable {
00204         friend class ASDM;
00205 
00206 public:
00207 
00208 
00214         static std::vector<std::string> getKeyName();
00215 
00216 
00217         virtual ~CalReductionTable();
00218         
00224         ASDM &getContainer() const;
00225         
00231         unsigned int size() const;
00232         
00240         std::string getName() const;
00241         
00249         static std::string name() ;     
00250         
00255          std::string getVersion() const ;
00256         
00262          static const std::vector<std::string>& getAttributesNames();
00263 
00269          static const std::vector<std::string>& defaultAttributesNamesInBin();
00270          
00274         Entity getEntity() const;
00275 
00280         void setEntity(Entity e);
00281                 
00289         std::string toXML()  ;
00290 
00291 #ifndef WITHOUT_ACS
00292         // Conversion Methods
00298         asdmIDL::CalReductionTableIDL *toIDL() ;
00299 #endif
00300 
00301 #ifndef WITHOUT_ACS
00302 
00308         void fromIDL(asdmIDL::CalReductionTableIDL x) ;
00309 #endif
00310         
00311         //
00312         // ====> Row creation.
00313         //
00314         
00319         CalReductionRow *newRow();
00320         
00321         
00347         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);
00348         
00349 
00350 
00363          CalReductionRow *newRow(CalReductionRow *row); 
00364 
00365         //
00366         // ====> Append a row to its table.
00367         //
00368 
00369         
00370         
00371         
00381          CalReductionRow* add(CalReductionRow* x) ;
00382 
00383 
00384 
00385         //
00386         // ====> Methods returning rows.
00387         //
00388                 
00394         std::vector<CalReductionRow *> get() ;
00395         
00402          const std::vector<CalReductionRow *>& get() const ;
00403         
00404 
00405 
00406  
00407         
00417         CalReductionRow* getRowByKey(Tag calReductionId);
00418 
00419                 
00420 
00421 
00422 
00450         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); 
00451 
00452 
00453         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00454         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00455 
00456 private:
00457 
00466         CalReductionTable (ASDM & container);
00467 
00468         ASDM & container;
00469         
00470         bool archiveAsBin; // If true archive binary else archive XML
00471         bool fileAsBin ; // If true file binary else file XML   
00472         
00473         std::string version ; 
00474         
00475         Entity entity;
00476         
00477 
00478         // A map for the autoincrementation algorithm
00479         std::map<std::string,int>  noAutoIncIds;
00480         void autoIncrement(std::string key, CalReductionRow* x);
00481 
00482 
00486         static std::string itsName;
00487         
00491         static std::vector<std::string> attributesNames;
00492         
00496         static std::vector<std::string> attributesNamesInBin;
00497         
00498 
00502         static bool initAttributesNames(), initAttributesNamesDone ;
00503         
00504 
00508         static std::vector<std::string> key;
00509 
00510 
00520         CalReductionRow* checkAndAdd(CalReductionRow* x) ;
00521         
00527          void append(CalReductionRow* x) ;
00528          
00534          void addWithoutCheckingUnique(CalReductionRow* x) ;
00535          
00536          
00537 
00538 
00539 
00540 // A data structure to store the pointers on the table's rows.
00541 
00542 // In all cases we maintain a private vector of CalReductionRow s.
00543    std::vector<CalReductionRow * > privateRows;
00544    
00545 
00546                         
00547         std::vector<CalReductionRow *> row;
00548 
00549         
00550         void error() ; //throw(ConversionException);
00551 
00552         
00559         void fromXML(std::string& xmlDoc) ;
00560                 
00561         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00562 
00567         void setFromMIMEFile(const std::string& directory);
00568         /*
00569         void openMIMEFile(const std::string& directory);
00570         */
00571         void setFromXMLFile(const std::string& directory);
00572         
00580         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00581   
00582         
00589          void setFromMIME(const std::string & mimeMsg);
00590         
00594         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00595         
00605           void toFile(std::string directory);
00606           
00610           bool loadInProgress;
00611           void checkPresenceInMemory() {
00612                 if (!presentInMemory && !loadInProgress) {
00613                         loadInProgress = true;
00614                         setFromFile(getContainer().getDirectory());
00615                         presentInMemory = true;
00616                         loadInProgress = false;
00617                 }
00618           }
00627          void setFromFile(const std::string& directory);        
00628  
00629 };
00630 
00631 } // End namespace asdm
00632 
00633 #endif /* CalReductionTable_CLASS */