casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SwitchCycleTable.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 SwitchCycleTable.h
00032  */
00033  
00034 #ifndef SwitchCycleTable_CLASS
00035 #define SwitchCycleTable_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 <Frequency.h>
00061         
00062 
00063 
00064 
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072         
00073 
00074         
00075 
00076         
00077 
00078         
00079 #include "CDirectionReferenceCode.h"
00080         
00081 
00082         
00083 
00084 
00085 
00086 #include <ConversionException.h>
00087 #include <DuplicateKey.h>
00088 #include <UniquenessViolationException.h>
00089 #include <NoSuchRow.h>
00090 #include <DuplicateKey.h>
00091 
00092 
00093 #ifndef WITHOUT_ACS
00094 #include <asdmIDLC.h>
00095 #endif
00096 
00097 #include <Representable.h>
00098 
00099 namespace asdm {
00100 
00101 //class asdm::ASDM;
00102 //class asdm::SwitchCycleRow;
00103 
00104 class ASDM;
00105 class SwitchCycleRow;
00191 class SwitchCycleTable : public Representable {
00192         friend class ASDM;
00193 
00194 public:
00195 
00196 
00202         static std::vector<std::string> getKeyName();
00203 
00204 
00205         virtual ~SwitchCycleTable();
00206         
00212         ASDM &getContainer() const;
00213         
00219         unsigned int size() const;
00220         
00228         std::string getName() const;
00229         
00237         static std::string name() ;     
00238         
00243          std::string getVersion() const ;
00244         
00250          static const std::vector<std::string>& getAttributesNames();
00251 
00257          static const std::vector<std::string>& defaultAttributesNamesInBin();
00258          
00262         Entity getEntity() const;
00263 
00268         void setEntity(Entity e);
00269                 
00277         std::string toXML()  ;
00278 
00279 #ifndef WITHOUT_ACS
00280         // Conversion Methods
00286         asdmIDL::SwitchCycleTableIDL *toIDL() ;
00287 #endif
00288 
00289 #ifndef WITHOUT_ACS
00290 
00296         void fromIDL(asdmIDL::SwitchCycleTableIDL x) ;
00297 #endif
00298         
00299         //
00300         // ====> Row creation.
00301         //
00302         
00307         SwitchCycleRow *newRow();
00308         
00309         
00325         SwitchCycleRow *newRow(int numStep, vector<float > weightArray, vector<vector<Angle > > dirOffsetArray, vector<Frequency > freqOffsetArray, vector<Interval > stepDurationArray);
00326         
00327 
00328 
00341          SwitchCycleRow *newRow(SwitchCycleRow *row); 
00342 
00343         //
00344         // ====> Append a row to its table.
00345         //
00346 
00347         
00348         
00349         
00359          SwitchCycleRow* add(SwitchCycleRow* x) ;
00360 
00361 
00362 
00363         //
00364         // ====> Methods returning rows.
00365         //
00366                 
00372         std::vector<SwitchCycleRow *> get() ;
00373         
00380          const std::vector<SwitchCycleRow *>& get() const ;
00381         
00382 
00383 
00384  
00385         
00395         SwitchCycleRow* getRowByKey(Tag switchCycleId);
00396 
00397                 
00398 
00399 
00400 
00418         SwitchCycleRow* lookup(int numStep, vector<float > weightArray, vector<vector<Angle > > dirOffsetArray, vector<Frequency > freqOffsetArray, vector<Interval > stepDurationArray); 
00419 
00420 
00421         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00422         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00423 
00424 private:
00425 
00434         SwitchCycleTable (ASDM & container);
00435 
00436         ASDM & container;
00437         
00438         bool archiveAsBin; // If true archive binary else archive XML
00439         bool fileAsBin ; // If true file binary else file XML   
00440         
00441         std::string version ; 
00442         
00443         Entity entity;
00444         
00445 
00446         // A map for the autoincrementation algorithm
00447         std::map<std::string,int>  noAutoIncIds;
00448         void autoIncrement(std::string key, SwitchCycleRow* x);
00449 
00450 
00454         static std::string itsName;
00455         
00459         static std::vector<std::string> attributesNames;
00460         
00464         static std::vector<std::string> attributesNamesInBin;
00465         
00466 
00470         static bool initAttributesNames(), initAttributesNamesDone ;
00471         
00472 
00476         static std::vector<std::string> key;
00477 
00478 
00488         SwitchCycleRow* checkAndAdd(SwitchCycleRow* x) ;
00489         
00495          void append(SwitchCycleRow* x) ;
00496          
00502          void addWithoutCheckingUnique(SwitchCycleRow* x) ;
00503          
00504          
00505 
00506 
00507 
00508 // A data structure to store the pointers on the table's rows.
00509 
00510 // In all cases we maintain a private vector of SwitchCycleRow s.
00511    std::vector<SwitchCycleRow * > privateRows;
00512    
00513 
00514                         
00515         std::vector<SwitchCycleRow *> row;
00516 
00517         
00518         void error() ; //throw(ConversionException);
00519 
00520         
00527         void fromXML(std::string& xmlDoc) ;
00528                 
00529         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00530 
00535         void setFromMIMEFile(const std::string& directory);
00536         /*
00537         void openMIMEFile(const std::string& directory);
00538         */
00539         void setFromXMLFile(const std::string& directory);
00540         
00548         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00549   
00550         
00557          void setFromMIME(const std::string & mimeMsg);
00558         
00562         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00563         
00573           void toFile(std::string directory);
00574           
00578           bool loadInProgress;
00579           void checkPresenceInMemory() {
00580                 if (!presentInMemory && !loadInProgress) {
00581                         loadInProgress = true;
00582                         setFromFile(getContainer().getDirectory());
00583                         presentInMemory = true;
00584                         loadInProgress = false;
00585                 }
00586           }
00595          void setFromFile(const std::string& directory);        
00596  
00597 };
00598 
00599 } // End namespace asdm
00600 
00601 #endif /* SwitchCycleTable_CLASS */