casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CorrelatorModeTable.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 CorrelatorModeTable.h
00032  */
00033  
00034 #ifndef CorrelatorModeTable_CLASS
00035 #define CorrelatorModeTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047 
00048 
00049 
00050         
00051 
00052         
00053 
00054         
00055 #include "CBasebandName.h"
00056         
00057 
00058         
00059 
00060         
00061 #include "CAccumMode.h"
00062         
00063 
00064         
00065 
00066         
00067 
00068         
00069 #include "CAxisName.h"
00070         
00071 
00072         
00073 #include "CFilterMode.h"
00074         
00075 
00076         
00077 #include "CCorrelatorName.h"
00078         
00079 
00080 
00081 
00082 #include <ConversionException.h>
00083 #include <DuplicateKey.h>
00084 #include <UniquenessViolationException.h>
00085 #include <NoSuchRow.h>
00086 #include <DuplicateKey.h>
00087 
00088 
00089 #ifndef WITHOUT_ACS
00090 #include <asdmIDLC.h>
00091 #endif
00092 
00093 #include <Representable.h>
00094 
00095 namespace asdm {
00096 
00097 //class asdm::ASDM;
00098 //class asdm::CorrelatorModeRow;
00099 
00100 class ASDM;
00101 class CorrelatorModeRow;
00198 class CorrelatorModeTable : public Representable {
00199         friend class ASDM;
00200 
00201 public:
00202 
00203 
00209         static std::vector<std::string> getKeyName();
00210 
00211 
00212         virtual ~CorrelatorModeTable();
00213         
00219         ASDM &getContainer() const;
00220         
00226         unsigned int size() const;
00227         
00235         std::string getName() const;
00236         
00244         static std::string name() ;     
00245         
00250          std::string getVersion() const ;
00251         
00257          static const std::vector<std::string>& getAttributesNames();
00258 
00264          static const std::vector<std::string>& defaultAttributesNamesInBin();
00265          
00269         Entity getEntity() const;
00270 
00275         void setEntity(Entity e);
00276                 
00284         std::string toXML()  ;
00285 
00286 #ifndef WITHOUT_ACS
00287         // Conversion Methods
00293         asdmIDL::CorrelatorModeTableIDL *toIDL() ;
00294 #endif
00295 
00296 #ifndef WITHOUT_ACS
00297 
00303         void fromIDL(asdmIDL::CorrelatorModeTableIDL x) ;
00304 #endif
00305         
00306         //
00307         // ====> Row creation.
00308         //
00309         
00314         CorrelatorModeRow *newRow();
00315         
00316         
00340         CorrelatorModeRow *newRow(int numBaseband, vector<BasebandNameMod::BasebandName > basebandNames, vector<int > basebandConfig, AccumModeMod::AccumMode accumMode, int binMode, int numAxes, vector<AxisNameMod::AxisName > axesOrderArray, vector<FilterModeMod::FilterMode > filterMode, CorrelatorNameMod::CorrelatorName correlatorName);
00341         
00342 
00343 
00356          CorrelatorModeRow *newRow(CorrelatorModeRow *row); 
00357 
00358         //
00359         // ====> Append a row to its table.
00360         //
00361 
00362         
00363         
00364         
00374          CorrelatorModeRow* add(CorrelatorModeRow* x) ;
00375 
00376 
00377 
00378         //
00379         // ====> Methods returning rows.
00380         //
00381                 
00387         std::vector<CorrelatorModeRow *> get() ;
00388         
00395          const std::vector<CorrelatorModeRow *>& get() const ;
00396         
00397 
00398 
00399  
00400         
00410         CorrelatorModeRow* getRowByKey(Tag correlatorModeId);
00411 
00412                 
00413 
00414 
00415 
00441         CorrelatorModeRow* lookup(int numBaseband, vector<BasebandNameMod::BasebandName > basebandNames, vector<int > basebandConfig, AccumModeMod::AccumMode accumMode, int binMode, int numAxes, vector<AxisNameMod::AxisName > axesOrderArray, vector<FilterModeMod::FilterMode > filterMode, CorrelatorNameMod::CorrelatorName correlatorName); 
00442 
00443 
00444         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00445         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00446 
00447 private:
00448 
00457         CorrelatorModeTable (ASDM & container);
00458 
00459         ASDM & container;
00460         
00461         bool archiveAsBin; // If true archive binary else archive XML
00462         bool fileAsBin ; // If true file binary else file XML   
00463         
00464         std::string version ; 
00465         
00466         Entity entity;
00467         
00468 
00469         // A map for the autoincrementation algorithm
00470         std::map<std::string,int>  noAutoIncIds;
00471         void autoIncrement(std::string key, CorrelatorModeRow* x);
00472 
00473 
00477         static std::string itsName;
00478         
00482         static std::vector<std::string> attributesNames;
00483         
00487         static std::vector<std::string> attributesNamesInBin;
00488         
00489 
00493         static bool initAttributesNames(), initAttributesNamesDone ;
00494         
00495 
00499         static std::vector<std::string> key;
00500 
00501 
00511         CorrelatorModeRow* checkAndAdd(CorrelatorModeRow* x) ;
00512         
00518          void append(CorrelatorModeRow* x) ;
00519          
00525          void addWithoutCheckingUnique(CorrelatorModeRow* x) ;
00526          
00527          
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 CorrelatorModeRow s.
00534    std::vector<CorrelatorModeRow * > privateRows;
00535    
00536 
00537                         
00538         std::vector<CorrelatorModeRow *> row;
00539 
00540         
00541         void error() ; //throw(ConversionException);
00542 
00543         
00550         void fromXML(std::string& xmlDoc) ;
00551                 
00552         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00553 
00558         void setFromMIMEFile(const std::string& directory);
00559         /*
00560         void openMIMEFile(const std::string& directory);
00561         */
00562         void setFromXMLFile(const std::string& directory);
00563         
00571         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00572   
00573         
00580          void setFromMIME(const std::string & mimeMsg);
00581         
00585         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00586         
00596           void toFile(std::string directory);
00597           
00601           bool loadInProgress;
00602           void checkPresenceInMemory() {
00603                 if (!presentInMemory && !loadInProgress) {
00604                         loadInProgress = true;
00605                         setFromFile(getContainer().getDirectory());
00606                         presentInMemory = true;
00607                         loadInProgress = false;
00608                 }
00609           }
00618          void setFromFile(const std::string& directory);        
00619  
00620 };
00621 
00622 } // End namespace asdm
00623 
00624 #endif /* CorrelatorModeTable_CLASS */