casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SBSummaryTable.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 SBSummaryTable.h
00032  */
00033  
00034 #ifndef SBSummaryTable_CLASS
00035 #define SBSummaryTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <ArrayTime.h>
00045         
00046 
00047         
00048 #include <Angle.h>
00049         
00050 
00051         
00052 #include <Interval.h>
00053         
00054 
00055         
00056 #include <Tag.h>
00057         
00058 
00059         
00060 #include <EntityRef.h>
00061         
00062 
00063 
00064 
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 #include "CReceiverBand.h"
00078         
00079 
00080         
00081 #include "CSBType.h"
00082         
00083 
00084         
00085 
00086         
00087 
00088         
00089 
00090         
00091 
00092         
00093 
00094         
00095 
00096         
00097 
00098         
00099 
00100         
00101 
00102         
00103 #include "CDirectionReferenceCode.h"
00104         
00105 
00106         
00107 
00108 
00109 
00110 #include <ConversionException.h>
00111 #include <DuplicateKey.h>
00112 #include <UniquenessViolationException.h>
00113 #include <NoSuchRow.h>
00114 #include <DuplicateKey.h>
00115 
00116 
00117 #ifndef WITHOUT_ACS
00118 #include <asdmIDLC.h>
00119 #endif
00120 
00121 #include <Representable.h>
00122 
00123 #include <pthread.h>
00124 
00125 namespace asdm {
00126 
00127 //class asdm::ASDM;
00128 //class asdm::SBSummaryRow;
00129 
00130 class ASDM;
00131 class SBSummaryRow;
00287 class SBSummaryTable : public Representable {
00288         friend class ASDM;
00289 
00290 public:
00291 
00292 
00298         static const std::vector<std::string>& getKeyName();
00299 
00300 
00301         virtual ~SBSummaryTable();
00302         
00308         ASDM &getContainer() const;
00309         
00315         unsigned int size() const;
00316         
00324         std::string getName() const;
00325         
00333         static std::string name() ;     
00334         
00339          std::string getVersion() const ;
00340         
00346          static const std::vector<std::string>& getAttributesNames();
00347 
00353          static const std::vector<std::string>& defaultAttributesNamesInBin();
00354          
00358         Entity getEntity() const;
00359 
00364         void setEntity(Entity e);
00365                 
00373         std::string toXML()  ;
00374 
00375 #ifndef WITHOUT_ACS
00376         // Conversion Methods
00382         asdmIDL::SBSummaryTableIDL *toIDL() ;
00383         
00391          void toIDL(asdmIDL::SBSummaryTableIDL& x) const;
00392          
00393 #endif
00394 
00395 #ifndef WITHOUT_ACS
00396 
00402         void fromIDL(asdmIDL::SBSummaryTableIDL x) ;
00403 #endif
00404         
00405         //
00406         // ====> Row creation.
00407         //
00408         
00413         SBSummaryRow *newRow();
00414         
00415         
00449         SBSummaryRow *newRow(EntityRef sbSummaryUID, EntityRef projectUID, EntityRef obsUnitSetUID, double frequency, ReceiverBandMod::ReceiverBand frequencyBand, SBTypeMod::SBType sbType, Interval sbDuration, int numObservingMode, vector<string > observingMode, int numberRepeats, int numScienceGoal, vector<string > scienceGoal, int numWeatherConstraint, vector<string > weatherConstraint);
00450         
00451 
00452 
00465          SBSummaryRow *newRow(SBSummaryRow *row); 
00466 
00467         //
00468         // ====> Append a row to its table.
00469         //
00470 
00471         
00472         
00473         
00483          SBSummaryRow* add(SBSummaryRow* x) ;
00484 
00485 
00486 
00487         //
00488         // ====> Methods returning rows.
00489         //
00490                 
00496         std::vector<SBSummaryRow *> get() ;
00497         
00504          const std::vector<SBSummaryRow *>& get() const ;
00505         
00506 
00507 
00508  
00509         
00519         SBSummaryRow* getRowByKey(Tag sBSummaryId);
00520 
00521                 
00522 
00523 
00524 
00560         SBSummaryRow* lookup(EntityRef sbSummaryUID, EntityRef projectUID, EntityRef obsUnitSetUID, double frequency, ReceiverBandMod::ReceiverBand frequencyBand, SBTypeMod::SBType sbType, Interval sbDuration, int numObservingMode, vector<string > observingMode, int numberRepeats, int numScienceGoal, vector<string > scienceGoal, int numWeatherConstraint, vector<string > weatherConstraint); 
00561 
00562 
00563         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00564         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00565 
00566 private:
00567 
00576         SBSummaryTable (ASDM & container);
00577 
00578         ASDM & container;
00579         
00580         bool archiveAsBin; // If true archive binary else archive XML
00581         bool fileAsBin ; // If true file binary else file XML   
00582         
00583         std::string version ; 
00584         
00585         Entity entity;
00586         
00587 
00588         // A map for the autoincrementation algorithm
00589         std::map<std::string,int>  noAutoIncIds;
00590         void autoIncrement(std::string key, SBSummaryRow* x);
00591 
00592 
00602         SBSummaryRow* checkAndAdd(SBSummaryRow* x, bool skipCheckUniqueness=false) ;
00603         
00609          void append(SBSummaryRow* x) ;
00610          
00616          void addWithoutCheckingUnique(SBSummaryRow* x) ;
00617          
00618          
00619 
00620 
00621 
00622 // A data structure to store the pointers on the table's rows.
00623 
00624 // In all cases we maintain a private vector of SBSummaryRow s.
00625    std::vector<SBSummaryRow * > privateRows;
00626    
00627 
00628                         
00629         std::vector<SBSummaryRow *> row;
00630 
00631         
00632         void error() ; //throw(ConversionException);
00633 
00634         
00641         void fromXML(std::string& xmlDoc) ;
00642                 
00643         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00644 
00649         void setFromMIMEFile(const std::string& directory);
00650         /*
00651         void openMIMEFile(const std::string& directory);
00652         */
00653         void setFromXMLFile(const std::string& directory);
00654         
00662         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00663   
00664         
00671          void setFromMIME(const std::string & mimeMsg);
00672         
00676         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00677         
00687           void toFile(std::string directory);
00688           
00692           bool loadInProgress;
00693           void checkPresenceInMemory() {
00694                 if (!presentInMemory && !loadInProgress) {
00695                         loadInProgress = true;
00696                         setFromFile(getContainer().getDirectory());
00697                         presentInMemory = true;
00698                         loadInProgress = false;
00699                 }
00700           }
00709          void setFromFile(const std::string& directory);        
00710  
00711 };
00712 
00713 } // End namespace asdm
00714 
00715 #endif /* SBSummaryTable_CLASS */