casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FocusTable.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 FocusTable.h
00032  */
00033  
00034 #ifndef FocusTable_CLASS
00035 #define FocusTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Angle.h>
00045         
00046 
00047         
00048 #include <Tag.h>
00049         
00050 
00051         
00052 #include <Length.h>
00053         
00054 
00055         
00056 #include <ArrayTimeInterval.h>
00057         
00058 
00059 
00060 
00061 
00062         
00063 
00064         
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074 
00075 
00076 #include <ConversionException.h>
00077 #include <DuplicateKey.h>
00078 #include <UniquenessViolationException.h>
00079 #include <NoSuchRow.h>
00080 #include <DuplicateKey.h>
00081 
00082 
00083 #ifndef WITHOUT_ACS
00084 #include <asdmIDLC.h>
00085 #endif
00086 
00087 #include <Representable.h>
00088 
00089 namespace asdm {
00090 
00091 //class asdm::ASDM;
00092 //class asdm::FocusRow;
00093 
00094 class ASDM;
00095 class FocusRow;
00183 class FocusTable : public Representable {
00184         friend class ASDM;
00185 
00186 public:
00187 
00188 
00194         static std::vector<std::string> getKeyName();
00195 
00196 
00197         virtual ~FocusTable();
00198         
00204         ASDM &getContainer() const;
00205         
00211         unsigned int size() const;
00212         
00220         std::string getName() const;
00221         
00229         static std::string name() ;     
00230         
00235          std::string getVersion() const ;
00236         
00242          static const std::vector<std::string>& getAttributesNames();
00243 
00249          static const std::vector<std::string>& defaultAttributesNamesInBin();
00250          
00254         Entity getEntity() const;
00255 
00260         void setEntity(Entity e);
00261                 
00269         std::string toXML()  ;
00270 
00271 #ifndef WITHOUT_ACS
00272         // Conversion Methods
00278         asdmIDL::FocusTableIDL *toIDL() ;
00279 #endif
00280 
00281 #ifndef WITHOUT_ACS
00282 
00288         void fromIDL(asdmIDL::FocusTableIDL x) ;
00289 #endif
00290         
00291         //
00292         // ====> Row creation.
00293         //
00294         
00299         FocusRow *newRow();
00300         
00301         
00319         FocusRow *newRow(Tag antennaId, ArrayTimeInterval timeInterval, bool focusTracking, vector<Length > focusOffset, vector<Angle > focusRotationOffset, int focusModelId);
00320         
00321 
00322 
00335          FocusRow *newRow(FocusRow *row); 
00336 
00337         //
00338         // ====> Append a row to its table.
00339         //
00340  
00341         
00358         FocusRow* add(FocusRow* x) ; 
00359 
00360  
00361 
00362 
00363 
00364         //
00365         // ====> Methods returning rows.
00366         //
00367                 
00373         std::vector<FocusRow *> get() ;
00374         
00381          const std::vector<FocusRow *>& get() const ;
00382         
00383 
00394          std::vector <FocusRow*> *getByContext(Tag antennaId);
00395          
00396 
00397 
00398  
00399         
00411         FocusRow* getRowByKey(Tag antennaId, ArrayTimeInterval timeInterval);
00412 
00413                 
00414 
00415 
00416 
00436         FocusRow* lookup(Tag antennaId, ArrayTimeInterval timeInterval, bool focusTracking, vector<Length > focusOffset, vector<Angle > focusRotationOffset, int focusModelId); 
00437 
00438 
00439         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00440         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00441 
00442 private:
00443 
00452         FocusTable (ASDM & container);
00453 
00454         ASDM & container;
00455         
00456         bool archiveAsBin; // If true archive binary else archive XML
00457         bool fileAsBin ; // If true file binary else file XML   
00458         
00459         std::string version ; 
00460         
00461         Entity entity;
00462         
00463 
00464 
00468         static std::string itsName;
00469         
00473         static std::vector<std::string> attributesNames;
00474         
00478         static std::vector<std::string> attributesNamesInBin;
00479         
00480 
00484         static bool initAttributesNames(), initAttributesNamesDone ;
00485         
00486 
00490         static std::vector<std::string> key;
00491 
00492 
00500         FocusRow* checkAndAdd(FocusRow* x) ;
00501         
00507          void append(FocusRow* x) ;
00508          
00514          void addWithoutCheckingUnique(FocusRow* x) ;
00515          
00516          
00517 
00518 
00519         
00520         
00528          FocusRow * insertByStartTime(FocusRow* x, std::vector<FocusRow* >& row);
00529           
00530 
00531 
00532 // A data structure to store the pointers on the table's rows.
00533 
00534 // In all cases we maintain a private vector of FocusRow s.
00535    std::vector<FocusRow * > privateRows;
00536    
00537 
00538         
00539 
00540         
00541         
00542                 
00543                                 
00544         typedef std::vector <FocusRow* > TIME_ROWS;
00545         std::map<std::string, TIME_ROWS > context;
00546                 
00551          std::string Key(Tag antennaId) ;
00552                  
00553                 
00554         
00555         
00561         void getByKeyNoAutoIncNoTime(std::vector <FocusRow*>& vin, std::vector <FocusRow*>& vout,  Tag antennaId);
00562         
00563 
00564         
00565         void error() ; //throw(ConversionException);
00566 
00567         
00574         void fromXML(std::string& xmlDoc) ;
00575                 
00576         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00577 
00582         void setFromMIMEFile(const std::string& directory);
00583         /*
00584         void openMIMEFile(const std::string& directory);
00585         */
00586         void setFromXMLFile(const std::string& directory);
00587         
00595         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00596   
00597         
00604          void setFromMIME(const std::string & mimeMsg);
00605         
00609         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00610         
00620           void toFile(std::string directory);
00621           
00625           bool loadInProgress;
00626           void checkPresenceInMemory() {
00627                 if (!presentInMemory && !loadInProgress) {
00628                         loadInProgress = true;
00629                         setFromFile(getContainer().getDirectory());
00630                         presentInMemory = true;
00631                         loadInProgress = false;
00632                 }
00633           }
00642          void setFromFile(const std::string& directory);        
00643  
00644 };
00645 
00646 } // End namespace asdm
00647 
00648 #endif /* FocusTable_CLASS */