casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SquareLawDetectorTable.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 SquareLawDetectorTable.h
00032  */
00033  
00034 #ifndef SquareLawDetectorTable_CLASS
00035 #define SquareLawDetectorTable_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 "CDetectorBandType.h"
00056         
00057 
00058 
00059 
00060 #include <ConversionException.h>
00061 #include <DuplicateKey.h>
00062 #include <UniquenessViolationException.h>
00063 #include <NoSuchRow.h>
00064 #include <DuplicateKey.h>
00065 
00066 
00067 #ifndef WITHOUT_ACS
00068 #include <asdmIDLC.h>
00069 #endif
00070 
00071 #include <Representable.h>
00072 
00073 namespace asdm {
00074 
00075 //class asdm::ASDM;
00076 //class asdm::SquareLawDetectorRow;
00077 
00078 class ASDM;
00079 class SquareLawDetectorRow;
00127 class SquareLawDetectorTable : public Representable {
00128         friend class ASDM;
00129 
00130 public:
00131 
00132 
00138         static std::vector<std::string> getKeyName();
00139 
00140 
00141         virtual ~SquareLawDetectorTable();
00142         
00148         ASDM &getContainer() const;
00149         
00155         unsigned int size() const;
00156         
00164         std::string getName() const;
00165         
00173         static std::string name() ;     
00174         
00179          std::string getVersion() const ;
00180         
00186          static const std::vector<std::string>& getAttributesNames();
00187 
00193          static const std::vector<std::string>& defaultAttributesNamesInBin();
00194          
00198         Entity getEntity() const;
00199 
00204         void setEntity(Entity e);
00205                 
00213         std::string toXML()  ;
00214 
00215 #ifndef WITHOUT_ACS
00216         // Conversion Methods
00222         asdmIDL::SquareLawDetectorTableIDL *toIDL() ;
00223 #endif
00224 
00225 #ifndef WITHOUT_ACS
00226 
00232         void fromIDL(asdmIDL::SquareLawDetectorTableIDL x) ;
00233 #endif
00234         
00235         //
00236         // ====> Row creation.
00237         //
00238         
00243         SquareLawDetectorRow *newRow();
00244         
00245         
00255         SquareLawDetectorRow *newRow(int numBand, DetectorBandTypeMod::DetectorBandType bandType);
00256         
00257 
00258 
00271          SquareLawDetectorRow *newRow(SquareLawDetectorRow *row); 
00272 
00273         //
00274         // ====> Append a row to its table.
00275         //
00276 
00277         
00278         
00279         
00289          SquareLawDetectorRow* add(SquareLawDetectorRow* x) ;
00290 
00291 
00292 
00293         //
00294         // ====> Methods returning rows.
00295         //
00296                 
00302         std::vector<SquareLawDetectorRow *> get() ;
00303         
00310          const std::vector<SquareLawDetectorRow *>& get() const ;
00311         
00312 
00313 
00314  
00315         
00325         SquareLawDetectorRow* getRowByKey(Tag squareLawDetectorId);
00326 
00327                 
00328 
00329 
00330 
00342         SquareLawDetectorRow* lookup(int numBand, DetectorBandTypeMod::DetectorBandType bandType); 
00343 
00344 
00345         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00346         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00347 
00348 private:
00349 
00358         SquareLawDetectorTable (ASDM & container);
00359 
00360         ASDM & container;
00361         
00362         bool archiveAsBin; // If true archive binary else archive XML
00363         bool fileAsBin ; // If true file binary else file XML   
00364         
00365         std::string version ; 
00366         
00367         Entity entity;
00368         
00369 
00370         // A map for the autoincrementation algorithm
00371         std::map<std::string,int>  noAutoIncIds;
00372         void autoIncrement(std::string key, SquareLawDetectorRow* x);
00373 
00374 
00378         static std::string itsName;
00379         
00383         static std::vector<std::string> attributesNames;
00384         
00388         static std::vector<std::string> attributesNamesInBin;
00389         
00390 
00394         static bool initAttributesNames(), initAttributesNamesDone ;
00395         
00396 
00400         static std::vector<std::string> key;
00401 
00402 
00412         SquareLawDetectorRow* checkAndAdd(SquareLawDetectorRow* x) ;
00413         
00419          void append(SquareLawDetectorRow* x) ;
00420          
00426          void addWithoutCheckingUnique(SquareLawDetectorRow* x) ;
00427          
00428          
00429 
00430 
00431 
00432 // A data structure to store the pointers on the table's rows.
00433 
00434 // In all cases we maintain a private vector of SquareLawDetectorRow s.
00435    std::vector<SquareLawDetectorRow * > privateRows;
00436    
00437 
00438                         
00439         std::vector<SquareLawDetectorRow *> row;
00440 
00441         
00442         void error() ; //throw(ConversionException);
00443 
00444         
00451         void fromXML(std::string& xmlDoc) ;
00452                 
00453         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00454 
00459         void setFromMIMEFile(const std::string& directory);
00460         /*
00461         void openMIMEFile(const std::string& directory);
00462         */
00463         void setFromXMLFile(const std::string& directory);
00464         
00472         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00473   
00474         
00481          void setFromMIME(const std::string & mimeMsg);
00482         
00486         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00487         
00497           void toFile(std::string directory);
00498           
00502           bool loadInProgress;
00503           void checkPresenceInMemory() {
00504                 if (!presentInMemory && !loadInProgress) {
00505                         loadInProgress = true;
00506                         setFromFile(getContainer().getDirectory());
00507                         presentInMemory = true;
00508                         loadInProgress = false;
00509                 }
00510           }
00519          void setFromFile(const std::string& directory);        
00520  
00521 };
00522 
00523 } // End namespace asdm
00524 
00525 #endif /* SquareLawDetectorTable_CLASS */