casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SysPowerTable.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 SysPowerTable.h
00032  */
00033  
00034 #ifndef SysPowerTable_CLASS
00035 #define SysPowerTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047         
00048 #include <ArrayTimeInterval.h>
00049         
00050 
00051 
00052 
00053 
00054         
00055 
00056         
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064 
00065 
00066 #include <ConversionException.h>
00067 #include <DuplicateKey.h>
00068 #include <UniquenessViolationException.h>
00069 #include <NoSuchRow.h>
00070 #include <DuplicateKey.h>
00071 
00072 
00073 #ifndef WITHOUT_ACS
00074 #include <asdmIDLC.h>
00075 #endif
00076 
00077 #include <Representable.h>
00078 
00079 namespace asdm {
00080 
00081 //class asdm::ASDM;
00082 //class asdm::SysPowerRow;
00083 
00084 class ASDM;
00085 class SysPowerRow;
00182 class SysPowerTable : public Representable {
00183         friend class ASDM;
00184 
00185 public:
00186 
00187 
00193         static std::vector<std::string> getKeyName();
00194 
00195 
00196         virtual ~SysPowerTable();
00197         
00203         ASDM &getContainer() const;
00204         
00210         unsigned int size() const;
00211         
00219         std::string getName() const;
00220         
00228         static std::string name() ;     
00229         
00234          std::string getVersion() const ;
00235         
00241          static const std::vector<std::string>& getAttributesNames();
00242 
00248          static const std::vector<std::string>& defaultAttributesNamesInBin();
00249          
00253         Entity getEntity() const;
00254 
00259         void setEntity(Entity e);
00260                 
00268         std::string toXML()  ;
00269 
00270 #ifndef WITHOUT_ACS
00271         // Conversion Methods
00277         asdmIDL::SysPowerTableIDL *toIDL() ;
00278 #endif
00279 
00280 #ifndef WITHOUT_ACS
00281 
00287         void fromIDL(asdmIDL::SysPowerTableIDL x) ;
00288 #endif
00289         
00290         //
00291         // ====> Row creation.
00292         //
00293         
00298         SysPowerRow *newRow();
00299         
00300         
00316         SysPowerRow *newRow(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval, int numReceptor);
00317         
00318 
00319 
00332          SysPowerRow *newRow(SysPowerRow *row); 
00333 
00334         //
00335         // ====> Append a row to its table.
00336         //
00337  
00338         
00355         SysPowerRow* add(SysPowerRow* x) ; 
00356 
00357  
00358 
00359 
00360 
00361         //
00362         // ====> Methods returning rows.
00363         //
00364                 
00370         std::vector<SysPowerRow *> get() ;
00371         
00378          const std::vector<SysPowerRow *>& get() const ;
00379         
00380 
00391          std::vector <SysPowerRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
00392          
00393 
00394 
00395  
00396         
00412         SysPowerRow* getRowByKey(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval);
00413 
00414                 
00415 
00416 
00417 
00435         SysPowerRow* lookup(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval, int numReceptor); 
00436 
00437 
00438         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00439         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00440 
00441 private:
00442 
00451         SysPowerTable (ASDM & container);
00452 
00453         ASDM & container;
00454         
00455         bool archiveAsBin; // If true archive binary else archive XML
00456         bool fileAsBin ; // If true file binary else file XML   
00457         
00458         std::string version ; 
00459         
00460         Entity entity;
00461         
00462 
00463 
00467         static std::string itsName;
00468         
00472         static std::vector<std::string> attributesNames;
00473         
00477         static std::vector<std::string> attributesNamesInBin;
00478         
00479 
00483         static bool initAttributesNames(), initAttributesNamesDone ;
00484         
00485 
00489         static std::vector<std::string> key;
00490 
00491 
00499         SysPowerRow* checkAndAdd(SysPowerRow* x) ;
00500         
00506          void append(SysPowerRow* x) ;
00507          
00513          void addWithoutCheckingUnique(SysPowerRow* x) ;
00514          
00515          
00516 
00517 
00518         
00519         
00527          SysPowerRow * insertByStartTime(SysPowerRow* x, std::vector<SysPowerRow* >& row);
00528           
00529 
00530 
00531 // A data structure to store the pointers on the table's rows.
00532 
00533 // In all cases we maintain a private vector of SysPowerRow s.
00534    std::vector<SysPowerRow * > privateRows;
00535    
00536 
00537         
00538 
00539         
00540         
00541                 
00542                                 
00543         typedef std::vector <SysPowerRow* > TIME_ROWS;
00544         std::map<std::string, TIME_ROWS > context;
00545                 
00550          std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
00551                  
00552                 
00553         
00554         
00560         void getByKeyNoAutoIncNoTime(std::vector <SysPowerRow*>& vin, std::vector <SysPowerRow*>& vout,  Tag antennaId, Tag spectralWindowId, int feedId);
00561         
00562 
00563         
00564         void error() ; //throw(ConversionException);
00565 
00566         
00573         void fromXML(std::string& xmlDoc) ;
00574                 
00575         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00576 
00581         void setFromMIMEFile(const std::string& directory);
00582         /*
00583         void openMIMEFile(const std::string& directory);
00584         */
00585         void setFromXMLFile(const std::string& directory);
00586         
00594         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00595   
00596         
00603          void setFromMIME(const std::string & mimeMsg);
00604         
00608         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00609         
00619           void toFile(std::string directory);
00620           
00624           bool loadInProgress;
00625           void checkPresenceInMemory() {
00626                 if (!presentInMemory && !loadInProgress) {
00627                         loadInProgress = true;
00628                         setFromFile(getContainer().getDirectory());
00629                         presentInMemory = true;
00630                         loadInProgress = false;
00631                 }
00632           }
00641          void setFromFile(const std::string& directory);        
00642  
00643 };
00644 
00645 } // End namespace asdm
00646 
00647 #endif /* SysPowerTable_CLASS */