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 namespace asdm {
00124 
00125 //class asdm::ASDM;
00126 //class asdm::SBSummaryRow;
00127 
00128 class ASDM;
00129 class SBSummaryRow;
00285 class SBSummaryTable : public Representable {
00286         friend class ASDM;
00287 
00288 public:
00289 
00290 
00296         static std::vector<std::string> getKeyName();
00297 
00298 
00299         virtual ~SBSummaryTable();
00300         
00306         ASDM &getContainer() const;
00307         
00313         unsigned int size() const;
00314         
00322         std::string getName() const;
00323         
00331         static std::string name() ;     
00332         
00337          std::string getVersion() const ;
00338         
00344          static const std::vector<std::string>& getAttributesNames();
00345 
00351          static const std::vector<std::string>& defaultAttributesNamesInBin();
00352          
00356         Entity getEntity() const;
00357 
00362         void setEntity(Entity e);
00363                 
00371         std::string toXML()  ;
00372 
00373 #ifndef WITHOUT_ACS
00374         // Conversion Methods
00380         asdmIDL::SBSummaryTableIDL *toIDL() ;
00381 #endif
00382 
00383 #ifndef WITHOUT_ACS
00384 
00390         void fromIDL(asdmIDL::SBSummaryTableIDL x) ;
00391 #endif
00392         
00393         //
00394         // ====> Row creation.
00395         //
00396         
00401         SBSummaryRow *newRow();
00402         
00403         
00437         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);
00438         
00439 
00440 
00453          SBSummaryRow *newRow(SBSummaryRow *row); 
00454 
00455         //
00456         // ====> Append a row to its table.
00457         //
00458 
00459         
00460         
00461         
00471          SBSummaryRow* add(SBSummaryRow* x) ;
00472 
00473 
00474 
00475         //
00476         // ====> Methods returning rows.
00477         //
00478                 
00484         std::vector<SBSummaryRow *> get() ;
00485         
00492          const std::vector<SBSummaryRow *>& get() const ;
00493         
00494 
00495 
00496  
00497         
00507         SBSummaryRow* getRowByKey(Tag sBSummaryId);
00508 
00509                 
00510 
00511 
00512 
00548         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); 
00549 
00550 
00551         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00552         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00553 
00554 private:
00555 
00564         SBSummaryTable (ASDM & container);
00565 
00566         ASDM & container;
00567         
00568         bool archiveAsBin; // If true archive binary else archive XML
00569         bool fileAsBin ; // If true file binary else file XML   
00570         
00571         std::string version ; 
00572         
00573         Entity entity;
00574         
00575 
00576         // A map for the autoincrementation algorithm
00577         std::map<std::string,int>  noAutoIncIds;
00578         void autoIncrement(std::string key, SBSummaryRow* x);
00579 
00580 
00584         static std::string itsName;
00585         
00589         static std::vector<std::string> attributesNames;
00590         
00594         static std::vector<std::string> attributesNamesInBin;
00595         
00596 
00600         static bool initAttributesNames(), initAttributesNamesDone ;
00601         
00602 
00606         static std::vector<std::string> key;
00607 
00608 
00618         SBSummaryRow* checkAndAdd(SBSummaryRow* x) ;
00619         
00625          void append(SBSummaryRow* x) ;
00626          
00632          void addWithoutCheckingUnique(SBSummaryRow* x) ;
00633          
00634          
00635 
00636 
00637 
00638 // A data structure to store the pointers on the table's rows.
00639 
00640 // In all cases we maintain a private vector of SBSummaryRow s.
00641    std::vector<SBSummaryRow * > privateRows;
00642    
00643 
00644                         
00645         std::vector<SBSummaryRow *> row;
00646 
00647         
00648         void error() ; //throw(ConversionException);
00649 
00650         
00657         void fromXML(std::string& xmlDoc) ;
00658                 
00659         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00660 
00665         void setFromMIMEFile(const std::string& directory);
00666         /*
00667         void openMIMEFile(const std::string& directory);
00668         */
00669         void setFromXMLFile(const std::string& directory);
00670         
00678         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00679   
00680         
00687          void setFromMIME(const std::string & mimeMsg);
00688         
00692         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00693         
00703           void toFile(std::string directory);
00704           
00708           bool loadInProgress;
00709           void checkPresenceInMemory() {
00710                 if (!presentInMemory && !loadInProgress) {
00711                         loadInProgress = true;
00712                         setFromFile(getContainer().getDirectory());
00713                         presentInMemory = true;
00714                         loadInProgress = false;
00715                 }
00716           }
00725          void setFromFile(const std::string& directory);        
00726  
00727 };
00728 
00729 } // End namespace asdm
00730 
00731 #endif /* SBSummaryTable_CLASS */